Skip to content

Commit 890c78e

Browse files
authored
Mh less publishing (#739)
less package publishing in tests
1 parent ff1158f commit 890c78e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1013
-722
lines changed

packages/kiosk/test/e2e/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class TestToolbox {
4444

4545
export function getClient(): SuiJsonRpcClient {
4646
return new SuiJsonRpcClient({
47+
network: 'localnet',
4748
url: DEFAULT_FULLNODE_URL,
4849
});
4950
}

packages/sui/src/client/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ export namespace SuiClientTypes {
230230
balanceChanges: Include extends { balanceChanges: true } ? BalanceChange[] : undefined;
231231
effects: Include extends { effects: true } ? TransactionEffects : undefined;
232232
events: Include extends { events: true } ? Event[] : undefined;
233-
objectTypes: Include extends { objectTypes: true }
234-
? PromiseLike<Record<string, string>>
235-
: undefined;
233+
objectTypes: Include extends { objectTypes: true } ? Record<string, string> : undefined;
236234
transaction: Include extends { transaction: true } ? TransactionData : undefined;
237235
}
238236

packages/sui/src/graphql/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
632632
: undefined) as SuiClientTypes.Transaction<Include>['effects'],
633633
epoch: transaction.effects?.epoch?.epochId?.toString() ?? null,
634634
objectTypes: (include?.objectTypes
635-
? Promise.resolve(objectTypes)
635+
? objectTypes
636636
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
637637
transaction: (include?.transaction
638638
? parseTransactionBcs(fromBase64(transaction.transactionBcs!))

packages/sui/src/grpc/core.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ export class GrpcCoreClient extends CoreClient {
234234
paths.push('events');
235235
}
236236
if (options.include?.objectTypes) {
237-
paths.push('objects');
237+
paths.push('effects.changed_objects.object_type');
238+
paths.push('effects.changed_objects.object_id');
238239
}
239240

240241
const { response } = await this.#client.ledgerService.getTransaction({
@@ -267,7 +268,8 @@ export class GrpcCoreClient extends CoreClient {
267268
paths.push('events');
268269
}
269270
if (options.include?.objectTypes) {
270-
paths.push('objects');
271+
paths.push('effects.changed_objects.object_type');
272+
paths.push('effects.changed_objects.object_id');
271273
}
272274

273275
const { response } = await this.#client.transactionExecutionService.executeTransaction({
@@ -313,7 +315,9 @@ export class GrpcCoreClient extends CoreClient {
313315
paths.push('transaction.events');
314316
}
315317
if (options.include?.objectTypes) {
316-
paths.push('transaction.objects');
318+
// Use effects.changed_objects to match JSON-RPC behavior (which uses objectChanges)
319+
paths.push('transaction.effects.changed_objects.object_type');
320+
paths.push('transaction.effects.changed_objects.object_id');
317321
}
318322
if (options.include?.commandResults) {
319323
paths.push('command_outputs');
@@ -764,9 +768,9 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
764768
): SuiClientTypes.TransactionResult<Include> {
765769
const objectTypes: Record<string, string> = {};
766770
if (include?.objectTypes) {
767-
transaction.objects?.objects.forEach((object) => {
768-
if (object.objectId && object.objectType) {
769-
objectTypes[object.objectId] = object.objectType;
771+
transaction.effects?.changedObjects?.forEach((change) => {
772+
if (change.objectId && change.objectType) {
773+
objectTypes[change.objectId] = change.objectType;
770774
}
771775
});
772776
}
@@ -820,7 +824,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
820824
status,
821825
effects: effects as SuiClientTypes.Transaction<Include>['effects'],
822826
objectTypes: (include?.objectTypes
823-
? Promise.resolve(objectTypes)
827+
? objectTypes
824828
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
825829
transaction: transactionData as SuiClientTypes.Transaction<Include>['transaction'],
826830
signatures: transaction.signatures?.map((sig) => toBase64(sig.bcs?.value!)) ?? [],

packages/sui/src/jsonRpc/core.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class JSONRpcCoreClient extends CoreClient {
257257
? effects
258258
: undefined) as SuiClientTypes.Transaction<Include>['effects'],
259259
objectTypes: (options.include?.objectTypes
260-
? Promise.resolve(objectTypes)
260+
? objectTypes
261261
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
262262
signatures: [],
263263
transaction: (options.include?.transaction
@@ -625,7 +625,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
625625
if (include?.objectTypes) {
626626
transaction.objectChanges?.forEach((change) => {
627627
if (change.type !== 'published') {
628-
objectTypes[change.objectId] = change.objectType;
628+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
629629
}
630630
});
631631
}
@@ -670,7 +670,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
670670
? parseTransactionEffectsBcs(effectsBytes)
671671
: undefined) as SuiClientTypes.Transaction<Include>['effects'],
672672
objectTypes: (include?.objectTypes
673-
? Promise.resolve(objectTypes)
673+
? objectTypes
674674
: undefined) as SuiClientTypes.Transaction<Include>['objectTypes'],
675675
transaction: transactionData as SuiClientTypes.Transaction<Include>['transaction'],
676676
signatures,
@@ -751,7 +751,7 @@ function parseTransactionEffectsJson({
751751
outputOwner: parseOwner(change.recipient),
752752
idOperation: 'None',
753753
});
754-
objectTypes[change.objectId] = change.objectType;
754+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
755755
break;
756756
case 'mutated':
757757
changedObjects.push({
@@ -766,7 +766,7 @@ function parseTransactionEffectsJson({
766766
outputOwner: parseOwner(change.owner),
767767
idOperation: 'None',
768768
});
769-
objectTypes[change.objectId] = change.objectType;
769+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
770770
break;
771771
case 'deleted':
772772
changedObjects.push({
@@ -781,7 +781,7 @@ function parseTransactionEffectsJson({
781781
outputOwner: null,
782782
idOperation: 'Deleted',
783783
});
784-
objectTypes[change.objectId] = change.objectType;
784+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
785785
break;
786786
case 'wrapped':
787787
changedObjects.push({
@@ -803,7 +803,7 @@ function parseTransactionEffectsJson({
803803
},
804804
idOperation: 'None',
805805
});
806-
objectTypes[change.objectId] = change.objectType;
806+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
807807
break;
808808
case 'created':
809809
changedObjects.push({
@@ -818,7 +818,7 @@ function parseTransactionEffectsJson({
818818
outputOwner: parseOwner(change.owner),
819819
idOperation: 'Created',
820820
});
821-
objectTypes[change.objectId] = change.objectType;
821+
objectTypes[change.objectId] = normalizeStructTag(change.objectType);
822822
break;
823823
}
824824
});

packages/sui/test/e2e/clients/core/coins.test.ts

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,30 @@ describe('Core API - Coins', () => {
1919
testAddress = toolbox.address();
2020

2121
// Get the package ID for custom coin tests
22-
testPackageId = await toolbox.getPackage('core_test');
22+
testPackageId = await toolbox.getPackage('test_data');
2323

24-
// Mint custom coins before tests run
25-
if (!testAddress) {
26-
throw new Error('testAddress is undefined');
24+
// Mint custom TEST_COIN coins using the shared TreasuryCap
25+
const treasuryCapId = toolbox.getSharedObject('test_data', 'TreasuryCap<TEST_COIN>');
26+
if (!treasuryCapId) {
27+
throw new Error('TreasuryCap<TEST_COIN> not found in pre-published package');
2728
}
2829

29-
const ownedObjects = await toolbox.jsonRpcClient.core.listOwnedObjects({
30-
owner: testAddress,
30+
const tx = new Transaction();
31+
const [coin] = tx.moveCall({
32+
target: `${testPackageId}::test_coin::mint`,
33+
arguments: [tx.object(treasuryCapId), tx.pure.u64(1000000)],
34+
});
35+
tx.transferObjects([coin], tx.pure.address(testAddress));
36+
37+
const result = await toolbox.jsonRpcClient.signAndExecuteTransaction({
38+
transaction: tx,
39+
signer: toolbox.keypair,
40+
options: {
41+
showEffects: true,
42+
},
3143
});
3244

33-
const treasuryCap = ownedObjects.objects.find(
34-
(obj) =>
35-
obj.type && obj.type.includes('TreasuryCap') && obj.type.includes('test_coin::TEST_COIN'),
36-
);
37-
38-
if (treasuryCap) {
39-
const tx = new Transaction();
40-
const [coin] = tx.moveCall({
41-
target: `${testPackageId}::test_coin::mint`,
42-
arguments: [tx.object(treasuryCap.objectId), tx.pure.u64(1000000)],
43-
});
44-
tx.transferObjects([coin], tx.pure.address(testAddress));
45-
46-
const result = await toolbox.jsonRpcClient.signAndExecuteTransaction({
47-
transaction: tx,
48-
signer: toolbox.keypair,
49-
options: {
50-
showEffects: true,
51-
},
52-
});
53-
54-
await toolbox.jsonRpcClient.waitForTransaction({ digest: result.digest });
55-
}
45+
await toolbox.jsonRpcClient.waitForTransaction({ digest: result.digest });
5646
});
5747

5848
describe('getCoins', () => {

packages/sui/test/e2e/clients/core/dynamic-fields.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Core API - Dynamic Fields', () => {
1717
beforeAll(async () => {
1818
toolbox = await setup();
1919
testAddress = toolbox.address();
20-
testPackageId = await toolbox.getPackage('core_test');
20+
testPackageId = await toolbox.getPackage('test_data');
2121

2222
// Create an object with dynamic fields
2323
const tx = new Transaction();

packages/sui/test/e2e/clients/core/move-functions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('Core API - Move Functions', () => {
1414
beforeAll(async () => {
1515
toolbox = await setup();
1616
// Use entry_point_types package which has well-defined functions
17-
testPackageId = await toolbox.getPackage('entry_point_types');
17+
testPackageId = await toolbox.getPackage('test_data');
1818
});
1919

2020
describe('getMoveFunction', () => {

packages/sui/test/e2e/clients/core/move-packages.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Core API - Move Packages', () => {
1313

1414
beforeAll(async () => {
1515
toolbox = await setup();
16-
packageId = await toolbox.getPackage('core_test');
16+
packageId = await toolbox.getPackage('test_data');
1717
});
1818

1919
describe('getMoveFunction', () => {

packages/sui/test/e2e/clients/core/objects.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ describe('Core API - Objects', () => {
2626
testAddress = toolbox.address();
2727

2828
// Publish test package
29-
testPackageId = await toolbox.getPackage('core_test');
29+
testPackageId = await toolbox.getPackage('test_data');
3030

31-
// Create a test object
31+
// Create multiple test objects to ensure pagination tests work
3232
const tx = new Transaction();
33-
const [obj] = tx.moveCall({
34-
target: `${testPackageId}::test_objects::create_simple_object`,
35-
arguments: [tx.pure.u64(42)],
36-
});
37-
tx.transferObjects([obj], tx.pure.address(testAddress));
33+
for (let i = 0; i < 5; i++) {
34+
const [obj] = tx.moveCall({
35+
target: `${testPackageId}::test_objects::create_simple_object`,
36+
arguments: [tx.pure.u64(42)],
37+
});
38+
tx.transferObjects([obj], tx.pure.address(testAddress));
39+
}
3840

3941
const result = await toolbox.jsonRpcClient.signAndExecuteTransaction({
4042
transaction: tx,
@@ -50,7 +52,7 @@ describe('Core API - Objects', () => {
5052
digest: result.digest,
5153
});
5254

53-
// Get the created object ID
55+
// Get the first created object ID for individual object tests
5456
const createdObject = result.objectChanges?.find(
5557
(change) => change.type === 'created' && change.objectType.includes('SimpleObject'),
5658
);

0 commit comments

Comments
 (0)