@tradeport/sui-trading-sdk 0.4.49 → 0.4.50
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +62 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +5 -2
- package/src/apiClients/graphqlClient.ts +11 -3
- package/src/graphql/gqlChainRequest.ts +1 -0
package/package.json
CHANGED
package/src/SuiTradingClient.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getFullnodeUrl } from '@mysten/sui/client';
|
|
2
2
|
import { type Transaction } from '@mysten/sui/transactions';
|
|
3
|
-
import {
|
|
3
|
+
import { GraphQLClient } from 'graphql-request';
|
|
4
4
|
import createKioskClient from './apiClients/createKioskClient';
|
|
5
5
|
import createSuiClient from './apiClients/createSuiClient';
|
|
6
6
|
import { getGraphqlClient, setGraphqlClient } from './apiClients/graphqlClient';
|
|
@@ -74,6 +74,7 @@ import {
|
|
|
74
74
|
type ApiConfig = {
|
|
75
75
|
apiUser: string;
|
|
76
76
|
apiKey: string;
|
|
77
|
+
apiUrl: string;
|
|
77
78
|
suiNodeUrl?: string;
|
|
78
79
|
graphQLClient?: GraphQLClient;
|
|
79
80
|
};
|
|
@@ -91,7 +92,7 @@ class SuiTradingClient {
|
|
|
91
92
|
private readonly kioskClient: ReturnType<typeof createKioskClient>;
|
|
92
93
|
private readonly allowedApiUsersForUnsharedKiosksMigration = ['tradeport.xyz', 'mercato.xyz'];
|
|
93
94
|
|
|
94
|
-
constructor({ apiUser, apiKey, suiNodeUrl, graphQLClient }: ApiConfig) {
|
|
95
|
+
constructor({ apiUser, apiKey, apiUrl, suiNodeUrl, graphQLClient }: ApiConfig) {
|
|
95
96
|
this.apiUser = apiUser;
|
|
96
97
|
this.apiKey = apiKey;
|
|
97
98
|
this.suiClient = createSuiClient(suiNodeUrl || getFullnodeUrl('mainnet'));
|
|
@@ -99,6 +100,8 @@ class SuiTradingClient {
|
|
|
99
100
|
|
|
100
101
|
if (graphQLClient) {
|
|
101
102
|
setGraphqlClient(graphQLClient);
|
|
103
|
+
} else {
|
|
104
|
+
setGraphqlClient(new GraphQLClient(apiUrl));
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
getGraphqlClient().setHeaders({
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
2
|
|
|
3
|
-
let graphqlClient
|
|
3
|
+
let graphqlClient: GraphQLClient;
|
|
4
4
|
|
|
5
|
-
export const getGraphqlClient = () =>
|
|
5
|
+
export const getGraphqlClient = () => {
|
|
6
|
+
if (!graphqlClient) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
'GraphQL client not initialized. Please provide apiUrl to SuiTradingClient constructor.',
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return graphqlClient;
|
|
13
|
+
};
|
|
6
14
|
|
|
7
15
|
export function setGraphqlClient(client: GraphQLClient) {
|
|
8
16
|
graphqlClient = client;
|