pmxtjs 2.27.7 → 2.27.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/pmxt/client.js +91 -56
- package/dist/pmxt/client.js +91 -56
- package/generated/package.json +1 -1
- package/package.json +2 -2
- package/pmxt/client.ts +91 -70
package/dist/esm/pmxt/client.js
CHANGED
|
@@ -830,15 +830,20 @@ export class Exchange {
|
|
|
830
830
|
if (limit !== undefined) {
|
|
831
831
|
args.push(limit);
|
|
832
832
|
}
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const response = await this.api.watchOrderBook({
|
|
838
|
-
exchange: this.exchangeName,
|
|
839
|
-
watchOrderBookRequest: requestBody,
|
|
833
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchOrderBook`, {
|
|
834
|
+
method: 'POST',
|
|
835
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
836
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
840
837
|
});
|
|
841
|
-
|
|
838
|
+
if (!response.ok) {
|
|
839
|
+
const body = await response.json().catch(() => ({}));
|
|
840
|
+
if (body.error && typeof body.error === "object") {
|
|
841
|
+
throw fromServerError(body.error);
|
|
842
|
+
}
|
|
843
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
844
|
+
}
|
|
845
|
+
const json = await response.json();
|
|
846
|
+
const data = this.handleResponse(json);
|
|
842
847
|
return convertOrderBook(data);
|
|
843
848
|
}
|
|
844
849
|
catch (error) {
|
|
@@ -884,15 +889,20 @@ export class Exchange {
|
|
|
884
889
|
if (limit !== undefined) {
|
|
885
890
|
args.push(limit);
|
|
886
891
|
}
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const response = await this.api.watchTrades({
|
|
892
|
-
exchange: this.exchangeName,
|
|
893
|
-
watchTradesRequest: requestBody,
|
|
892
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchTrades`, {
|
|
893
|
+
method: 'POST',
|
|
894
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
895
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
894
896
|
});
|
|
895
|
-
|
|
897
|
+
if (!response.ok) {
|
|
898
|
+
const body = await response.json().catch(() => ({}));
|
|
899
|
+
if (body.error && typeof body.error === "object") {
|
|
900
|
+
throw fromServerError(body.error);
|
|
901
|
+
}
|
|
902
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
903
|
+
}
|
|
904
|
+
const json = await response.json();
|
|
905
|
+
const data = this.handleResponse(json);
|
|
896
906
|
return data.map(convertTrade);
|
|
897
907
|
}
|
|
898
908
|
catch (error) {
|
|
@@ -929,15 +939,20 @@ export class Exchange {
|
|
|
929
939
|
if (types !== undefined) {
|
|
930
940
|
args.push(types);
|
|
931
941
|
}
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const response = await this.api.watchAddress({
|
|
937
|
-
exchange: this.exchangeName,
|
|
938
|
-
watchAddressRequest: requestBody,
|
|
942
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchAddress`, {
|
|
943
|
+
method: 'POST',
|
|
944
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
945
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
939
946
|
});
|
|
940
|
-
|
|
947
|
+
if (!response.ok) {
|
|
948
|
+
const body = await response.json().catch(() => ({}));
|
|
949
|
+
if (body.error && typeof body.error === "object") {
|
|
950
|
+
throw fromServerError(body.error);
|
|
951
|
+
}
|
|
952
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
953
|
+
}
|
|
954
|
+
const json = await response.json();
|
|
955
|
+
const data = this.handleResponse(json);
|
|
941
956
|
return convertSubscriptionSnapshot(data);
|
|
942
957
|
}
|
|
943
958
|
catch (error) {
|
|
@@ -956,15 +971,20 @@ export class Exchange {
|
|
|
956
971
|
await this.initPromise;
|
|
957
972
|
try {
|
|
958
973
|
const args = [address];
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const response = await this.api.unwatchAddress({
|
|
964
|
-
exchange: this.exchangeName,
|
|
965
|
-
unwatchAddressRequest: requestBody,
|
|
974
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/unwatchAddress`, {
|
|
975
|
+
method: 'POST',
|
|
976
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
977
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
966
978
|
});
|
|
967
|
-
|
|
979
|
+
if (!response.ok) {
|
|
980
|
+
const body = await response.json().catch(() => ({}));
|
|
981
|
+
if (body.error && typeof body.error === "object") {
|
|
982
|
+
throw fromServerError(body.error);
|
|
983
|
+
}
|
|
984
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
985
|
+
}
|
|
986
|
+
const json = await response.json();
|
|
987
|
+
return this.handleResponse(json);
|
|
968
988
|
}
|
|
969
989
|
catch (error) {
|
|
970
990
|
if (error instanceof PmxtError)
|
|
@@ -1038,15 +1058,20 @@ export class Exchange {
|
|
|
1038
1058
|
if (params.fee !== undefined) {
|
|
1039
1059
|
paramsDict.fee = params.fee;
|
|
1040
1060
|
}
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
const response = await this.api.buildOrder({
|
|
1046
|
-
exchange: this.exchangeName,
|
|
1047
|
-
buildOrderRequest: requestBody,
|
|
1061
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/buildOrder`, {
|
|
1062
|
+
method: 'POST',
|
|
1063
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1064
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1048
1065
|
});
|
|
1049
|
-
|
|
1066
|
+
if (!response.ok) {
|
|
1067
|
+
const body = await response.json().catch(() => ({}));
|
|
1068
|
+
if (body.error && typeof body.error === "object") {
|
|
1069
|
+
throw fromServerError(body.error);
|
|
1070
|
+
}
|
|
1071
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1072
|
+
}
|
|
1073
|
+
const json = await response.json();
|
|
1074
|
+
const data = this.handleResponse(json);
|
|
1050
1075
|
return data;
|
|
1051
1076
|
}
|
|
1052
1077
|
catch (error) {
|
|
@@ -1077,15 +1102,20 @@ export class Exchange {
|
|
|
1077
1102
|
async submitOrder(built) {
|
|
1078
1103
|
await this.initPromise;
|
|
1079
1104
|
try {
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
const response = await this.api.submitOrder({
|
|
1085
|
-
exchange: this.exchangeName,
|
|
1086
|
-
submitOrderRequest: requestBody,
|
|
1105
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/submitOrder`, {
|
|
1106
|
+
method: 'POST',
|
|
1107
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1108
|
+
body: JSON.stringify({ args: [built], credentials: this.getCredentials() }),
|
|
1087
1109
|
});
|
|
1088
|
-
|
|
1110
|
+
if (!response.ok) {
|
|
1111
|
+
const body = await response.json().catch(() => ({}));
|
|
1112
|
+
if (body.error && typeof body.error === "object") {
|
|
1113
|
+
throw fromServerError(body.error);
|
|
1114
|
+
}
|
|
1115
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1116
|
+
}
|
|
1117
|
+
const json = await response.json();
|
|
1118
|
+
const data = this.handleResponse(json);
|
|
1089
1119
|
return convertOrder(data);
|
|
1090
1120
|
}
|
|
1091
1121
|
catch (error) {
|
|
@@ -1142,15 +1172,20 @@ export class Exchange {
|
|
|
1142
1172
|
if (params.fee !== undefined) {
|
|
1143
1173
|
paramsDict.fee = params.fee;
|
|
1144
1174
|
}
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const response = await this.api.createOrder({
|
|
1150
|
-
exchange: this.exchangeName,
|
|
1151
|
-
createOrderRequest: requestBody,
|
|
1175
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/createOrder`, {
|
|
1176
|
+
method: 'POST',
|
|
1177
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1178
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1152
1179
|
});
|
|
1153
|
-
|
|
1180
|
+
if (!response.ok) {
|
|
1181
|
+
const body = await response.json().catch(() => ({}));
|
|
1182
|
+
if (body.error && typeof body.error === "object") {
|
|
1183
|
+
throw fromServerError(body.error);
|
|
1184
|
+
}
|
|
1185
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1186
|
+
}
|
|
1187
|
+
const json = await response.json();
|
|
1188
|
+
const data = this.handleResponse(json);
|
|
1154
1189
|
return convertOrder(data);
|
|
1155
1190
|
}
|
|
1156
1191
|
catch (error) {
|
package/dist/pmxt/client.js
CHANGED
|
@@ -833,15 +833,20 @@ class Exchange {
|
|
|
833
833
|
if (limit !== undefined) {
|
|
834
834
|
args.push(limit);
|
|
835
835
|
}
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
const response = await this.api.watchOrderBook({
|
|
841
|
-
exchange: this.exchangeName,
|
|
842
|
-
watchOrderBookRequest: requestBody,
|
|
836
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchOrderBook`, {
|
|
837
|
+
method: 'POST',
|
|
838
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
839
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
843
840
|
});
|
|
844
|
-
|
|
841
|
+
if (!response.ok) {
|
|
842
|
+
const body = await response.json().catch(() => ({}));
|
|
843
|
+
if (body.error && typeof body.error === "object") {
|
|
844
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
845
|
+
}
|
|
846
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
847
|
+
}
|
|
848
|
+
const json = await response.json();
|
|
849
|
+
const data = this.handleResponse(json);
|
|
845
850
|
return convertOrderBook(data);
|
|
846
851
|
}
|
|
847
852
|
catch (error) {
|
|
@@ -887,15 +892,20 @@ class Exchange {
|
|
|
887
892
|
if (limit !== undefined) {
|
|
888
893
|
args.push(limit);
|
|
889
894
|
}
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
const response = await this.api.watchTrades({
|
|
895
|
-
exchange: this.exchangeName,
|
|
896
|
-
watchTradesRequest: requestBody,
|
|
895
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchTrades`, {
|
|
896
|
+
method: 'POST',
|
|
897
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
898
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
897
899
|
});
|
|
898
|
-
|
|
900
|
+
if (!response.ok) {
|
|
901
|
+
const body = await response.json().catch(() => ({}));
|
|
902
|
+
if (body.error && typeof body.error === "object") {
|
|
903
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
904
|
+
}
|
|
905
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
906
|
+
}
|
|
907
|
+
const json = await response.json();
|
|
908
|
+
const data = this.handleResponse(json);
|
|
899
909
|
return data.map(convertTrade);
|
|
900
910
|
}
|
|
901
911
|
catch (error) {
|
|
@@ -932,15 +942,20 @@ class Exchange {
|
|
|
932
942
|
if (types !== undefined) {
|
|
933
943
|
args.push(types);
|
|
934
944
|
}
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
const response = await this.api.watchAddress({
|
|
940
|
-
exchange: this.exchangeName,
|
|
941
|
-
watchAddressRequest: requestBody,
|
|
945
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchAddress`, {
|
|
946
|
+
method: 'POST',
|
|
947
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
948
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
942
949
|
});
|
|
943
|
-
|
|
950
|
+
if (!response.ok) {
|
|
951
|
+
const body = await response.json().catch(() => ({}));
|
|
952
|
+
if (body.error && typeof body.error === "object") {
|
|
953
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
954
|
+
}
|
|
955
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
956
|
+
}
|
|
957
|
+
const json = await response.json();
|
|
958
|
+
const data = this.handleResponse(json);
|
|
944
959
|
return convertSubscriptionSnapshot(data);
|
|
945
960
|
}
|
|
946
961
|
catch (error) {
|
|
@@ -959,15 +974,20 @@ class Exchange {
|
|
|
959
974
|
await this.initPromise;
|
|
960
975
|
try {
|
|
961
976
|
const args = [address];
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
const response = await this.api.unwatchAddress({
|
|
967
|
-
exchange: this.exchangeName,
|
|
968
|
-
unwatchAddressRequest: requestBody,
|
|
977
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/unwatchAddress`, {
|
|
978
|
+
method: 'POST',
|
|
979
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
980
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
969
981
|
});
|
|
970
|
-
|
|
982
|
+
if (!response.ok) {
|
|
983
|
+
const body = await response.json().catch(() => ({}));
|
|
984
|
+
if (body.error && typeof body.error === "object") {
|
|
985
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
986
|
+
}
|
|
987
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
988
|
+
}
|
|
989
|
+
const json = await response.json();
|
|
990
|
+
return this.handleResponse(json);
|
|
971
991
|
}
|
|
972
992
|
catch (error) {
|
|
973
993
|
if (error instanceof errors_js_1.PmxtError)
|
|
@@ -1041,15 +1061,20 @@ class Exchange {
|
|
|
1041
1061
|
if (params.fee !== undefined) {
|
|
1042
1062
|
paramsDict.fee = params.fee;
|
|
1043
1063
|
}
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
const response = await this.api.buildOrder({
|
|
1049
|
-
exchange: this.exchangeName,
|
|
1050
|
-
buildOrderRequest: requestBody,
|
|
1064
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/buildOrder`, {
|
|
1065
|
+
method: 'POST',
|
|
1066
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1067
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1051
1068
|
});
|
|
1052
|
-
|
|
1069
|
+
if (!response.ok) {
|
|
1070
|
+
const body = await response.json().catch(() => ({}));
|
|
1071
|
+
if (body.error && typeof body.error === "object") {
|
|
1072
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1073
|
+
}
|
|
1074
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1075
|
+
}
|
|
1076
|
+
const json = await response.json();
|
|
1077
|
+
const data = this.handleResponse(json);
|
|
1053
1078
|
return data;
|
|
1054
1079
|
}
|
|
1055
1080
|
catch (error) {
|
|
@@ -1080,15 +1105,20 @@ class Exchange {
|
|
|
1080
1105
|
async submitOrder(built) {
|
|
1081
1106
|
await this.initPromise;
|
|
1082
1107
|
try {
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const response = await this.api.submitOrder({
|
|
1088
|
-
exchange: this.exchangeName,
|
|
1089
|
-
submitOrderRequest: requestBody,
|
|
1108
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/submitOrder`, {
|
|
1109
|
+
method: 'POST',
|
|
1110
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1111
|
+
body: JSON.stringify({ args: [built], credentials: this.getCredentials() }),
|
|
1090
1112
|
});
|
|
1091
|
-
|
|
1113
|
+
if (!response.ok) {
|
|
1114
|
+
const body = await response.json().catch(() => ({}));
|
|
1115
|
+
if (body.error && typeof body.error === "object") {
|
|
1116
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1117
|
+
}
|
|
1118
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1119
|
+
}
|
|
1120
|
+
const json = await response.json();
|
|
1121
|
+
const data = this.handleResponse(json);
|
|
1092
1122
|
return convertOrder(data);
|
|
1093
1123
|
}
|
|
1094
1124
|
catch (error) {
|
|
@@ -1145,15 +1175,20 @@ class Exchange {
|
|
|
1145
1175
|
if (params.fee !== undefined) {
|
|
1146
1176
|
paramsDict.fee = params.fee;
|
|
1147
1177
|
}
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const response = await this.api.createOrder({
|
|
1153
|
-
exchange: this.exchangeName,
|
|
1154
|
-
createOrderRequest: requestBody,
|
|
1178
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/createOrder`, {
|
|
1179
|
+
method: 'POST',
|
|
1180
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1181
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1155
1182
|
});
|
|
1156
|
-
|
|
1183
|
+
if (!response.ok) {
|
|
1184
|
+
const body = await response.json().catch(() => ({}));
|
|
1185
|
+
if (body.error && typeof body.error === "object") {
|
|
1186
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1187
|
+
}
|
|
1188
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1189
|
+
}
|
|
1190
|
+
const json = await response.json();
|
|
1191
|
+
const data = this.handleResponse(json);
|
|
1157
1192
|
return convertOrder(data);
|
|
1158
1193
|
}
|
|
1159
1194
|
catch (error) {
|
package/generated/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.9",
|
|
4
4
|
"description": "Unified prediction market data API - The ccxt for prediction markets",
|
|
5
5
|
"author": "PMXT Contributors",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"unified"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"pmxt-core": "2.27.
|
|
46
|
+
"pmxt-core": "2.27.9"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/jest": "^30.0.0",
|
package/pmxt/client.ts
CHANGED
|
@@ -953,17 +953,20 @@ export abstract class Exchange {
|
|
|
953
953
|
args.push(limit);
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
const response = await this.api.watchOrderBook({
|
|
962
|
-
exchange: this.exchangeName as any,
|
|
963
|
-
watchOrderBookRequest: requestBody,
|
|
956
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchOrderBook`, {
|
|
957
|
+
method: 'POST',
|
|
958
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
959
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
964
960
|
});
|
|
965
|
-
|
|
966
|
-
|
|
961
|
+
if (!response.ok) {
|
|
962
|
+
const body = await response.json().catch(() => ({}));
|
|
963
|
+
if (body.error && typeof body.error === "object") {
|
|
964
|
+
throw fromServerError(body.error);
|
|
965
|
+
}
|
|
966
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
967
|
+
}
|
|
968
|
+
const json = await response.json();
|
|
969
|
+
const data = this.handleResponse(json);
|
|
967
970
|
return convertOrderBook(data);
|
|
968
971
|
} catch (error) {
|
|
969
972
|
if (error instanceof PmxtError) throw error;
|
|
@@ -1014,17 +1017,20 @@ export abstract class Exchange {
|
|
|
1014
1017
|
args.push(limit);
|
|
1015
1018
|
}
|
|
1016
1019
|
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
const response = await this.api.watchTrades({
|
|
1023
|
-
exchange: this.exchangeName as any,
|
|
1024
|
-
watchTradesRequest: requestBody,
|
|
1020
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchTrades`, {
|
|
1021
|
+
method: 'POST',
|
|
1022
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1023
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1025
1024
|
});
|
|
1026
|
-
|
|
1027
|
-
|
|
1025
|
+
if (!response.ok) {
|
|
1026
|
+
const body = await response.json().catch(() => ({}));
|
|
1027
|
+
if (body.error && typeof body.error === "object") {
|
|
1028
|
+
throw fromServerError(body.error);
|
|
1029
|
+
}
|
|
1030
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1031
|
+
}
|
|
1032
|
+
const json = await response.json();
|
|
1033
|
+
const data = this.handleResponse(json);
|
|
1028
1034
|
return data.map(convertTrade);
|
|
1029
1035
|
} catch (error) {
|
|
1030
1036
|
if (error instanceof PmxtError) throw error;
|
|
@@ -1063,17 +1069,20 @@ export abstract class Exchange {
|
|
|
1063
1069
|
if (types !== undefined) {
|
|
1064
1070
|
args.push(types);
|
|
1065
1071
|
}
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
const response = await this.api.watchAddress({
|
|
1072
|
-
exchange: this.exchangeName as any,
|
|
1073
|
-
watchAddressRequest: requestBody,
|
|
1072
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/watchAddress`, {
|
|
1073
|
+
method: 'POST',
|
|
1074
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1075
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1074
1076
|
});
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
+
if (!response.ok) {
|
|
1078
|
+
const body = await response.json().catch(() => ({}));
|
|
1079
|
+
if (body.error && typeof body.error === "object") {
|
|
1080
|
+
throw fromServerError(body.error);
|
|
1081
|
+
}
|
|
1082
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1083
|
+
}
|
|
1084
|
+
const json = await response.json();
|
|
1085
|
+
const data = this.handleResponse(json);
|
|
1077
1086
|
return convertSubscriptionSnapshot(data);
|
|
1078
1087
|
} catch (error) {
|
|
1079
1088
|
if (error instanceof PmxtError) throw error;
|
|
@@ -1094,17 +1103,20 @@ export abstract class Exchange {
|
|
|
1094
1103
|
try {
|
|
1095
1104
|
const args: any[] = [address];
|
|
1096
1105
|
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
const response = await this.api.unwatchAddress({
|
|
1103
|
-
exchange: this.exchangeName as any,
|
|
1104
|
-
unwatchAddressRequest: requestBody,
|
|
1106
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/unwatchAddress`, {
|
|
1107
|
+
method: 'POST',
|
|
1108
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1109
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1105
1110
|
});
|
|
1106
|
-
|
|
1107
|
-
|
|
1111
|
+
if (!response.ok) {
|
|
1112
|
+
const body = await response.json().catch(() => ({}));
|
|
1113
|
+
if (body.error && typeof body.error === "object") {
|
|
1114
|
+
throw fromServerError(body.error);
|
|
1115
|
+
}
|
|
1116
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1117
|
+
}
|
|
1118
|
+
const json = await response.json();
|
|
1119
|
+
return this.handleResponse(json);
|
|
1108
1120
|
} catch (error) {
|
|
1109
1121
|
if (error instanceof PmxtError) throw error;
|
|
1110
1122
|
throw new PmxtError(`Failed to unwatch address: ${error}`);
|
|
@@ -1185,17 +1197,20 @@ export abstract class Exchange {
|
|
|
1185
1197
|
paramsDict.fee = params.fee;
|
|
1186
1198
|
}
|
|
1187
1199
|
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const response = await this.api.buildOrder({
|
|
1194
|
-
exchange: this.exchangeName as any,
|
|
1195
|
-
buildOrderRequest: requestBody,
|
|
1200
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/buildOrder`, {
|
|
1201
|
+
method: 'POST',
|
|
1202
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1203
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1196
1204
|
});
|
|
1197
|
-
|
|
1198
|
-
|
|
1205
|
+
if (!response.ok) {
|
|
1206
|
+
const body = await response.json().catch(() => ({}));
|
|
1207
|
+
if (body.error && typeof body.error === "object") {
|
|
1208
|
+
throw fromServerError(body.error);
|
|
1209
|
+
}
|
|
1210
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1211
|
+
}
|
|
1212
|
+
const json = await response.json();
|
|
1213
|
+
const data = this.handleResponse(json);
|
|
1199
1214
|
return data as BuiltOrder;
|
|
1200
1215
|
} catch (error) {
|
|
1201
1216
|
if (error instanceof PmxtError) throw error;
|
|
@@ -1225,17 +1240,20 @@ export abstract class Exchange {
|
|
|
1225
1240
|
async submitOrder(built: BuiltOrder): Promise<Order> {
|
|
1226
1241
|
await this.initPromise;
|
|
1227
1242
|
try {
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
const response = await this.api.submitOrder({
|
|
1234
|
-
exchange: this.exchangeName as any,
|
|
1235
|
-
submitOrderRequest: requestBody,
|
|
1243
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/submitOrder`, {
|
|
1244
|
+
method: 'POST',
|
|
1245
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1246
|
+
body: JSON.stringify({ args: [built as any], credentials: this.getCredentials() }),
|
|
1236
1247
|
});
|
|
1237
|
-
|
|
1238
|
-
|
|
1248
|
+
if (!response.ok) {
|
|
1249
|
+
const body = await response.json().catch(() => ({}));
|
|
1250
|
+
if (body.error && typeof body.error === "object") {
|
|
1251
|
+
throw fromServerError(body.error);
|
|
1252
|
+
}
|
|
1253
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1254
|
+
}
|
|
1255
|
+
const json = await response.json();
|
|
1256
|
+
const data = this.handleResponse(json);
|
|
1239
1257
|
return convertOrder(data);
|
|
1240
1258
|
} catch (error) {
|
|
1241
1259
|
if (error instanceof PmxtError) throw error;
|
|
@@ -1298,17 +1316,20 @@ export abstract class Exchange {
|
|
|
1298
1316
|
paramsDict.fee = params.fee;
|
|
1299
1317
|
}
|
|
1300
1318
|
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const response = await this.api.createOrder({
|
|
1307
|
-
exchange: this.exchangeName as any,
|
|
1308
|
-
createOrderRequest: requestBody,
|
|
1319
|
+
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/createOrder`, {
|
|
1320
|
+
method: 'POST',
|
|
1321
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1322
|
+
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
1309
1323
|
});
|
|
1310
|
-
|
|
1311
|
-
|
|
1324
|
+
if (!response.ok) {
|
|
1325
|
+
const body = await response.json().catch(() => ({}));
|
|
1326
|
+
if (body.error && typeof body.error === "object") {
|
|
1327
|
+
throw fromServerError(body.error);
|
|
1328
|
+
}
|
|
1329
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1330
|
+
}
|
|
1331
|
+
const json = await response.json();
|
|
1332
|
+
const data = this.handleResponse(json);
|
|
1312
1333
|
return convertOrder(data);
|
|
1313
1334
|
} catch (error) {
|
|
1314
1335
|
if (error instanceof PmxtError) throw error;
|