@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradeport/sui-trading-sdk",
3
3
  "license": "MIT",
4
- "version": "0.4.49",
4
+ "version": "0.4.50",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { getFullnodeUrl } from '@mysten/sui/client';
2
2
  import { type Transaction } from '@mysten/sui/transactions';
3
- import { type GraphQLClient } from 'graphql-request';
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 = new GraphQLClient('https://api.indexer.xyz/graphql');
3
+ let graphqlClient: GraphQLClient;
4
4
 
5
- export const getGraphqlClient = () => graphqlClient;
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;
@@ -16,5 +16,6 @@ export const gqlChainRequest = async ({ chain, query, variables }: Args) => {
16
16
  createChainGQLQuery({ chain, query }),
17
17
  variables,
18
18
  );
19
+
19
20
  return response?.[chain];
20
21
  };