Skip to content

Commit

Permalink
Remove deprecated APIs (#14152)
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 not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### 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
Jordan-Mysten authored Oct 10, 2023
1 parent 6ade193 commit 11cf4e6
Show file tree
Hide file tree
Showing 33 changed files with 79 additions and 2,460 deletions.
6 changes: 6 additions & 0 deletions .changeset/nasty-weeks-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@mysten/wallet-kit': minor
'@mysten/sui.js': minor
---

Remove deprecated methods.
2 changes: 1 addition & 1 deletion apps/wallet/src/background/accounts/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export abstract class Account<
return toSerializedSignature({
signature,
signatureScheme,
pubKey: pubkey,
publicKey: pubkey,
});
}

Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/src/background/keyring/AccountKeypair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AccountKeypair {
return toSerializedSignature({
signature,
signatureScheme,
pubKey: pubkey,
publicKey: pubkey,
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/wallet/src/ui/app/LedgerSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export class LedgerSigner extends WalletSigner {
async signData(data: Uint8Array): Promise<SerializedSignature> {
const ledgerClient = await this.#initializeSuiLedgerClient();
const { signature } = await ledgerClient.signTransaction(this.#derivationPath, data);
const pubKey = await this.getPublicKey();
const publicKey = await this.getPublicKey();
return toSerializedSignature({
signature,
signatureScheme: this.#signatureScheme,
pubKey,
publicKey,
});
}

Expand Down
41 changes: 35 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdk/move-binary-format-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"vitest": "^0.33.0"
"vitest": "^0.33.0",
"wasm-pack": "^0.12.1"
}
}
44 changes: 5 additions & 39 deletions sdk/typescript/src/builder/TransactionBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { bcs } from '../bcs/index.js';
import type { ProtocolConfig, SuiClient, SuiMoveNormalizedType } from '../client/index.js';
import type { Keypair, SignatureWithBytes } from '../cryptography/index.js';
import { SUI_TYPE_ARG } from '../framework/framework.js';
import type { JsonRpcProvider } from '../providers/json-rpc-provider.js';
import type { SuiObjectResponse } from '../types/index.js';
import {
extractMutableReference,
Expand Down Expand Up @@ -96,13 +95,13 @@ function createTransactionResult(index: number): TransactionResult {
}

function expectClient(options: BuildOptions): SuiClient {
if (!options.client && !options.provider) {
if (!options.client) {
throw new Error(
`No provider passed to Transaction#build, but transaction data was not sufficient to build offline.`,
);
}

return (options.client ?? options.provider!) as SuiClient;
return options.client;
}

const TRANSACTION_BRAND = Symbol.for('@mysten/transaction');
Expand Down Expand Up @@ -132,11 +131,7 @@ const chunk = <T>(arr: T[], size: number): T[][] =>
);

interface BuildOptions {
/**
* @deprecated Use `client` instead.
*/
provider?: JsonRpcProvider | SuiClient;
client?: SuiClient | JsonRpcProvider;
client?: SuiClient;
onlyTransactionKind?: boolean;
/** Define a protocol config to build against, instead of having it fetched from the provider at build time. */
protocolConfig?: ProtocolConfig;
Expand All @@ -156,13 +151,6 @@ export function isTransactionBlock(obj: unknown): obj is TransactionBlock {
* Transaction Builder
*/
export class TransactionBlock {
/** Returns `true` if the object is an instance of the Transaction builder class.
* @deprecated Use `isTransactionBlock` from `@mysten/sui.js/transactions` instead.
*/
static is(obj: unknown): obj is TransactionBlock {
return !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true;
}

/**
* Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.
* Supports either a byte array, or base64-encoded bytes.
Expand Down Expand Up @@ -198,22 +186,6 @@ export class TransactionBlock {
return tx;
}

/**
* A helper to retrieve the Transaction builder `Transactions`
* @deprecated Either use the helper methods on the `TransactionBlock` class, or import `Transactions` from `@mysten/sui.js/transactions`.
*/
static get Transactions() {
return Transactions;
}

/**
* A helper to retrieve the Transaction builder `Inputs`
* * @deprecated Either use the helper methods on the `TransactionBlock` class, or import `Inputs` from `@mysten/sui.js/transactions`.
*/
static get Inputs() {
return Inputs;
}

setSender(sender: string) {
this.#blockData.sender = sender;
}
Expand Down Expand Up @@ -526,10 +498,6 @@ export class TransactionBlock {
/** Derive transaction digest */
async getDigest(
options: {
/**
* @deprecated Use `client` instead.
*/
provider?: JsonRpcProvider | SuiClient;
client?: SuiClient;
} = {},
): Promise<string> {
Expand Down Expand Up @@ -806,10 +774,8 @@ export class TransactionBlock {
throw new Error('Missing transaction sender');
}

const client = options.client || options.provider;

if (!options.protocolConfig && !options.limits && client) {
options.protocolConfig = await client.getProtocolConfig();
if (!options.protocolConfig && !options.limits && options.client) {
options.protocolConfig = await options.client.getProtocolConfig();
}

await Promise.all([this.#prepareGasPrice(options), this.#prepareTransactions(options)]);
Expand Down
9 changes: 1 addition & 8 deletions sdk/typescript/src/cryptography/keypair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export abstract class BaseSigner {
const signature = toSerializedSignature({
signature: await this.sign(digest),
signatureScheme: this.getKeyScheme(),
pubKey: this.getPublicKey(),
publicKey: this.getPublicKey(),
});

return {
Expand All @@ -64,13 +64,6 @@ export abstract class BaseSigner {
);
}

/**
* @deprecated use `signPersonalMessage` instead
*/
async signMessage(bytes: Uint8Array) {
return this.signPersonalMessage(bytes);
}

toSuiAddress(): string {
return this.getPublicKey().toSuiAddress();
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/src/cryptography/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function decodeMultiSig(signature: string): SignaturePubkeyPair[] {
}

function toPkWeightPair(pair: PubkeyWeightPair): PubkeyEnumWeightPair {
let pk_bytes = Array.from(pair.pubKey.toBytes().map((x) => Number(x)));
let pk_bytes = Array.from(pair.pubKey.toRawBytes().map((x) => Number(x)));
switch (pair.pubKey.flag()) {
case SIGNATURE_SCHEME_TO_FLAG['Secp256k1']:
return {
Expand Down
18 changes: 4 additions & 14 deletions sdk/typescript/src/cryptography/publickey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ export abstract class PublicKey {
return toB64(this.toRawBytes());
}

/**
* @deprecated use toBase64 instead.
*
* Return the base-64 representation of the public key
*/
toString() {
return this.toBase64();
toString(): never {
throw new Error(
'`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.',
);
}

/**
Expand Down Expand Up @@ -115,13 +112,6 @@ export abstract class PublicKey {
return suiBytes;
}

/**
* @deprecated use `toRawBytes` instead.
*/
toBytes() {
return this.toRawBytes();
}

/**
* Return the Sui address associated with this Ed25519 public key
*/
Expand Down
7 changes: 2 additions & 5 deletions sdk/typescript/src/cryptography/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export type SerializeSignatureInput = {
signatureScheme: SignatureScheme;
/** Base64-encoded signature */
signature: Uint8Array;
/** @deprecated use publicKey instead */
pubKey?: PublicKey;
/** Base64-encoded public key */
publicKey?: PublicKey;
};
Expand All @@ -41,14 +39,13 @@ export type SerializedSignature = string;
export function toSerializedSignature({
signature,
signatureScheme,
pubKey,
publicKey = pubKey,
publicKey,
}: SerializeSignatureInput): SerializedSignature {
if (!publicKey) {
throw new Error('`publicKey` is required');
}

const pubKeyBytes = publicKey.toBytes();
const pubKeyBytes = publicKey.toRawBytes();
const serializedSignature = new Uint8Array(1 + signature.length + pubKeyBytes.length);
serializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[signatureScheme]]);
serializedSignature.set(signature, 1);
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/src/framework/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Infer } from 'superstruct';
import { nullable, number, object, string } from 'superstruct';

import type { StructTag } from '../bcs/index.js';
import type { CoinStruct } from '../types/coin.js';
import type { CoinStruct } from '../client/types/index.js';
import type {
SuiMoveObject,
SuiObjectData,
Expand Down
3 changes: 1 addition & 2 deletions sdk/typescript/src/framework/sui-system-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { TransactionBlock } from '../builder/index.js';
import type { SuiClient } from '../client/index.js';
import type { JsonRpcProvider } from '../providers/json-rpc-provider.js';
import { getObjectReference } from '../types/index.js';
import { normalizeSuiObjectId } from '../utils/sui-types.js';
import { SUI_SYSTEM_ADDRESS } from './framework.js';
Expand Down Expand Up @@ -31,7 +30,7 @@ export class SuiSystemStateUtil {
* @param gasBudget omittable only for DevInspect mode
*/
public static async newRequestAddStakeTxn(
client: JsonRpcProvider | SuiClient,
client: SuiClient,
coins: string[],
amount: bigint,
validatorAddress: string,
Expand Down
Loading

3 comments on commit 11cf4e6

@vercel
Copy link

@vercel vercel bot commented on 11cf4e6 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 11cf4e6 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 11cf4e6 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mysten-ui – ./apps/ui

mysten-ui-mysten-labs.vercel.app
mysten-ui.vercel.app
mysten-ui-git-main-mysten-labs.vercel.app

Please sign in to comment.