Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert committed Feb 27, 2024
1 parent 24982c3 commit 7f02c9d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 396 deletions.
100 changes: 1 addition & 99 deletions packages/x-client/src/IMXClient.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,10 @@
import { ImxApiClients } from '@imtbl/generated-clients';
import {
ImxConfiguration,
ImxModuleConfiguration as ImxClientModuleConfiguration,
ImxModuleConfiguration as ImxClientModuleConfiguration, // preserve old name for backwards compatibility
} from './config';
import { formatError } from './utils/formatError';
import {
// // ImmutableX,
// EthSigner,
// // generateLegacyStarkPrivateKey,
// // createStarkSigner,
// UnsignedExchangeTransferRequest,
// UnsignedMintRequest,
// WalletConnection,
// AssetsApi,
// BalancesApi,
// CollectionsApi,
// DepositsApi,
// EncodingApi,
// MintsApi,
// MetadataApi,
// OrdersApi,
// PrimarySalesApi,
// ProjectsApi,
// TokensApi,
// TradesApi,
// TransfersApi,
// UsersApi,
// WithdrawalsApi,
// DepositsApiGetDepositRequest,
// DepositsApiListDepositsRequest,
// AssetsApiGetAssetRequest,
// AssetsApiListAssetsRequest,
// CreateCollectionRequest,
// CollectionsApiGetCollectionRequest,
// CollectionsApiListCollectionFiltersRequest,
// CollectionsApiListCollectionsRequest,
// UpdateCollectionRequest,
// AddMetadataSchemaToCollectionRequest,
// MetadataApiGetMetadataSchemaRequest,
// MetadataSchemaRequest,
// BalancesApiGetBalanceRequest,
// BalancesApiListBalancesRequest,
// MintsApiGetMintRequest,
// MintsApiListMintsRequest,
// WithdrawalsApiListWithdrawalsRequest,
// WithdrawalsApiGetWithdrawalRequest,
// OrdersApiGetOrderV3Request,
// OrdersApiListOrdersV3Request,
// TradesApiGetTradeV3Request,
// TradesApiListTradesV3Request,
// TokensApiGetTokenRequest,
// TokensApiListTokensRequest,
// TransfersApiGetTransferRequest,
// TransfersApiListTransfersRequest,
// MetadataRefreshesApi,
// CreateMetadataRefreshRequest,
// ExchangesApi,
// ExchangesApiCreateExchangeRequest,
// ExchangesApiGetExchangeRequest,
// ExchangesApiGetExchangesRequest,
// NftCheckoutPrimaryApi,
// NftCheckoutPrimaryApiCreateNftPrimaryRequest,
// NftCheckoutPrimaryApiGetCurrenciesNFTCheckoutPrimaryRequest,
// NftCheckoutPrimaryApiGetNftPrimaryTransactionRequest,
// NftCheckoutPrimaryApiGetNftPrimaryTransactionsRequest,
// PrimarySalesApiSignableCreatePrimarySaleRequest,

AddMetadataSchemaToCollectionRequest,
AssetsApi,
AssetsApiGetAssetRequest,
Expand Down Expand Up @@ -913,40 +852,3 @@ export class IMXClient {

// eslint-disable-next-line @typescript-eslint/naming-convention
export const ImmutableX = IMXClient;

// methods moved to x-provider
/**
* getAddress
* registerOffchain
* isRegisteredOffchain
* isRegisteredOnchain
* createOrder
* cancelOrder
* createTrade
* transfer
* batchNftTransfer
* exchangeTransfer
* deposit
* prepareWithdrawal
* completeWithdrawal
*/

// methods moved from Core SDK that aren't in x-provider
// workflows
/**
* createCollection ✅
* updateCollection ✅
* addMetadataSchemaToCollection ✅
* updateMetadataSchemaByName ✅
* listMetadataRefreshes ✅
* getMetadataRefreshErrors ✅
* getMetadataRefreshResults ✅
* createMetadataRefresh ✅
* getProject ✅
* getProjects (removed)
* mint ✅
* exchangeTransfer ✅
* createPrimarySale ✅
* acceptPrimarySale ✅
* rejectPrimarySale ✅
*/
5 changes: 4 additions & 1 deletion packages/x-client/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export interface ImmutableXConfiguration {
ethConfiguration: EthConfiguration;
}

/**
* @dev Copied from Core SDK as a convenience for migrating away from Core SDK
*/
const createConfig = ({
coreContractAddress,
registrationContractAddress,
Expand All @@ -66,7 +69,7 @@ const createConfig = ({
};

return {
apiConfiguration: new imx.Configuration(apiConfigOptions),
apiConfiguration: new ApiConfiguration(apiConfigOptions),
ethConfiguration: {
coreContractAddress,
registrationContractAddress,
Expand Down
2 changes: 2 additions & 0 deletions packages/x-client/src/exportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export {
generateStarkPrivateKey,
generateLegacyStarkPrivateKey,
createStarkSigner,
generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, // preserve old name for backwards compatibility
createStarkSigner as imxClientCreateStarkSigner, // preserve old name for backwards compatibility
} from './utils';
10 changes: 3 additions & 7 deletions packages/x-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
export {
EthConfiguration,
ImxModuleConfiguration,
ImxModuleConfiguration as ImxClientModuleConfiguration, // preserve old name for backwards compatibility
} from './config';
export { IMXClient, ImmutableX } from './IMXClient';
export {
createStarkSigner,
createStarkSigner as imxClientCreateStarkSigner, // preserve old name for backwards compatibility
generateLegacyStarkPrivateKey,
generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, // TODO - remove console.log in utils file -- // preserve old name for backwards compatibility
generateStarkPrivateKey,
} from './utils';
export * from './exportUtils';
export * as Contracts from './exportContracts';
export { IMXError } from './types/errors';
export * from './types/requests';
export {
Expand Down
6 changes: 0 additions & 6 deletions packages/x-client/src/utils/stark/starkCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,15 @@ export function generateStarkPrivateKey(): string {
export async function generateLegacyStarkPrivateKey(
signer: Signer,
): Promise<string> {
// console.log('generateLegacyStarkPrivateKey');
const address = (await signer.getAddress()).toLowerCase();
// console.log('address', address);
const signature = await signer.signMessage(legacy.DEFAULT_SIGNATURE_MESSAGE);
// console.log('signature', signature);
const seed = splitSignature(signature).s;
// console.log('seed', seed);
const path = legacy.getAccountPath(
legacy.DEFAULT_ACCOUNT_LAYER,
legacy.DEFAULT_ACCOUNT_APPLICATION,
address,
legacy.DEFAULT_ACCOUNT_INDEX,
);
// console.log('path', path);
const key = await getKeyFromPath(seed, path, address);
// console.log('key', key);
return key.padStart(64, '0');
}
Loading

0 comments on commit 7f02c9d

Please sign in to comment.