Skip to content

Commit

Permalink
Add extensions to all SDK import paths (MystenLabs#15595)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
hayes-mysten authored Jan 6, 2024
1 parent 73360dd commit 9ac0a4e
Show file tree
Hide file tree
Showing 49 changed files with 184 additions and 179 deletions.
11 changes: 11 additions & 0 deletions .changeset/empty-carrots-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@mysten/wallet-standard': patch
'@mysten/suins-toolkit': patch
'@mysten/create-dapp': patch
'@mysten/sui.js': patch
'@mysten/deepbook': patch
'@mysten/kiosk': patch
'@mysten/bcs': patch
---

Add extensions to all sdk import paths
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
},
overrides: [
{
files: ['sdk/typescript/src/**/*', 'sdk/dapp-kit/**/*', 'sdk/zklogin/**/*', 'sdk/enoki/**/*'],
files: ['sdk/**/*'],
rules: {
'require-extensions/require-extensions': 'error',
'require-extensions/require-index': 'error',
Expand Down Expand Up @@ -271,6 +271,7 @@ module.exports = {
files: ['sdk/create-dapp/templates/**/*'],
rules: {
'header/header': 'off',
'require-extensions/require-extensions': 'off',
},
},
],
Expand Down
13 changes: 7 additions & 6 deletions sdk/bcs/src/bcs-type.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { toB58 } from './b58';
import { toB64 } from './b64';
import { toHEX } from './hex';
import { BcsReader } from './reader';
import { ulebEncode } from './uleb';
import { BcsWriter, BcsWriterOptions } from './writer';
import { toB58 } from './b58.js';
import { toB64 } from './b64.js';
import { toHEX } from './hex.js';
import { BcsReader } from './reader.js';
import { ulebEncode } from './uleb.js';
import type { BcsWriterOptions } from './writer.js';
import { BcsWriter } from './writer.js';

export interface BcsTypeOptions<T, Input = T> {
name?: string;
Expand Down
4 changes: 2 additions & 2 deletions sdk/bcs/src/bcs.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import type { BcsTypeOptions } from './bcs-type.js';
import {
BcsType,
BcsTypeOptions,
bigUIntBcsType,
dynamicSizeBcsType,
fixedSizeBcsType,
lazyBcsType,
stringLikeBcsType,
uIntBcsType,
} from './bcs-type.js';
import { GenericPlaceholder, ReplaceBcsGenerics } from './types.js';
import type { GenericPlaceholder, ReplaceBcsGenerics } from './types.js';
import { ulebEncode } from './uleb.js';

export const bcs = {
Expand Down
8 changes: 5 additions & 3 deletions sdk/bcs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

import { fromB58, toB58 } from './b58.js';
import { fromB64, toB64 } from './b64.js';
import { BcsType, BcsTypeOptions, isSerializedBcs, SerializedBcs } from './bcs-type.js';
import type { BcsTypeOptions } from './bcs-type.js';
import { BcsType, isSerializedBcs, SerializedBcs } from './bcs-type.js';
import { bcs } from './bcs.js';
import { fromHEX, toHEX } from './hex.js';
import { BcsReader } from './reader.js';
import { type InferBcsInput, type InferBcsType } from './types.js';
import type { InferBcsInput, InferBcsType } from './types.js';
import { decodeStr, encodeStr, splitGenericParameters } from './utils.js';
import { BcsWriter, BcsWriterOptions } from './writer.js';
import type { BcsWriterOptions } from './writer.js';
import { BcsWriter } from './writer.js';

export * from './legacy-registry.js';

Expand Down
5 changes: 3 additions & 2 deletions sdk/bcs/src/legacy-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { fromB64, toB64 } from './b64.js';
import { BcsType } from './bcs-type.js';
import { fromHEX, toHEX } from './hex.js';
import { BcsReader } from './reader.js';
import { Encoding } from './types.js';
import type { Encoding } from './types.js';
import { decodeStr, splitGenericParameters } from './utils.js';
import { BcsWriter, BcsWriterOptions } from './writer.js';
import type { BcsWriterOptions } from './writer.js';
import { BcsWriter } from './writer.js';

/**
* Allows for array definitions for names.
Expand Down
2 changes: 1 addition & 1 deletion sdk/bcs/src/reader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { ulebDecode } from './uleb';
import { ulebDecode } from './uleb.js';

/**
* Class used for reading BCS data chunk by chunk. Meant to be used
Expand Down
2 changes: 1 addition & 1 deletion sdk/bcs/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { type BcsType } from './bcs-type';
import type { BcsType } from './bcs-type.js';

/**
* Supported encodings.
Expand Down
8 changes: 4 additions & 4 deletions sdk/bcs/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { fromB58, toB58 } from './b58';
import { fromB64, toB64 } from './b64';
import { fromHEX, toHEX } from './hex';
import { Encoding } from './types';
import { fromB58, toB58 } from './b58.js';
import { fromB64, toB64 } from './b64.js';
import { fromHEX, toHEX } from './hex.js';
import type { Encoding } from './types.js';

/**
* Encode data with either `hex` or `base64`.
Expand Down
6 changes: 3 additions & 3 deletions sdk/bcs/src/writer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { Encoding } from './types';
import { ulebEncode } from './uleb';
import { encodeStr } from './utils';
import type { Encoding } from './types.js';
import { ulebEncode } from './uleb.js';
import { encodeStr } from './utils.js';

export interface BcsWriterOptions {
/** The initial size (in bytes) of the buffer tht will be allocated */
Expand Down
2 changes: 1 addition & 1 deletion sdk/bcs/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { BCS } from '../src/index';
import type { BCS } from '../src/index.js';

/** Serialize and deserialize the result. */
export function serde(bcs: BCS, type: any, data: any): any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useSuiClient,
useSuiClientQuery,
} from "@mysten/dapp-kit";
import { SuiObjectData } from "@mysten/sui.js/client";
import type { SuiObjectData } from "@mysten/sui.js/client";
import { TransactionBlock } from "@mysten/sui.js/transactions";
import { Button, Flex, Heading, Text } from "@radix-ui/themes";
import { useNetworkVariable } from "./networkConfig";
Expand Down
23 changes: 8 additions & 15 deletions sdk/deepbook/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import {
getFullnodeUrl,
OrderArguments,
PaginatedEvents,
PaginationArguments,
SuiClient,
} from '@mysten/sui.js/client';
import {
import type { OrderArguments, PaginatedEvents, PaginationArguments } from '@mysten/sui.js/client';
import { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';
import type {
TransactionArgument,
TransactionBlock,
TransactionObjectInput,
TransactionResult,
} from '@mysten/sui.js/transactions';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import {
normalizeStructTag,
normalizeSuiAddress,
Expand All @@ -22,25 +17,23 @@ import {
SUI_CLOCK_OBJECT_ID,
} from '@mysten/sui.js/utils';

import {
bcs,
import type {
Level2BookStatusPoint,
LimitOrderType,
MarketPrice,
Order,
PaginatedPoolSummary,
PoolSummary,
SelfMatchingPreventionStyle,
UserPosition,
} from './types';
} from './types/index.js';
import { bcs, LimitOrderType, SelfMatchingPreventionStyle } from './types/index.js';
import {
CREATION_FEE,
MODULE_CLOB,
MODULE_CUSTODIAN,
NORMALIZED_SUI_COIN_TYPE,
ORDER_DEFAULT_EXPIRATION_IN_MS,
PACKAGE_ID,
} from './utils';
} from './utils/index.js';

const DUMMY_ADDRESS = normalizeSuiAddress('0x0');

Expand Down
2 changes: 1 addition & 1 deletion sdk/deepbook/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

export * from './client';
export * from './client.js';
4 changes: 2 additions & 2 deletions sdk/deepbook/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { EventId } from '@mysten/sui.js/client';
import type { EventId } from '@mysten/sui.js/client';

export * from './bcs';
export * from './bcs.js';

export interface PoolSummary {
poolId: string;
Expand Down
2 changes: 1 addition & 1 deletion sdk/deepbook/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

export * from './constants';
export * from './constants.js';
11 changes: 5 additions & 6 deletions sdk/deepbook/test/e2e/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
// SPDX-License-Identifier: Apache-2.0

import { execSync } from 'child_process';
import {
import type {
DevInspectResults,
getFullnodeUrl,
SuiClient,
SuiObjectChangeCreated,
SuiObjectChangePublished,
SuiTransactionBlockResponse,
} from '@mysten/sui.js/client';
import { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';
import { FaucetRateLimitError, getFaucetHost, requestSuiFromFaucetV0 } from '@mysten/sui.js/faucet';
import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import tmp from 'tmp';
import { retry } from 'ts-retry-promise';
import { expect } from 'vitest';

import { DeepBookClient } from '../../src';
import { PoolSummary } from '../../src/types';
import { FLOAT_SCALING_FACTOR, NORMALIZED_SUI_COIN_TYPE } from '../../src/utils';
import { DeepBookClient } from '../../src/index.js';
import type { PoolSummary } from '../../src/types/index.js';
import { FLOAT_SCALING_FACTOR, NORMALIZED_SUI_COIN_TYPE } from '../../src/utils/index.js';

const DEFAULT_FAUCET_URL = import.meta.env.VITE_FAUCET_URL ?? getFaucetHost('localnet');
const DEFAULT_FULLNODE_URL = import.meta.env.VITE_FULLNODE_URL ?? getFullnodeUrl('localnet');
Expand Down
3 changes: 2 additions & 1 deletion sdk/docs/examples/wallet-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
import { getFullnodeUrl } from '@mysten/sui.js/client';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ComponentProps, useEffect, useState } from 'react';
import type { ComponentProps } from 'react';
import { useEffect, useState } from 'react';

import '@mysten/dapp-kit/dist/index.css';

Expand Down
2 changes: 1 addition & 1 deletion sdk/kiosk/src/bcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
KIOSK_TYPE,
TRANSFER_POLICY_CREATED_EVENT,
TRANSFER_POLICY_TYPE,
} from './types';
} from './types/index.js';

// Register the `Kiosk` struct for faster queries.
bcs.registerStructType(KIOSK_TYPE, {
Expand Down
25 changes: 12 additions & 13 deletions sdk/kiosk/src/client/kiosk-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { type SuiClient } from '@mysten/sui.js/client';
import type { SuiClient } from '@mysten/sui.js/client';

import {
FLOOR_PRICE_RULE_ADDRESS,
Expand All @@ -10,22 +10,21 @@ import {
PERSONAL_KIOSK_RULE_ADDRESS,
ROYALTY_RULE_ADDRESS,
rules,
type BaseRulePackageIds,
type TransferPolicyRule,
} from '../constants';
import { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk';
} from '../constants.js';
import type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';
import { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk.js';
import {
queryOwnedTransferPolicies,
queryTransferPolicy,
queryTransferPolicyCapsByType,
} from '../query/transfer-policy';
import {
Network,
type FetchKioskOptions,
type KioskClientOptions,
type KioskData,
type OwnedKiosks,
} from '../types';
} from '../query/transfer-policy.js';
import { Network } from '../types/index.js';
import type {
FetchKioskOptions,
KioskClientOptions,
KioskData,
OwnedKiosks,
} from '../types/index.js';

/**
* A Client that allows you to interact with kiosk.
Expand Down
20 changes: 10 additions & 10 deletions sdk/kiosk/src/client/kiosk-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import {
import type {
TransactionArgument,
TransactionBlock,
TransactionObjectArgument,
type TransactionArgument,
type TransactionBlock,
} from '@mysten/sui.js/transactions';

import * as kioskTx from '../tx/kiosk';
import { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk';
import { confirmRequest } from '../tx/transfer-policy';
import {
import * as kioskTx from '../tx/kiosk.js';
import { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';
import { confirmRequest } from '../tx/transfer-policy.js';
import type {
ItemId,
ItemReference,
ItemValue,
KioskOwnerCap,
ObjectArgument,
Price,
PurchaseOptions,
} from '../types';
import { getNormalizedRuleType } from '../utils';
import { type KioskClient } from './kiosk-client';
} from '../types/index.js';
import { getNormalizedRuleType } from '../utils.js';
import type { KioskClient } from './kiosk-client.js';

export type KioskTransactionParams = {
/** The TransactionBlock for this run */
Expand Down
Loading

0 comments on commit 9ac0a4e

Please sign in to comment.