Skip to content

Commit

Permalink
[ts sdk] Remove deprecated types directory (MystenLabs#16237)
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 Feb 14, 2024
1 parent dc904ca commit 0cafa94
Show file tree
Hide file tree
Showing 53 changed files with 120 additions and 965 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-bags-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/sui.js': minor
---

Remove deprecated types directory
1 change: 0 additions & 1 deletion apps/wallet/configs/ts/tsconfig.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"_values/*": ["./src/ui/styles/values/*"],
"_utils": ["./src/ui/styles/utils"],
"_utils/*": ["./src/ui/styles/utils/*"],
"@mysten/sui.js/transactions": ["../../sdk/typescript/src/builder/export.ts"],
"@mysten/sui.js/*": ["../../sdk/typescript/src/*"],
"@mysten/sui.js": ["../../sdk/typescript/src/"],
"@mysten/kiosk": ["../../sdk/kiosk/src/index.ts"],
Expand Down
3 changes: 1 addition & 2 deletions apps/wallet/src/ui/app/components/nft-display/Kiosk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import { getKioskIdFromOwnerCap, hasDisplayData, useGetKioskContents } from '@mysten/core';
import { type SuiObjectResponse } from '@mysten/sui.js/client';
import { getObjectDisplay } from '@mysten/sui.js/types';
import cl from 'clsx';

import { useActiveAddress } from '../../hooks';
Expand All @@ -28,7 +27,7 @@ const cardStyles = [

function getLabel(item?: SuiObjectResponse) {
if (!item) return;
const display = getObjectDisplay(item)?.data;
const display = item.data?.display?.data;
return display?.name ?? display?.description ?? item.data?.objectId;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/src/ui/app/hooks/deepbook/useGetEstimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { DEEPBOOK_KEY, WALLET_FEES_PERCENTAGE } from '_pages/swap/constants';
import { useDeepBookContext } from '_shared/deepBook/context';
import { useSuiClient } from '@mysten/dapp-kit';
import { type DeepBookClient } from '@mysten/deepbook';
import { TransactionBlock } from '@mysten/sui.js/builder';
import { type CoinStruct, type SuiClient } from '@mysten/sui.js/client';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import * as Sentry from '@sentry/react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import BigNumber from 'bignumber.js';
Expand Down
2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
- '!sdk/create-dapp/templates'
- '!sdk/typescript/*/**'
- '!sdk/typescript/scripts'
- '!sdk/typescript/builder'
- '!sdk/typescript/transactions'
- '!sdk/typescript/cryptography'
- '!sdk/typescript/faucet'
- '!sdk/typescript/transactions'
Expand Down
3 changes: 2 additions & 1 deletion sdk/dapp-kit/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default defineConfig({
).pathname,
'@mysten/sui.js/client': new URL('../typescript/src/client', import.meta.url).pathname,
'@mysten/sui.js/utils': new URL('../typescript/src/utils', import.meta.url).pathname,
'@mysten/sui.js/transactions': new URL('../typescript/src/builder', import.meta.url).pathname,
'@mysten/sui.js/transactions': new URL('../typescript/src/transactions', import.meta.url)
.pathname,
},
},
});
2 changes: 1 addition & 1 deletion sdk/graphql-transport/test/compatability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import { beforeAll, describe, expect, test } from 'vitest';

import { TransactionBlock } from '../../typescript/src/builder/index.js';
import {
getFullnodeUrl,
SuiClient,
SuiObjectData,
SuiTransactionBlockResponse,
} from '../../typescript/src/client/index.js';
import { TransactionBlock } from '../../typescript/src/transactions/index.js';
import { publishPackage, setup, TestToolbox } from '../../typescript/test/e2e/utils/setup';
import { SuiClientGraphQLTransport } from '../src/transport';

Expand Down
2 changes: 1 addition & 1 deletion sdk/graphql-transport/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rootDir": "src",
"paths": {
"@mysten/sui.js/client": ["../../typescrupt/src/client"],
"@mysten/sui.js/transactions": ["../../typescript/src/builder"]
"@mysten/sui.js/transactions": ["../../typescript/src/transactions"]
}
},
"references": [{ "path": "../wallet-standard" }, { "path": "../typescript" }]
Expand Down
2 changes: 1 addition & 1 deletion sdk/graphql-transport/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
alias: {
'@mysten/bcs': new URL('../bcs/src', import.meta.url).toString(),
'@mysten/sui.js/transactions': new URL(
'../typescript/src/builder',
'../typescript/src/transactions',
import.meta.url,
).toString(),
'@mysten/sui.js': new URL('../typescript/src', import.meta.url).toString(),
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"require": "./dist/cjs/multisig/index.js"
},
"./transactions": {
"import": "./dist/esm/builder/export.js",
"require": "./dist/cjs/builder/export.js"
"import": "./dist/esm/transactions/export.js",
"require": "./dist/cjs/transactions/export.js"
},
"./utils": {
"import": "./dist/esm/utils/index.js",
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ methodGenerator.imports.push(
),
]),
),
ts.factory.createStringLiteral('../../builder/index.js'),
ts.factory.createStringLiteral('../../transactions/index.js'),
),
);

