From 0123dba28b0680b361d6adc0f5f3919ee26a6967 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 31 Oct 2024 15:43:11 +0100 Subject: [PATCH] feat(tooling-sdk): Pair TS SDK after rename TransactionEffectsV2 to TransactionEffectsV1 (#3805) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(tooling-sdk): TS SDK remove transactionEffectsV1 and rename transactionEffectsV2 to V1 [WiP] * tmp * wip: no errors * chore: cleanup code * chore: rename remaining v2 effects to v1 in tests * feat(tooling-sdk): Minor formatting fix * feat(tooling-sdk): Fix dapp-kit test * feat(tooling-sdk): Remove unneeded export --------- Co-authored-by: BegoƱa Alvarez --- .../useSignAndExecuteTransaction.test.tsx | 2 +- .../src/mappers/transaction-block.ts | 386 +++++++++--------- sdk/typescript/src/bcs/effects.ts | 25 +- .../src/transactions/ObjectCache.ts | 4 +- .../src/transactions/executor/caching.ts | 2 +- .../src/transactions/executor/parallel.ts | 8 +- .../src/transactions/executor/serial.ts | 8 +- .../test/e2e/parallel-executor.test.ts | 4 +- .../test/e2e/serial-executor.test.ts | 10 +- 9 files changed, 209 insertions(+), 240 deletions(-) diff --git a/sdk/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx b/sdk/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx index 73b348cc3fc..5cf63eb64b7 100644 --- a/sdk/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx +++ b/sdk/dapp-kit/test/hooks/useSignAndExecuteTransaction.test.tsx @@ -164,7 +164,7 @@ describe('useSignAndExecuteTransaction', () => { ]), ); const effectsBcs = bcs.TransactionEffects.serialize({ - V2: { + V1: { status: { Success: true, }, diff --git a/sdk/graphql-transport/src/mappers/transaction-block.ts b/sdk/graphql-transport/src/mappers/transaction-block.ts index 02f82f95c49..f722709dc7e 100644 --- a/sdk/graphql-transport/src/mappers/transaction-block.ts +++ b/sdk/graphql-transport/src/mappers/transaction-block.ts @@ -14,8 +14,10 @@ import type { IotaTransactionBlockResponse, IotaTransactionBlockResponseOptions, } from '@iota/iota-sdk/client'; +import type { IotaObjectRef } from '@iota/iota-sdk/client'; import { normalizeIotaAddress } from '@iota/iota-sdk/utils'; +import type { ObjectOut } from '@iota/iota-sdk/src/bcs/effects.js'; import type { Rpc_Transaction_FieldsFragment } from '../generated/queries.js'; import { toShortTypeString } from './util.js'; @@ -351,250 +353,236 @@ const ADDRESS_ZERO = normalizeIotaAddress('0x0'); export function mapEffects(data: string): IotaTransactionBlockResponse['effects'] { const effects = bcs.TransactionEffects.parse(fromB64(data)); - let effectsV1 = effects.V1; - - if (effects.V2) { - const sharedObjects = effects.V2.unchangedSharedObjects.map(([id, sharedObject]) => { - switch (sharedObject.$kind) { - case 'ReadOnlyRoot': - return { - objectId: id, - version: Number(sharedObject.ReadOnlyRoot[0]) as unknown as string, - digest: sharedObject.ReadOnlyRoot[1], - }; - case 'MutateDeleted': - return { - objectId: id, - version: Number(sharedObject.MutateDeleted) as unknown as string, - digest: OBJECT_DIGEST_DELETED, - }; - case 'ReadDeleted': - return { - objectId: id, - version: Number(sharedObject.ReadDeleted) as unknown as string, - digest: OBJECT_DIGEST_DELETED, - }; - default: - throw new Error(`Unknown shared object type: ${sharedObject}`); - } - }); + type InferedOwner = Exclude<(typeof ObjectOut)['$inferType']['ObjectWrite'], undefined>[1]; - effects.V2.changedObjects - .filter(([_id, change]) => change.inputState.Exist?.[1].Shared) - .forEach(([id, change]) => { - sharedObjects.push({ + const sharedObjects = effects.V1.unchangedSharedObjects.map(([id, sharedObject]) => { + switch (sharedObject.$kind) { + case 'ReadOnlyRoot': + return { objectId: id, - version: Number(change.inputState.Exist![0][0]) as unknown as string, - digest: change.inputState.Exist![0][1], - }); - }); - - const gasObject = - effects.V2.gasObjectIndex != null - ? effects.V2.changedObjects[effects.V2.gasObjectIndex] - : null; - - effectsV1 = { - status: effects.V2.status, - executedEpoch: effects.V2.executedEpoch, - gasUsed: effects.V2.gasUsed, - modifiedAtVersions: effects.V2.changedObjects - .filter(([_id, change]) => change.inputState.Exist) - .map(([id, change]) => [id, change.inputState.Exist![0][0]] as const), - sharedObjects, - transactionDigest: effects.V2.transactionDigest, - created: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.NotExist && - (change.outputState.ObjectWrite || change.outputState.PackageWrite) && - change.idOperation.Created, - ) - .map(([objectId, change]) => - change.outputState.PackageWrite - ? ([ - { - objectId, - version: Number( - change.outputState.PackageWrite[0], - ) as unknown as string, - digest: change.outputState.PackageWrite[1], - }, - { $kind: 'Immutable', Immutable: true }, - ] as const) - : ([ - { - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, - digest: change.outputState.ObjectWrite![0], - }, - change.outputState.ObjectWrite![1], - ] as const), - ), - mutated: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.Exist && - (change.outputState.ObjectWrite || change.outputState.PackageWrite), - ) - .map(([objectId, change]) => [ - change.outputState.PackageWrite - ? { - objectId, - version: Number( - change.outputState.PackageWrite[0], - ) as unknown as string, - digest: change.outputState.PackageWrite[1], - } - : { - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, - digest: change.outputState.ObjectWrite![0], - }, - change.outputState.ObjectWrite - ? change.outputState.ObjectWrite[1] - : { $kind: 'Immutable', Immutable: true }, - ]), - unwrapped: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.NotExist && - change.outputState.ObjectWrite && - change.idOperation.None, - ) - .map(([objectId, change]) => [ - { - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, - digest: change.outputState.ObjectWrite![0], - }, - change.outputState.ObjectWrite![1], - ]), - deleted: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.Exist && - change.outputState.NotExist && - change.idOperation.Deleted, - ) - .map(([objectId, _change]) => ({ - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, + version: Number(sharedObject.ReadOnlyRoot[0]) as unknown as string, + digest: sharedObject.ReadOnlyRoot[1], + }; + case 'MutateDeleted': + return { + objectId: id, + version: Number(sharedObject.MutateDeleted) as unknown as string, digest: OBJECT_DIGEST_DELETED, - })), - unwrappedThenDeleted: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.NotExist && - change.outputState.NotExist && - change.idOperation.Deleted, - ) - .map(([objectId, _change]) => ({ - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, + }; + case 'ReadDeleted': + return { + objectId: id, + version: Number(sharedObject.ReadDeleted) as unknown as string, digest: OBJECT_DIGEST_DELETED, - })), - wrapped: effects.V2.changedObjects - .filter( - ([_id, change]) => - change.inputState.Exist && - change.outputState.NotExist && - change.idOperation.None, - ) - .map(([objectId, _change]) => ({ - objectId, - version: Number(effects.V2.lamportVersion) as unknown as string, - digest: OBJECT_DIGEST_WRAPPED, - })), - gasObject: gasObject - ? [ - { - objectId: gasObject[0], - digest: gasObject[1].outputState.ObjectWrite![0], - version: Number(effects.V2.lamportVersion) as unknown as string, - }, - gasObject[1].outputState.ObjectWrite![1], - ] - : [ + }; + default: + throw new Error(`Unknown shared object type: ${sharedObject}`); + } + }); + + effects.V1.changedObjects + .filter(([_id, change]) => change.inputState.Exist?.[1].Shared) + .forEach(([id, change]) => { + sharedObjects.push({ + objectId: id, + version: Number(change.inputState.Exist![0][0]) as unknown as string, + digest: change.inputState.Exist![0][1], + }); + }); + + const modifiedAtVersions = effects.V1.changedObjects + .filter(([_id, change]) => change.inputState.Exist) + .map(([id, change]) => [id, change.inputState.Exist![0][0]] as const); + + const created = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.NotExist && + (change.outputState.ObjectWrite || change.outputState.PackageWrite) && + change.idOperation.Created, + ) + .map(([objectId, change]) => + change.outputState.PackageWrite + ? ([ { - objectId: ADDRESS_ZERO, - version: '0', - digest: OBJECT_DIGEST_ZERO, + objectId, + version: Number(change.outputState.PackageWrite[0]) as unknown as string, + digest: change.outputState.PackageWrite[1], }, + { $kind: 'Immutable', Immutable: true }, + ] as const) + : ([ { - $kind: 'AddressOwner', - AddressOwner: ADDRESS_ZERO, + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: change.outputState.ObjectWrite![0], }, - ], - eventsDigest: effects.V2.eventsDigest, - dependencies: effects.V2.dependencies, - }; - } + change.outputState.ObjectWrite![1], + ] as const), + ); - if (!effectsV1) { - throw new Error('Invalid effects'); - } + const mutated: Array<[IotaObjectRef, InferedOwner]> = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.Exist && + (change.outputState.ObjectWrite || change.outputState.PackageWrite), + ) + .map(([objectId, change]) => [ + change.outputState.PackageWrite + ? { + objectId, + version: Number(change.outputState.PackageWrite[0]) as unknown as string, + digest: change.outputState.PackageWrite[1], + } + : { + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: change.outputState.ObjectWrite![0], + }, + change.outputState.ObjectWrite + ? change.outputState.ObjectWrite[1] + : { $kind: 'Immutable', Immutable: true }, + ]); + + const unwrapped: Array<[IotaObjectRef, InferedOwner]> = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.NotExist && + change.outputState.ObjectWrite && + change.idOperation.None, + ) + .map(([objectId, change]) => [ + { + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: change.outputState.ObjectWrite![0], + }, + change.outputState.ObjectWrite![1], + ]); + + const deleted = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.Exist && + change.outputState.NotExist && + change.idOperation.Deleted, + ) + .map(([objectId, _change]) => ({ + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: OBJECT_DIGEST_DELETED, + })); + + const unwrappedThenDeleted = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.NotExist && + change.outputState.NotExist && + change.idOperation.Deleted, + ) + .map(([objectId, _change]) => ({ + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: OBJECT_DIGEST_DELETED, + })); + + const wrapped = effects.V1.changedObjects + .filter( + ([_id, change]) => + change.inputState.Exist && change.outputState.NotExist && change.idOperation.None, + ) + .map(([objectId, _change]) => ({ + objectId, + version: Number(effects.V1.lamportVersion) as unknown as string, + digest: OBJECT_DIGEST_WRAPPED, + })); + + const gasObjectFromV1 = + effects.V1.gasObjectIndex != null + ? effects.V1.changedObjects[effects.V1.gasObjectIndex] + : null; + + const gasObject: [IotaObjectRef, InferedOwner] = gasObjectFromV1 + ? [ + { + objectId: gasObjectFromV1[0], + digest: gasObjectFromV1[1].outputState.ObjectWrite![0], + version: Number(effects.V1.lamportVersion) as unknown as string, + }, + gasObjectFromV1[1].outputState.ObjectWrite![1], + ] + : [ + { + objectId: ADDRESS_ZERO, + version: '0', + digest: OBJECT_DIGEST_ZERO, + }, + { + $kind: 'AddressOwner', + AddressOwner: ADDRESS_ZERO, + }, + ]; return { messageVersion: 'v1', - status: effectsV1.status.Success + status: effects.V1.status.Success ? { status: 'success', } : { status: 'failure', // TODO: we don't have the error message from bcs effects - error: effectsV1.status.$kind, + error: effects.V1.status.$kind, }, - executedEpoch: effectsV1.executedEpoch, - gasUsed: effectsV1.gasUsed, - modifiedAtVersions: effectsV1.modifiedAtVersions.map(([objectId, sequenceNumber]) => ({ + executedEpoch: effects.V1.executedEpoch, + gasUsed: effects.V1.gasUsed, + modifiedAtVersions: modifiedAtVersions.map(([objectId, sequenceNumber]) => ({ objectId, sequenceNumber, })), - ...(effectsV1.sharedObjects.length === 0 ? {} : { sharedObjects: effectsV1.sharedObjects }), - transactionDigest: effectsV1.transactionDigest, - ...(effectsV1.created.length === 0 + ...(sharedObjects.length === 0 ? {} : { sharedObjects }), + transactionDigest: effects.V1.transactionDigest, + ...(created.length === 0 ? {} : { - created: effectsV1.created.map(([reference, owner]) => ({ + created: created.map(([reference, owner]) => ({ reference, owner: mapEffectsOwner(owner), })), }), - ...(effectsV1.mutated.length === 0 + ...(mutated.length === 0 ? {} : { - mutated: effectsV1.mutated.map(([reference, owner]) => ({ + mutated: mutated.map(([reference, owner]) => ({ reference, - owner: mapEffectsOwner(owner), + owner: mapEffectsOwner(owner as InferedOwner), })), }), - ...(effectsV1.unwrapped.length === 0 + ...(unwrapped.length === 0 ? {} : { unwrapped: - effectsV1.unwrapped.length === 0 + unwrapped.length === 0 ? undefined - : effectsV1.unwrapped.map(([reference, owner]) => ({ + : unwrapped.map(([reference, owner]) => ({ reference, - owner: mapEffectsOwner(owner), + owner: mapEffectsOwner(owner as InferedOwner), })), }), - ...(effectsV1.deleted.length === 0 ? {} : { deleted: effectsV1.deleted }), - ...(effectsV1.unwrappedThenDeleted.length === 0 + ...(deleted.length === 0 ? {} : { deleted: deleted }), + ...(unwrappedThenDeleted.length === 0 ? {} - : { unwrappedThenDeleted: effectsV1.unwrappedThenDeleted }), - ...(effectsV1.wrapped.length === 0 ? {} : { wrapped: effectsV1.wrapped }), + : { unwrappedThenDeleted: unwrappedThenDeleted }), + ...(wrapped.length === 0 ? {} : { wrapped: wrapped }), gasObject: { - reference: effectsV1.gasObject[0], - owner: mapEffectsOwner(effectsV1.gasObject[1]), + reference: gasObject[0], + owner: mapEffectsOwner(gasObject[1]), }, - ...(effectsV1.eventsDigest ? { eventsDigest: effectsV1.eventsDigest } : {}), - dependencies: effectsV1.dependencies, + ...(effects.V1.eventsDigest ? { eventsDigest: effects.V1.eventsDigest } : {}), + dependencies: effects.V1.dependencies, }; - function mapEffectsOwner(owner: NonNullable['gasObject'][1]) { + function mapEffectsOwner(owner: NonNullable) { if (owner.Immutable) { return 'Immutable'; } else if (owner.Shared) { diff --git a/sdk/typescript/src/bcs/effects.ts b/sdk/typescript/src/bcs/effects.ts index 08cc8d8fe06..bb9f23c37c0 100644 --- a/sdk/typescript/src/bcs/effects.ts +++ b/sdk/typescript/src/bcs/effects.ts @@ -4,7 +4,7 @@ import { bcs } from '@iota/bcs'; -import { Address, ObjectDigest, IotaObjectRef } from './bcs.js'; +import { Address, ObjectDigest } from './bcs.js'; const PackageUpgradeError = bcs.enum('PackageUpgradeError', { UnableToFetchPackage: bcs.struct('UnableToFetchPackage', { packageId: Address }), @@ -132,24 +132,6 @@ const Owner = bcs.enum('Owner', { Immutable: null, }); -const TransactionEffectsV1 = bcs.struct('TransactionEffectsV1', { - status: ExecutionStatus, - executedEpoch: bcs.u64(), - gasUsed: GasCostSummary, - modifiedAtVersions: bcs.vector(bcs.tuple([Address, bcs.u64()])), - sharedObjects: bcs.vector(IotaObjectRef), - transactionDigest: ObjectDigest, - created: bcs.vector(bcs.tuple([IotaObjectRef, Owner])), - mutated: bcs.vector(bcs.tuple([IotaObjectRef, Owner])), - unwrapped: bcs.vector(bcs.tuple([IotaObjectRef, Owner])), - deleted: bcs.vector(IotaObjectRef), - unwrappedThenDeleted: bcs.vector(IotaObjectRef), - wrapped: bcs.vector(IotaObjectRef), - gasObject: bcs.tuple([IotaObjectRef, Owner]), - eventsDigest: bcs.option(ObjectDigest), - dependencies: bcs.vector(ObjectDigest), -}); - const VersionDigest = bcs.tuple([bcs.u64(), ObjectDigest]); const ObjectIn = bcs.enum('ObjectIn', { @@ -157,7 +139,7 @@ const ObjectIn = bcs.enum('ObjectIn', { Exist: bcs.tuple([VersionDigest, Owner]), }); -const ObjectOut = bcs.enum('ObjectOut', { +export const ObjectOut = bcs.enum('ObjectOut', { NotExist: null, ObjectWrite: bcs.tuple([ObjectDigest, Owner]), PackageWrite: VersionDigest, @@ -183,7 +165,7 @@ const UnchangedSharedKind = bcs.enum('UnchangedSharedKind', { PerEpochConfig: null, }); -const TransactionEffectsV2 = bcs.struct('TransactionEffectsV2', { +const TransactionEffectsV1 = bcs.struct('TransactionEffectsV1', { status: ExecutionStatus, executedEpoch: bcs.u64(), gasUsed: GasCostSummary, @@ -199,5 +181,4 @@ const TransactionEffectsV2 = bcs.struct('TransactionEffectsV2', { export const TransactionEffects = bcs.enum('TransactionEffects', { V1: TransactionEffectsV1, - V2: TransactionEffectsV2, }); diff --git a/sdk/typescript/src/transactions/ObjectCache.ts b/sdk/typescript/src/transactions/ObjectCache.ts index 6ce896a5d82..f33455d6304 100644 --- a/sdk/typescript/src/transactions/ObjectCache.ts +++ b/sdk/typescript/src/transactions/ObjectCache.ts @@ -267,11 +267,11 @@ export class ObjectCache { } async applyEffects(effects: typeof bcs.TransactionEffects.$inferType) { - if (!effects.V2) { + if (!effects.V1) { throw new Error(`Unsupported transaction effects version ${effects.$kind}`); } - const { lamportVersion, changedObjects } = effects.V2; + const { lamportVersion, changedObjects } = effects.V1; const deletedIds: string[] = []; const addedObjects: ObjectCacheEntry[] = []; diff --git a/sdk/typescript/src/transactions/executor/caching.ts b/sdk/typescript/src/transactions/executor/caching.ts index 6db0f214b1e..a57c342eabe 100644 --- a/sdk/typescript/src/transactions/executor/caching.ts +++ b/sdk/typescript/src/transactions/executor/caching.ts @@ -99,7 +99,7 @@ export class CachingTransactionExecutor { } async applyEffects(effects: typeof bcs.TransactionEffects.$inferType) { - this.#lastDigest = effects.V2?.transactionDigest ?? null; + this.#lastDigest = effects.V1?.transactionDigest ?? null; await this.cache.applyEffects(effects); } diff --git a/sdk/typescript/src/transactions/executor/parallel.ts b/sdk/typescript/src/transactions/executor/parallel.ts index 1d1e797f48f..36cf8455056 100644 --- a/sdk/typescript/src/transactions/executor/parallel.ts +++ b/sdk/typescript/src/transactions/executor/parallel.ts @@ -228,7 +228,7 @@ export class ParallelTransactionExecutor { const effects = bcs.TransactionEffects.parse(effectsBytes); const gasResult = getGasCoinFromEffects(effects); - const gasUsed = effects.V2?.gasUsed; + const gasUsed = effects.V1?.gasUsed; if (gasCoin && gasUsed && gasResult.owner === this.#signer.toIotaAddress()) { const totalUsed = @@ -428,14 +428,14 @@ export class ParallelTransactionExecutor { }); const effects = bcs.TransactionEffects.parse(Uint8Array.from(result.rawEffects!)); - effects.V2?.changedObjects.forEach(([id, { outputState }], i) => { - if (i === effects.V2?.gasObjectIndex || !outputState.ObjectWrite) { + effects.V1?.changedObjects.forEach(([id, { outputState }], i) => { + if (i === effects.V1?.gasObjectIndex || !outputState.ObjectWrite) { return; } this.#coinPool.push({ id, - version: effects.V2!.lamportVersion, + version: effects.V1!.lamportVersion, digest: outputState.ObjectWrite[0], balance: BigInt(this.#initialCoinBalance), }); diff --git a/sdk/typescript/src/transactions/executor/serial.ts b/sdk/typescript/src/transactions/executor/serial.ts index 8c0d92fef79..c11e6878b4c 100644 --- a/sdk/typescript/src/transactions/executor/serial.ts +++ b/sdk/typescript/src/transactions/executor/serial.ts @@ -41,7 +41,7 @@ export class SerialTransactionExecutor { } #cacheGasCoin = async (effects: typeof bcs.TransactionEffects.$inferType) => { - if (!effects.V2) { + if (!effects.V1) { return; } @@ -117,11 +117,11 @@ export class SerialTransactionExecutor { } export function getGasCoinFromEffects(effects: typeof bcs.TransactionEffects.$inferType) { - if (!effects.V2) { + if (!effects.V1) { throw new Error('Unexpected effects version'); } - const gasObjectChange = effects.V2.changedObjects[effects.V2.gasObjectIndex!]; + const gasObjectChange = effects.V1.changedObjects[effects.V1.gasObjectIndex!]; if (!gasObjectChange) { throw new Error('Gas object not found in effects'); @@ -139,7 +139,7 @@ export function getGasCoinFromEffects(effects: typeof bcs.TransactionEffects.$in ref: { objectId, digest, - version: effects.V2.lamportVersion, + version: effects.V1.lamportVersion, }, owner: owner.AddressOwner || owner.ObjectOwner!, }; diff --git a/sdk/typescript/test/e2e/parallel-executor.test.ts b/sdk/typescript/test/e2e/parallel-executor.test.ts index 391f1819633..35cd2b08626 100644 --- a/sdk/typescript/test/e2e/parallel-executor.test.ts +++ b/sdk/typescript/test/e2e/parallel-executor.test.ts @@ -146,9 +146,9 @@ describe('ParallelTransactionExecutor', { retry: 3 }, () => { const result = await executor.executeTransaction(txb); const effects = bcs.TransactionEffects.fromBase64(result.effects); - const newCoinId = effects.V2?.changedObjects.find( + const newCoinId = effects.V1?.changedObjects.find( ([_id, { outputState }], index) => - index !== effects.V2.gasObjectIndex && outputState.ObjectWrite, + index !== effects.V1.gasObjectIndex && outputState.ObjectWrite, )?.[0]!; return newCoinId; diff --git a/sdk/typescript/test/e2e/serial-executor.test.ts b/sdk/typescript/test/e2e/serial-executor.test.ts index 89c48bd8cdf..ab2ba8b74df 100644 --- a/sdk/typescript/test/e2e/serial-executor.test.ts +++ b/sdk/typescript/test/e2e/serial-executor.test.ts @@ -46,9 +46,9 @@ describe('SerialExecutor', { retry: 3 }, () => { const effects = bcs.TransactionEffects.fromBase64(result.effects); - const newCoinId = effects.V2?.changedObjects.find( + const newCoinId = effects.V1?.changedObjects.find( ([_id, { outputState }], index) => - index !== effects.V2.gasObjectIndex && outputState.ObjectWrite, + index !== effects.V1.gasObjectIndex && outputState.ObjectWrite, )?.[0]!; expect(toolbox.client.getCoins).toHaveBeenCalledTimes(1); @@ -82,9 +82,9 @@ describe('SerialExecutor', { retry: 3 }, () => { await toolbox.client.waitForTransaction({ digest: result.digest }); - const newCoinId = effects.V2?.changedObjects.find( + const newCoinId = effects.V1?.changedObjects.find( ([_id, { outputState }], index) => - index !== effects.V2.gasObjectIndex && outputState.ObjectWrite, + index !== effects.V1.gasObjectIndex && outputState.ObjectWrite, )?.[0]!; expect(toolbox.client.getCoins).toHaveBeenCalledTimes(1); @@ -106,6 +106,6 @@ describe('SerialExecutor', { retry: 3 }, () => { const result2 = await executor.executeTransaction(txb3); expect(result2.digest).not.toEqual(result.digest); - expect(bcs.TransactionEffects.fromBase64(result2.effects).V2?.status.Success).toEqual(true); + expect(bcs.TransactionEffects.fromBase64(result2.effects).V1?.status.Success).toEqual(true); }); });