Skip to content

Commit

Permalink
Transfer becomes TransferCoin in typescript type check (MystenLabs#1923)
Browse files Browse the repository at this point in the history
* Transfer becomes TransferCoin in ts type check

* remove 'Transfer' backwards compat

* shorten getTransferTransaction()

* Update TransactionView.tsx

* Update GitHub Checks to Force Install

* updates tests

* update Transfer tx in mock data

* Revert "updates tests"

This reverts commit ae32d2f.

Co-authored-by: Andrew Burnie <[email protected]>
  • Loading branch information
Stella Cannefax and apburnie authored May 12, 2022
1 parent e80fcd3 commit 9cdbebd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/explorer-client-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: yarn install; yarn build
- name: Install yarn dependencies
working-directory: ./explorer/client
run: yarn install
run: yarn install --force
- name: Lint
working-directory: ./explorer/client
run: yarn lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const initState: TxnState = {
data: {
kind: {
Single: {
Transfer: {
TransferCoin: {
recipient: '',
object_ref: ['', 0, ''],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function formatByTransactionKind(
data: TransactionData
) {
switch (kind) {
case 'Transfer':
case 'TransferCoin':
const transfer = getTransferTransaction(data)!;
return [
{
Expand Down
4 changes: 2 additions & 2 deletions explorer/client/src/utils/static/mock_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@
"data": {
"kind": {
"Single": {
"Transfer": {
"TransferCoin": {
"recipient": "receiverAddress",
"object_ref": [
"7bc832ec31709638cd8d9323e90edf332gff4389",
Expand Down Expand Up @@ -961,7 +961,7 @@
"data": {
"kind": {
"Single": {
"Transfer": {
"TransferCoin": {
"recipient": "receiverAddress",
"object_ref": [
"7bc832ec31709638cd8d9323e90edf332gff4389",
Expand Down
8 changes: 4 additions & 4 deletions sdk/typescript/src/index.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Generated type guards for "index.ts".
* WARNING: Do not manually change this file.
*/
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, ObjectRef, ObjectContentField, ObjectContentFields, ObjectContent, MovePackageContent, SuiObject, ObjectExistsInfo, ObjectNotExistsInfo, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, RawObjectRef, Transfer, RawAuthoritySignInfo, TransactionKindName, SingleTransactionKind, TransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, ExecutionStatusDetail, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveModulePublish, Event, StructTag, MoveTypeTag, MoveCall, MoveCallArg, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, TransactionResponse, SignedTransaction } from "./index";
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, ObjectRef, ObjectContentField, ObjectContentFields, ObjectContent, MovePackageContent, SuiObject, ObjectExistsInfo, ObjectNotExistsInfo, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, RawObjectRef, TransferCoin, RawAuthoritySignInfo, TransactionKindName, SingleTransactionKind, TransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, ExecutionStatusDetail, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveModulePublish, Event, StructTag, MoveTypeTag, MoveCall, MoveCallArg, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, TransactionResponse, SignedTransaction } from "./index";
import { BN } from "bn.js";

export function isEd25519KeypairData(obj: any, _argumentName?: string): obj is Ed25519KeypairData {
Expand Down Expand Up @@ -259,7 +259,7 @@ export function isRawObjectRef(obj: any, _argumentName?: string): obj is RawObje
)
}

export function isTransfer(obj: any, _argumentName?: string): obj is Transfer {
export function isTransferCoin(obj: any, _argumentName?: string): obj is TransferCoin {
return (
(obj !== null &&
typeof obj === "object" ||
Expand All @@ -279,7 +279,7 @@ export function isRawAuthoritySignInfo(obj: any, _argumentName?: string): obj is

export function isTransactionKindName(obj: any, _argumentName?: string): obj is TransactionKindName {
return (
(obj === "Transfer" ||
(obj === "TransferCoin" ||
obj === "Publish" ||
obj === "Call")
)
Expand All @@ -290,7 +290,7 @@ export function isSingleTransactionKind(obj: any, _argumentName?: string): obj i
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransfer(obj.Transfer) as boolean ||
isTransferCoin(obj.TransferCoin) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Expand Down
10 changes: 5 additions & 5 deletions sdk/typescript/src/types/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import { ObjectOwner, SuiAddress, TransactionDigest } from './common';
import { ObjectId, RawObjectRef } from './objects';

export type Transfer = {
export type TransferCoin = {
recipient: string;
object_ref: RawObjectRef;
};
export type RawAuthoritySignInfo = [AuthorityName, AuthoritySignature];

export type TransactionKindName = 'Transfer' | 'Publish' | 'Call';
export type TransactionKindName = 'TransferCoin' | 'Publish' | 'Call';
export type SingleTransactionKind =
| { Transfer: Transfer }
| { TransferCoin: TransferCoin }
| { Publish: MoveModulePublish }
| { Call: MoveCall };
export type TransactionKind =
Expand Down Expand Up @@ -146,9 +146,9 @@ export function getSingleTransactionKind(

export function getTransferTransaction(
data: TransactionData
): Transfer | undefined {
): TransferCoin | undefined {
const tx = getSingleTransactionKind(data);
return tx && 'Transfer' in tx ? tx.Transfer : undefined;
return tx && 'TransferCoin' in tx ? tx.TransferCoin : undefined;
}

export function getPublishTransaction(
Expand Down

0 comments on commit 9cdbebd

Please sign in to comment.