Expand Down
18 changes: 13 additions & 5 deletions sdk/typescript/src/bcs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
toHEX,
} from '@mysten/bcs';

import type { MoveCallTransaction } from '../builder/Transactions.js';
import type { SuiObjectRef as SuiObjectRefType } from '../types/objects.js';
import type { MoveCallTransaction } from '../transactions/Transactions.js';
import { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';
import { TypeTagSerializer } from './type-tag-serializer.js';

Expand All @@ -35,13 +34,22 @@ export type SharedObjectRef = {
mutable: boolean;
};

export type SuiObjectRef = {
/** Base64 string representing the object digest */
objectId: string;
/** Object version */
version: number | string | bigint;
/** Hex code as string representing the object id */
digest: string;
};

/**
* An object argument.
*/
export type ObjectArg =
| { ImmOrOwned: SuiObjectRefType }
| { ImmOrOwned: SuiObjectRef }
| { Shared: SharedObjectRef }
| { Receiving: SuiObjectRefType };
| { Receiving: SuiObjectRef };

/**
* A pure argument.
Expand Down Expand Up @@ -109,7 +117,7 @@ export type TypeTag =
* The GasData to be used in the transaction.
*/
export type GasData = {
payment: SuiObjectRefType[];
payment: SuiObjectRef[];
owner: string; // Gas Object's owner
price: number;
budget: number;
Expand Down
9 changes: 0 additions & 9 deletions sdk/typescript/src/builder/utils.ts

This file was deleted.

4 changes: 2 additions & 2 deletions sdk/typescript/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
import { fromB58, toB64, toHEX } from '@mysten/bcs';

import type { TransactionBlock } from '../builder/index.js';
import { isTransactionBlock } from '../builder/index.js';
import type { Signer } from '../cryptography/index.js';
import type { TransactionBlock } from '../transactions/index.js';
import { isTransactionBlock } from '../transactions/index.js';
import {
isValidSuiAddress,
isValidSuiObjectId,
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/src/client/types/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* /crates/sui-open-rpc/spec/openrpc.json
*/

import type { TransactionBlock } from '../../builder/index.js';
import type { TransactionBlock } from '../../transactions/index.js';
import type * as RpcTypes from './generated.js';

/**
Expand Down
6 changes: 3 additions & 3 deletions sdk/typescript/src/signers/signer-with-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import { fromB64, toB64 } from '@mysten/bcs';

import { bcs } from '../bcs/index.js';
import type { TransactionBlock } from '../builder/TransactionBlock.js';
import { isTransactionBlock } from '../builder/TransactionBlock.js';
import { TransactionBlockDataBuilder } from '../builder/TransactionBlockData.js';
import type {
DevInspectResults,
DryRunTransactionBlockResponse,
Expand All @@ -17,6 +14,9 @@ import type {
} from '../client/index.js';
import { IntentScope, messageWithIntent } from '../cryptography/intent.js';
import type { SerializedSignature } from '../cryptography/signature.js';
import type { TransactionBlock } from '../transactions/TransactionBlock.js';
import { isTransactionBlock } from '../transactions/TransactionBlock.js';
import { TransactionBlockDataBuilder } from '../transactions/TransactionBlockData.js';
import type { Signer } from './signer.js';
import type { SignedMessage, SignedTransaction } from './types.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
import type { SerializedBcs } from '@mysten/bcs';
import { isSerializedBcs } from '@mysten/bcs';
import type { Infer } from 'superstruct';
import { array, boolean, integer, object, string, union } from 'superstruct';
import { array, bigint, boolean, integer, number, object, string, union } from 'superstruct';

import { bcs } from '../bcs/index.js';
import type { SharedObjectRef } from '../bcs/index.js';
import { SuiObjectRef } from '../types/index.js';
import { normalizeSuiAddress } from '../utils/sui-types.js';

export const SuiObjectRef = object({
/** Base64 string representing the object digest */
digest: string(),
/** Hex code as string representing the object id */
objectId: string(),
/** Object version */
version: union([number(), string(), bigint()]),
});
export type SuiObjectRef = Infer<typeof SuiObjectRef>;

const ObjectArg = union([
object({ ImmOrOwned: SuiObjectRef }),
object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import { is, mask } from 'superstruct';
import { bcs } from '../bcs/index.js';
import type { ProtocolConfig, SuiClient, SuiMoveNormalizedType } from '../client/index.js';
import type { SignatureWithBytes, Signer } from '../cryptography/index.js';
import type { SuiObjectResponse } from '../types/index.js';
import {
extractMutableReference,
extractReference,
extractStructTag,
getObjectReference,
SuiObjectRef,
} from '../types/index.js';
import { SUI_TYPE_ARG } from '../utils/index.js';
import { normalizeSuiAddress, normalizeSuiObjectId } from '../utils/sui-types.js';
import {
Expand All @@ -25,14 +17,15 @@ import {
isMutableSharedObjectInput,
ObjectCallArg,
PureCallArg,
SuiObjectRef,
} from './Inputs.js';
import { createPure } from './pure.js';
import { getPureSerializationType, isTxContext } from './serializer.js';
import type { TransactionExpiration } from './TransactionBlockData.js';
import { TransactionBlockDataBuilder } from './TransactionBlockData.js';
import type { MoveCallTransaction, TransactionArgument, TransactionType } from './Transactions.js';
import { TransactionBlockInput, Transactions } from './Transactions.js';
import { create } from './utils.js';
import { create, extractMutableReference, extractReference, extractStructTag } from './utils.js';

export type TransactionObjectArgument = Exclude<
TransactionArgument,
Expand Down Expand Up @@ -804,9 +797,9 @@ export class TransactionBlock {
mutable,
});
} else if (normalizedType && isReceivingType(normalizedType)) {
input.value = Inputs.ReceivingRef(getObjectReference(object)!);
input.value = Inputs.ReceivingRef(object.data!);
} else {
input.value = Inputs.ObjectRef(getObjectReference(object as SuiObjectResponse)!);
input.value = Inputs.ObjectRef(object.data!);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import {
} from 'superstruct';

import { bcs } from '../bcs/index.js';
import { SuiObjectRef } from '../types/index.js';
import { normalizeSuiAddress } from '../utils/sui-types.js';
import { hashTypedData } from './hash.js';
import { BuilderCallArg, PureCallArg } from './Inputs.js';
import { BuilderCallArg, PureCallArg, SuiObjectRef } from './Inputs.js';
import { TransactionBlockInput, TransactionType } from './Transactions.js';
import { create } from './utils.js';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

import type { SuiJsonValue, SuiMoveNormalizedType } from '../client/index.js';
import { extractStructTag } from '../types/index.js';
import { MOVE_STDLIB_ADDRESS, SUI_FRAMEWORK_ADDRESS } from '../utils/index.js';
import { isValidSuiAddress } from '../utils/sui-types.js';
import { extractStructTag } from './utils.js';

const OBJECT_MODULE_NAME = 'object';
const ID_STRUCT_NAME = 'ID';
Expand Down
47 changes: 47 additions & 0 deletions sdk/typescript/src/transactions/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import type { Struct } from 'superstruct';
import { create as superstructCreate } from 'superstruct';

import type { SuiMoveNormalizedType } from '../client/index.js';

export function create<T, S>(value: T, struct: Struct<T, S>): T {
return superstructCreate(value, struct);
}

export function extractMutableReference(
normalizedType: SuiMoveNormalizedType,
): SuiMoveNormalizedType | undefined {
return typeof normalizedType === 'object' && 'MutableReference' in normalizedType
? normalizedType.MutableReference
: undefined;
}

export function extractReference(
normalizedType: SuiMoveNormalizedType,
): SuiMoveNormalizedType | undefined {
return typeof normalizedType === 'object' && 'Reference' in normalizedType
? normalizedType.Reference
: undefined;
}

export function extractStructTag(
normalizedType: SuiMoveNormalizedType,
): Extract<SuiMoveNormalizedType, { Struct: unknown }> | undefined {
if (typeof normalizedType === 'object' && 'Struct' in normalizedType) {
return normalizedType;
}

const ref = extractReference(normalizedType);
const mutRef = extractMutableReference(normalizedType);

if (typeof ref === 'object' && 'Struct' in ref) {
return ref;
}

if (typeof mutRef === 'object' && 'Struct' in mutRef) {
return mutRef;
}
return undefined;
}
42 changes: 0 additions & 42 deletions sdk/typescript/src/types/common.ts

This file was deleted.

Loading

0 comments on commit 0cafa94

Please sign in to comment.