Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/kiosk/src/query/transfer-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { fromBase64, isValidSuiAddress } from '@mysten/sui/utils';
import { fromBase64, isValidSuiAddress, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';

import '../bcs.js';

Expand Down Expand Up @@ -114,7 +114,7 @@ export async function queryOwnedTransferPolicies(
{
MoveModule: {
module: 'transfer_policy',
package: '0x2',
package: SUI_FRAMEWORK_ADDRESS,
},
},
],
Expand Down
4 changes: 3 additions & 1 deletion packages/kiosk/src/types/kiosk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import type { TransactionArgument } from '@mysten/sui/transactions';

import type { ObjectArgument } from './index.js';

import { SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';

/** The Kiosk module. */
export const KIOSK_MODULE = '0x2::kiosk';
export const KIOSK_MODULE = `${SUI_FRAMEWORK_ADDRESS}::kiosk`;

/** The Kiosk type. */
export const KIOSK_TYPE = `${KIOSK_MODULE}::Kiosk`;
Expand Down
4 changes: 3 additions & 1 deletion packages/kiosk/src/types/transfer-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transac
import type { KioskClient } from '../client/kiosk-client.js';
import type { ObjectArgument } from './index.js';

import { SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';

/** The Transfer Policy module. */
export const TRANSFER_POLICY_MODULE = '0x2::transfer_policy';
export const TRANSFER_POLICY_MODULE = `${SUI_FRAMEWORK_ADDRESS}::transfer_policy`;

/** Name of the event emitted when a TransferPolicy for T is created. */
export const TRANSFER_POLICY_CREATED_EVENT = `${TRANSFER_POLICY_MODULE}::TransferPolicyCreated`;
Expand Down
9 changes: 7 additions & 2 deletions packages/sui/src/jsonRpc/json-rpc-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

import { parse } from 'valibot';

import { normalizeSuiAddress, normalizeSuiObjectId, SUI_TYPE_ARG } from '../utils/index.js';
import {
normalizeSuiAddress,
normalizeSuiObjectId,
SUI_FRAMEWORK_ADDRESS,
SUI_TYPE_ARG,
} from '../utils/index.js';
import { ObjectRefSchema } from '../transactions/data/internal.js';
import type { CallArg, Command, OpenMoveTypeSignature } from '../transactions/data/internal.js';
import { Inputs } from '../transactions/Inputs.js';
Expand Down Expand Up @@ -413,7 +418,7 @@ function isReceivingType(type: OpenMoveTypeSignature): boolean {
}

return (
type.body.datatype.package === '0x2' &&
normalizeSuiAddress(type.body.datatype.package) === SUI_FRAMEWORK_ADDRESS &&
type.body.datatype.module === 'transfer' &&
type.body.datatype.type === 'Receiving'
);
Expand Down
19 changes: 13 additions & 6 deletions packages/sui/src/transactions/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

import type { Transaction, TransactionObjectInput } from './Transaction.js';
import { Inputs } from './Inputs.js';
import {
MOVE_STDLIB_ADDRESS,
SUI_CLOCK_OBJECT_ID,
SUI_DENY_LIST_OBJECT_ID,
SUI_RANDOM_OBJECT_ID,
SUI_SYSTEM_STATE_OBJECT_ID,
} from '../utils/index.js';

export function createObjectMethods<T>(makeObject: (value: TransactionObjectInput) => T) {
function object(value: TransactionObjectInput) {
Expand All @@ -15,7 +22,7 @@ export function createObjectMethods<T>(makeObject: (value: TransactionObjectInpu
if (mutable !== undefined) {
return object(
Inputs.SharedObjectRef({
objectId: '0x5',
objectId: SUI_SYSTEM_STATE_OBJECT_ID,
initialSharedVersion: 1,
mutable,
}),
Expand All @@ -25,15 +32,15 @@ export function createObjectMethods<T>(makeObject: (value: TransactionObjectInpu
return object({
$kind: 'UnresolvedObject',
UnresolvedObject: {
objectId: '0x5',
objectId: SUI_SYSTEM_STATE_OBJECT_ID,
initialSharedVersion: 1,
},
});
};
object.clock = () =>
object(
Inputs.SharedObjectRef({
objectId: '0x6',
objectId: SUI_CLOCK_OBJECT_ID,
initialSharedVersion: 1,
mutable: false,
}),
Expand All @@ -42,15 +49,15 @@ export function createObjectMethods<T>(makeObject: (value: TransactionObjectInpu
object({
$kind: 'UnresolvedObject',
UnresolvedObject: {
objectId: '0x8',
objectId: SUI_RANDOM_OBJECT_ID,
mutable: false,
},
});
object.denyList = (options?: { mutable?: boolean }) => {
return object({
$kind: 'UnresolvedObject',
UnresolvedObject: {
objectId: '0x403',
objectId: SUI_DENY_LIST_OBJECT_ID,
mutable: options?.mutable,
},
});
Expand All @@ -60,7 +67,7 @@ export function createObjectMethods<T>(makeObject: (value: TransactionObjectInpu
(tx: Transaction) =>
tx.moveCall({
typeArguments: [type],
target: `0x1::option::${value === null ? 'none' : 'some'}`,
target: `${MOVE_STDLIB_ADDRESS}::option::${value === null ? 'none' : 'some'}`,
arguments: value === null ? [] : [tx.object(value)],
});

Expand Down
6 changes: 3 additions & 3 deletions packages/sui/src/transactions/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function isTxContext(param: OpenMoveTypeSignature): boolean {

return (
!!struct &&
normalizeSuiAddress(struct.package) === normalizeSuiAddress('0x2') &&
normalizeSuiAddress(struct.package) === SUI_FRAMEWORK_ADDRESS &&
struct.module === 'tx_context' &&
struct.type === 'TxContext'
);
Expand Down Expand Up @@ -72,7 +72,7 @@ export function getPureBcsSchema(typeSignature: OpenMoveTypeSignatureBody): BcsT
if ('datatype' in typeSignature) {
const pkg = normalizeSuiAddress(typeSignature.datatype.package);

if (pkg === normalizeSuiAddress(MOVE_STDLIB_ADDRESS)) {
if (pkg === MOVE_STDLIB_ADDRESS) {
if (
typeSignature.datatype.module === STD_ASCII_MODULE_NAME &&
typeSignature.datatype.type === STD_ASCII_STRUCT_NAME
Expand All @@ -97,7 +97,7 @@ export function getPureBcsSchema(typeSignature: OpenMoveTypeSignatureBody): BcsT
}

if (
pkg === normalizeSuiAddress(SUI_FRAMEWORK_ADDRESS) &&
pkg === SUI_FRAMEWORK_ADDRESS &&
typeSignature.datatype.module === OBJECT_MODULE_NAME &&
typeSignature.datatype.type === ID_STRUCT_NAME
) {
Expand Down
22 changes: 14 additions & 8 deletions packages/sui/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { normalizeSuiObjectId } from './sui-types.js';

export const SUI_DECIMALS = 9;
export const MIST_PER_SUI = BigInt(1000000000);

export const MOVE_STDLIB_ADDRESS = '0x1';
export const SUI_FRAMEWORK_ADDRESS = '0x2';
export const SUI_SYSTEM_ADDRESS = '0x3';
export const SUI_CLOCK_OBJECT_ID = normalizeSuiObjectId('0x6');
export const MOVE_STDLIB_ADDRESS =
'0x0000000000000000000000000000000000000000000000000000000000000001';
export const SUI_FRAMEWORK_ADDRESS =
'0x0000000000000000000000000000000000000000000000000000000000000002';
export const SUI_SYSTEM_ADDRESS =
'0x0000000000000000000000000000000000000000000000000000000000000003';
export const SUI_CLOCK_OBJECT_ID =
'0x0000000000000000000000000000000000000000000000000000000000000006';
export const SUI_SYSTEM_MODULE_NAME = 'sui_system';
export const SUI_TYPE_ARG = `${SUI_FRAMEWORK_ADDRESS}::sui::SUI`;
export const SUI_SYSTEM_STATE_OBJECT_ID: string = normalizeSuiObjectId('0x5');
export const SUI_RANDOM_OBJECT_ID = normalizeSuiObjectId('0x8');
export const SUI_SYSTEM_STATE_OBJECT_ID =
'0x0000000000000000000000000000000000000000000000000000000000000005';
export const SUI_RANDOM_OBJECT_ID =
'0x0000000000000000000000000000000000000000000000000000000000000008';
export const SUI_DENY_LIST_OBJECT_ID =
'0x0000000000000000000000000000000000000000000000000000000000000403';
1 change: 1 addition & 0 deletions packages/sui/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
SUI_TYPE_ARG,
SUI_SYSTEM_STATE_OBJECT_ID,
SUI_RANDOM_OBJECT_ID,
SUI_DENY_LIST_OBJECT_ID,
} from './constants.js';

export { isValidNamedPackage, isValidNamedType } from './move-registry.js';
Expand Down
Loading