From cbfde8b5303aebf242ce1673c5ab919175cbc8ea Mon Sep 17 00:00:00 2001 From: Gabriel Matei Date: Mon, 16 Feb 2026 11:32:10 +0200 Subject: [PATCH 1/3] feat: Introduce SUINS auction marketplace contract and transaction functionality, updating constants, codegen, and types. --- packages/suins/src/constants.ts | 13 + .../src/contracts/suins_auction/address.ts | 24 + .../src/contracts/suins_auction/ascii.ts | 451 ++++++ .../src/contracts/suins_auction/auction.ts | 518 +++++++ .../suins/src/contracts/suins_auction/bcs.ts | 40 + .../src/contracts/suins_auction/bit_vector.ts | 193 +++ .../src/contracts/suins_auction/constants.ts | 102 ++ .../src/contracts/suins_auction/debug.ts | 43 + .../src/contracts/suins_auction/decryption.ts | 30 + .../suins_auction/deps/bridge/bridge.ts | 323 ++++ .../suins_auction/deps/bridge/chain_ids.ts | 210 +++ .../suins_auction/deps/bridge/committee.ts | 100 ++ .../suins_auction/deps/bridge/limiter.ts | 59 + .../suins_auction/deps/bridge/message.ts | 974 ++++++++++++ .../deps/bridge/message_types.ts | 82 + .../suins_auction/deps/bridge/treasury.ts | 130 ++ .../deps/seal/bf_hmac_encryption.ts | 400 +++++ .../suins_auction/deps/seal/key_server.ts | 217 +++ .../suins_auction/deps/seal/polynomial.ts | 40 + .../suins_auction/deps/sui/accumulator.ts | 24 + .../deps/sui/accumulator_metadata.ts | 32 + .../deps/sui/accumulator_settlement.ts | 17 + .../suins_auction/deps/sui/address.ts | 189 +++ .../deps/sui/authenticator_state.ts | 45 + .../contracts/suins_auction/deps/sui/bag.ts | 310 ++++ .../suins_auction/deps/sui/balance.ts | 306 ++++ .../contracts/suins_auction/deps/sui/bcs.ts | 683 +++++++++ .../suins_auction/deps/sui/bls12381.ts | 929 ++++++++++++ .../suins_auction/deps/sui/borrow.ts | 133 ++ .../contracts/suins_auction/deps/sui/clock.ts | 46 + .../contracts/suins_auction/deps/sui/coin.ts | 1348 +++++++++++++++++ .../suins_auction/deps/sui/coin_registry.ts | 1236 +++++++++++++++ .../suins_auction/deps/sui/config.ts | 30 + .../suins_auction/deps/sui/deny_list.ts | 67 + .../suins_auction/deps/sui/derived_object.ts | 140 ++ .../suins_auction/deps/sui/display.ts | 349 +++++ .../suins_auction/deps/sui/dynamic_field.ts | 273 ++++ .../deps/sui/dynamic_object_field.ts | 261 ++++ .../suins_auction/deps/sui/ecdsa_k1.ts | 115 ++ .../suins_auction/deps/sui/ecdsa_r1.ts | 91 ++ .../contracts/suins_auction/deps/sui/ecvrf.ts | 46 + .../suins_auction/deps/sui/ed25519.ts | 40 + .../contracts/suins_auction/deps/sui/event.ts | 94 ++ .../deps/sui/funds_accumulator.ts | 130 ++ .../suins_auction/deps/sui/groth16.ts | 244 +++ .../suins_auction/deps/sui/group_ops.ts | 65 + .../contracts/suins_auction/deps/sui/hash.ts | 57 + .../contracts/suins_auction/deps/sui/hex.ts | 55 + .../contracts/suins_auction/deps/sui/hmac.ts | 31 + .../contracts/suins_auction/deps/sui/kiosk.ts | 1222 +++++++++++++++ .../suins_auction/deps/sui/kiosk_extension.ts | 467 ++++++ .../suins_auction/deps/sui/linked_table.ts | 512 +++++++ .../contracts/suins_auction/deps/sui/math.ts | 166 ++ .../deps/sui/nitro_attestation.ts | 247 +++ .../suins_auction/deps/sui/object.ts | 317 ++++ .../suins_auction/deps/sui/object_bag.ts | 321 ++++ .../suins_auction/deps/sui/object_table.ts | 297 ++++ .../suins_auction/deps/sui/package.ts | 572 +++++++ .../contracts/suins_auction/deps/sui/party.ts | 52 + .../contracts/suins_auction/deps/sui/pay.ts | 228 +++ .../suins_auction/deps/sui/poseidon.ts | 47 + .../suins_auction/deps/sui/priority_queue.ts | 185 +++ .../suins_auction/deps/sui/random.ts | 392 +++++ .../contracts/suins_auction/deps/sui/sui.ts | 45 + .../contracts/suins_auction/deps/sui/table.ts | 304 ++++ .../suins_auction/deps/sui/table_vec.ts | 316 ++++ .../contracts/suins_auction/deps/sui/token.ts | 1302 ++++++++++++++++ .../suins_auction/deps/sui/transfer.ts | 358 +++++ .../suins_auction/deps/sui/transfer_policy.ts | 602 ++++++++ .../suins_auction/deps/sui/tx_context.ts | 150 ++ .../contracts/suins_auction/deps/sui/types.ts | 34 + .../contracts/suins_auction/deps/sui/url.ts | 106 ++ .../contracts/suins_auction/deps/sui/vdf.ts | 79 + .../suins_auction/deps/sui/vec_map.ts | 568 +++++++ .../suins_auction/deps/sui/vec_set.ts | 281 ++++ .../suins_auction/deps/sui/versioned.ts | 205 +++ .../deps/sui/zklogin_verified_id.ts | 234 +++ .../deps/sui/zklogin_verified_issuer.ts | 145 ++ .../suins_auction/deps/sui_system/genesis.ts | 64 + .../deps/sui_system/stake_subsidy.ts | 56 + .../deps/sui_system/staking_pool.ts | 521 +++++++ .../deps/sui_system/storage_fund.ts | 56 + .../deps/sui_system/sui_system.ts | 1204 +++++++++++++++ .../deps/sui_system/sui_system_state_inner.ts | 212 +++ .../deps/sui_system/validator.ts | 870 +++++++++++ .../deps/sui_system/validator_cap.ts | 19 + .../deps/sui_system/validator_set.ts | 426 ++++++ .../deps/sui_system/validator_wrapper.ts | 12 + .../deps/sui_system/voting_power.ts | 50 + .../suins_auction/deps/suins/admin.ts | 118 ++ .../suins_auction/deps/suins/auction.ts | 345 +++++ .../suins_auction/deps/suins/config.ts | 229 +++ .../suins_auction/deps/suins/constants.ts | 167 ++ .../suins_auction/deps/suins/controller.ts | 269 ++++ .../suins_auction/deps/suins/core_config.ts | 212 +++ .../suins_auction/deps/suins/domain.ts | 234 +++ .../suins_auction/deps/suins/name_record.ts | 319 ++++ .../suins_auction/deps/suins/payment.ts | 444 ++++++ .../deps/suins/pricing_config.ts | 190 +++ .../suins_auction/deps/suins/registry.ts | 518 +++++++ .../deps/suins/subdomain_registration.ts | 67 + .../suins_auction/deps/suins/suins.ts | 460 ++++++ .../deps/suins/suins_registration.ts | 204 +++ .../suins_auction/deps/suins/update_image.ts | 15 + .../contracts/suins_auction/fixed_point32.ts | 171 +++ .../suins/src/contracts/suins_auction/hash.ts | 51 + .../src/contracts/suins_auction/internal.ts | 59 + .../src/contracts/suins_auction/offer.ts | 423 ++++++ .../src/contracts/suins_auction/option.ts | 494 ++++++ .../src/contracts/suins_auction/string.ts | 367 +++++ .../src/contracts/suins_auction/type_name.ts | 298 ++++ .../suins/src/contracts/suins_auction/u128.ts | 290 ++++ .../suins/src/contracts/suins_auction/u16.ts | 224 +++ .../suins/src/contracts/suins_auction/u256.ts | 262 ++++ .../suins/src/contracts/suins_auction/u32.ts | 244 +++ .../suins/src/contracts/suins_auction/u64.ts | 270 ++++ .../suins/src/contracts/suins_auction/u8.ts | 204 +++ .../src/contracts/suins_auction/uq32_32.ts | 369 +++++ .../src/contracts/suins_auction/uq64_64.ts | 369 +++++ .../src/contracts/suins_auction/vector.ts | 548 +++++++ packages/suins/src/index.ts | 28 +- .../suins/src/suins-marketplace-client.ts | 362 +++++ .../src/suins-marketplace-transaction.ts | 466 ++++++ packages/suins/src/types.ts | 157 ++ packages/suins/sui-codegen.config.ts | 2 + 125 files changed, 34027 insertions(+), 1 deletion(-) create mode 100644 packages/suins/src/contracts/suins_auction/address.ts create mode 100644 packages/suins/src/contracts/suins_auction/ascii.ts create mode 100644 packages/suins/src/contracts/suins_auction/auction.ts create mode 100644 packages/suins/src/contracts/suins_auction/bcs.ts create mode 100644 packages/suins/src/contracts/suins_auction/bit_vector.ts create mode 100644 packages/suins/src/contracts/suins_auction/constants.ts create mode 100644 packages/suins/src/contracts/suins_auction/debug.ts create mode 100644 packages/suins/src/contracts/suins_auction/decryption.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/message.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/address.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/bag.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/balance.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/clock.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/coin.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/config.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/display.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/event.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hash.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hex.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/math.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/object.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/package.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/party.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/pay.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/random.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/sui.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/table.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/token.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/types.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/url.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/admin.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/auction.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/config.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/constants.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/controller.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/domain.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/payment.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/registry.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/suins.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts create mode 100644 packages/suins/src/contracts/suins_auction/fixed_point32.ts create mode 100644 packages/suins/src/contracts/suins_auction/hash.ts create mode 100644 packages/suins/src/contracts/suins_auction/internal.ts create mode 100644 packages/suins/src/contracts/suins_auction/offer.ts create mode 100644 packages/suins/src/contracts/suins_auction/option.ts create mode 100644 packages/suins/src/contracts/suins_auction/string.ts create mode 100644 packages/suins/src/contracts/suins_auction/type_name.ts create mode 100644 packages/suins/src/contracts/suins_auction/u128.ts create mode 100644 packages/suins/src/contracts/suins_auction/u16.ts create mode 100644 packages/suins/src/contracts/suins_auction/u256.ts create mode 100644 packages/suins/src/contracts/suins_auction/u32.ts create mode 100644 packages/suins/src/contracts/suins_auction/u64.ts create mode 100644 packages/suins/src/contracts/suins_auction/u8.ts create mode 100644 packages/suins/src/contracts/suins_auction/uq32_32.ts create mode 100644 packages/suins/src/contracts/suins_auction/uq64_64.ts create mode 100644 packages/suins/src/contracts/suins_auction/vector.ts create mode 100644 packages/suins/src/suins-marketplace-client.ts create mode 100644 packages/suins/src/suins-marketplace-transaction.ts diff --git a/packages/suins/src/constants.ts b/packages/suins/src/constants.ts index 925e408d0..e660f4afe 100644 --- a/packages/suins/src/constants.ts +++ b/packages/suins/src/constants.ts @@ -56,6 +56,13 @@ export const mainPackage: Config = { }, }, registryTableId: '0xe64cd9db9f829c6cc405d9790bd71567ae07259855f4fba6f02c84f52298c106', + // TODO: Add marketplace constants once the contracts are deployed on mainnet + // marketplace: { + // packageId: '', + // originalPackageId: '', + // auctionTableId: '', + // offerTableId: '', + // }, }, testnet: { packageId: '0x40eee27b014a872f5c3330dcd5329aa55c7fe0fcc6e70c6498852e2e3727172e', @@ -102,5 +109,11 @@ export const mainPackage: Config = { }, }, registryTableId: '0xb120c0d55432630fce61f7854795a3463deb6e3b443cc4ae72e1282073ff56e4', + marketplace: { + packageId: '0xbd2b57cddef6674d5a4dfd14518583ea9bb194ec47207a8c1dcf00740babc2eb', + originalPackageId: '0xd421a8ebd93c4f93a4020e733b98108db3498be90a0d62ffed1ef926434aa569', + auctionTableId: '0x60ecc91870bd1d9c7b5ff74a05479aa53713096949c45aa830ef6f4d9cb6936b', + offerTableId: '0x1e848feb692bff38afc2d66c0757cd10cf062e2564697e6d4a1d8a1604304343', + }, }, }; diff --git a/packages/suins/src/contracts/suins_auction/address.ts b/packages/suins/src/contracts/suins_auction/address.ts new file mode 100644 index 000000000..9f52be541 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/address.ts @@ -0,0 +1,24 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Provides a way to get address length since it's a platform-specific parameter. */ + +import { type Transaction } from '@mysten/sui/transactions'; +export interface LengthOptions { + package?: string; + arguments?: []; +} +/** + * Should be converted to a native function. Current implementation only works for + * Sui. + */ +export function length(options: LengthOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'length', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/ascii.ts b/packages/suins/src/contracts/suins_auction/ascii.ts new file mode 100644 index 000000000..a0e867e1c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/ascii.ts @@ -0,0 +1,451 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * The `ASCII` module defines basic string and char newtypes in Move that verify + * that characters are valid ASCII, and that strings consist of only valid ASCII + * characters. + */ + +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::ascii'; +export const String = new MoveStruct({ + name: `${$moduleName}::String`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export const Char = new MoveStruct({ + name: `${$moduleName}::Char`, + fields: { + byte: bcs.u8(), + }, +}); +export interface CharArguments { + byte: RawTransactionArgument; +} +export interface CharOptions { + package?: string; + arguments: CharArguments | [byte: RawTransactionArgument]; +} +/** Convert a `byte` into a `Char` that is checked to make sure it is valid ASCII. */ +export function char(options: CharOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['byte']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'char', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StringArguments { + bytes: RawTransactionArgument; +} +export interface StringOptions { + package?: string; + arguments: StringArguments | [bytes: RawTransactionArgument]; +} +/** + * Convert a vector of bytes `bytes` into an `String`. Aborts if `bytes` contains + * non-ASCII characters. + */ +export function string(options: StringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryStringArguments { + bytes: RawTransactionArgument; +} +export interface TryStringOptions { + package?: string; + arguments: TryStringArguments | [bytes: RawTransactionArgument]; +} +/** + * Convert a vector of bytes `bytes` into an `String`. Returns + * `Some()` if the `bytes` contains all valid ASCII characters. + * Otherwise returns `None`. + */ +export function tryString(options: TryStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'try_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AllCharactersPrintableArguments { + string: RawTransactionArgument; +} +export interface AllCharactersPrintableOptions { + package?: string; + arguments: AllCharactersPrintableArguments | [string: RawTransactionArgument]; +} +/** + * Returns `true` if all characters in `string` are printable characters Returns + * `false` otherwise. Not all `String`s are printable strings. + */ +export function allCharactersPrintable(options: AllCharactersPrintableOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'all_characters_printable', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PushCharArguments { + string: RawTransactionArgument; + char: RawTransactionArgument; +} +export interface PushCharOptions { + package?: string; + arguments: + | PushCharArguments + | [string: RawTransactionArgument, char: RawTransactionArgument]; +} +/** Push a `Char` to the end of the `string`. */ +export function pushChar(options: PushCharOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', null] satisfies (string | null)[]; + const parameterNames = ['string', 'char']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'push_char', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PopCharArguments { + string: RawTransactionArgument; +} +export interface PopCharOptions { + package?: string; + arguments: PopCharArguments | [string: RawTransactionArgument]; +} +/** Pop a `Char` from the end of the `string`. */ +export function popChar(options: PopCharOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'pop_char', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LengthArguments { + string: RawTransactionArgument; +} +export interface LengthOptions { + package?: string; + arguments: LengthArguments | [string: RawTransactionArgument]; +} +/** Returns the length of the `string` in bytes. */ +export function length(options: LengthOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AppendArguments { + string: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface AppendOptions { + package?: string; + arguments: + | AppendArguments + | [string: RawTransactionArgument, other: RawTransactionArgument]; +} +/** Append the `other` string to the end of `string`. */ +export function append(options: AppendOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'append', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface InsertArguments { + s: RawTransactionArgument; + at: RawTransactionArgument; + o: RawTransactionArgument; +} +export interface InsertOptions { + package?: string; + arguments: + | InsertArguments + | [ + s: RawTransactionArgument, + at: RawTransactionArgument, + o: RawTransactionArgument, + ]; +} +/** Insert the `other` string at the `at` index of `string`. */ +export function insert(options: InsertOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'u64', '0x1::string::String'] satisfies ( + | string + | null + )[]; + const parameterNames = ['s', 'at', 'o']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SubstringArguments { + string: RawTransactionArgument; + i: RawTransactionArgument; + j: RawTransactionArgument; +} +export interface SubstringOptions { + package?: string; + arguments: + | SubstringArguments + | [ + string: RawTransactionArgument, + i: RawTransactionArgument, + j: RawTransactionArgument, + ]; +} +/** Copy the slice of the `string` from `i` to `j` into a new `String`. */ +export function substring(options: SubstringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['string', 'i', 'j']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'substring', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AsBytesArguments { + string: RawTransactionArgument; +} +export interface AsBytesOptions { + package?: string; + arguments: AsBytesArguments | [string: RawTransactionArgument]; +} +/** Get the inner bytes of the `string` as a reference */ +export function asBytes(options: AsBytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'as_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntoBytesArguments { + string: RawTransactionArgument; +} +export interface IntoBytesOptions { + package?: string; + arguments: IntoBytesArguments | [string: RawTransactionArgument]; +} +/** Unpack the `string` to get its backing bytes */ +export function intoBytes(options: IntoBytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'into_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ByteArguments { + char: RawTransactionArgument; +} +export interface ByteOptions { + package?: string; + arguments: ByteArguments | [char: RawTransactionArgument]; +} +/** Unpack the `char` into its underlying bytes. */ +export function byte(options: ByteOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['char']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'byte', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsValidCharArguments { + b: RawTransactionArgument; +} +export interface IsValidCharOptions { + package?: string; + arguments: IsValidCharArguments | [b: RawTransactionArgument]; +} +/** Returns `true` if `b` is a valid ASCII character. Returns `false` otherwise. */ +export function isValidChar(options: IsValidCharOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'is_valid_char', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsPrintableCharArguments { + byte: RawTransactionArgument; +} +export interface IsPrintableCharOptions { + package?: string; + arguments: IsPrintableCharArguments | [byte: RawTransactionArgument]; +} +/** + * Returns `true` if `byte` is a printable ASCII character. Returns `false` + * otherwise. + */ +export function isPrintableChar(options: IsPrintableCharOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['byte']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'is_printable_char', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsEmptyArguments { + string: RawTransactionArgument; +} +export interface IsEmptyOptions { + package?: string; + arguments: IsEmptyArguments | [string: RawTransactionArgument]; +} +/** Returns `true` if `string` is empty. */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToUppercaseArguments { + string: RawTransactionArgument; +} +export interface ToUppercaseOptions { + package?: string; + arguments: ToUppercaseArguments | [string: RawTransactionArgument]; +} +/** Convert a `string` to its uppercase equivalent. */ +export function toUppercase(options: ToUppercaseOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'to_uppercase', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToLowercaseArguments { + string: RawTransactionArgument; +} +export interface ToLowercaseOptions { + package?: string; + arguments: ToLowercaseArguments | [string: RawTransactionArgument]; +} +/** Convert a `string` to its lowercase equivalent. */ +export function toLowercase(options: ToLowercaseOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'to_lowercase', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IndexOfArguments { + string: RawTransactionArgument; + substr: RawTransactionArgument; +} +export interface IndexOfOptions { + package?: string; + arguments: + | IndexOfArguments + | [string: RawTransactionArgument, substr: RawTransactionArgument]; +} +/** + * Computes the index of the first occurrence of the `substr` in the `string`. + * Returns the length of the `string` if the `substr` is not found. Returns 0 if + * the `substr` is empty. + */ +export function indexOf(options: IndexOfOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['string', 'substr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ascii', + function: 'index_of', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/auction.ts b/packages/suins/src/contracts/suins_auction/auction.ts new file mode 100644 index 000000000..a3e5713a0 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/auction.ts @@ -0,0 +1,518 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as bf_hmac_encryption from './deps/seal/bf_hmac_encryption.js'; +import * as balance from './deps/sui/balance.js'; +import * as suins_registration from './deps/suins/suins_registration.js'; +import * as object_bag from './deps/sui/object_bag.js'; +import * as table from './deps/sui/table.js'; +import * as bag from './deps/sui/bag.js'; +import * as type_name from './type_name.js'; +const $moduleName = '@suins/auction::auction'; +export const AuctionWitness = new MoveStruct({ + name: `${$moduleName}::AuctionWitness`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const AdminCap = new MoveStruct({ + name: `${$moduleName}::AdminCap`, + fields: { + id: bcs.Address, + }, +}); +export const Auction = new MoveStruct({ + name: `${$moduleName}::Auction`, + fields: { + id: bcs.Address, + owner: bcs.Address, + start_time: bcs.u64(), + end_time: bcs.u64(), + min_bid: bcs.u64(), + reserve_price: bcs.option(bf_hmac_encryption.EncryptedObject), + highest_bidder: bcs.Address, + highest_bid_balance: balance.Balance, + suins_registration: suins_registration.SuinsRegistration, + }, +}); +export const AuctionTable = new MoveStruct({ + name: `${$moduleName}::AuctionTable`, + fields: { + id: bcs.Address, + version: bcs.u64(), + bag: object_bag.ObjectBag, + allowed_tokens: table.Table, + /** The key servers that must be used for seal encryption. */ + key_servers: bcs.vector(bcs.Address), + /** The public keys for the key servers in the same order as `key_servers`. */ + public_keys: bcs.vector(bcs.vector(bcs.u8())), + /** The threshold for the vote. */ + threshold: bcs.u8(), + service_fee: bcs.u64(), + /** Accumulated service fees for each token type */ + fees: bag.Bag, + }, +}); +export const AuctionCreatedEvent = new MoveStruct({ + name: `${$moduleName}::AuctionCreatedEvent`, + fields: { + auction_id: bcs.Address, + domain_name: bcs.string(), + owner: bcs.Address, + start_time: bcs.u64(), + end_time: bcs.u64(), + min_bid: bcs.u64(), + reserve_price: bcs.option(bcs.vector(bcs.u8())), + token: type_name.TypeName, + }, +}); +export const BidPlacedEvent = new MoveStruct({ + name: `${$moduleName}::BidPlacedEvent`, + fields: { + auction_id: bcs.Address, + domain_name: bcs.string(), + bidder: bcs.Address, + amount: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const AuctionFinalizedEvent = new MoveStruct({ + name: `${$moduleName}::AuctionFinalizedEvent`, + fields: { + auction_id: bcs.Address, + domain_name: bcs.string(), + highest_bidder: bcs.Address, + amount: bcs.u64(), + reserve_price: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const AuctionCancelledEvent = new MoveStruct({ + name: `${$moduleName}::AuctionCancelledEvent`, + fields: { + auction_id: bcs.Address, + domain_name: bcs.string(), + owner: bcs.Address, + token: type_name.TypeName, + }, +}); +export const MigrateEvent = new MoveStruct({ + name: `${$moduleName}::MigrateEvent`, + fields: { + old_version: bcs.u64(), + new_version: bcs.u64(), + }, +}); +export const SetSealConfig = new MoveStruct({ + name: `${$moduleName}::SetSealConfig`, + fields: { + key_servers: bcs.vector(bcs.Address), + public_keys: bcs.vector(bcs.vector(bcs.u8())), + threshold: bcs.u8(), + }, +}); +export const SetServiceFee = new MoveStruct({ + name: `${$moduleName}::SetServiceFee`, + fields: { + service_fee: bcs.u64(), + }, +}); +export const AddAllowedToken = new MoveStruct({ + name: `${$moduleName}::AddAllowedToken`, + fields: { + token: type_name.TypeName, + }, +}); +export const RemoveAllowedToken = new MoveStruct({ + name: `${$moduleName}::RemoveAllowedToken`, + fields: { + token: type_name.TypeName, + }, +}); +export const WithdrawFees = new MoveStruct({ + name: `${$moduleName}::WithdrawFees`, + fields: { + token: type_name.TypeName, + amount: bcs.u64(), + recipient: bcs.Address, + }, +}); +export interface MigrateArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + offerTable: RawTransactionArgument; +} +export interface MigrateOptions { + package?: string; + arguments: + | MigrateArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + offerTable: RawTransactionArgument, + ]; +} +export function migrate(options: MigrateOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'auctionTable', 'offerTable']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'migrate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetSealConfigArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + keyServers: RawTransactionArgument; + publicKeys: RawTransactionArgument; + threshold: RawTransactionArgument; +} +export interface SetSealConfigOptions { + package?: string; + arguments: + | SetSealConfigArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + keyServers: RawTransactionArgument, + publicKeys: RawTransactionArgument, + threshold: RawTransactionArgument, + ]; +} +export function setSealConfig(options: SetSealConfigOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, 'vector
', 'vector>', 'u8'] satisfies ( + | string + | null + )[]; + const parameterNames = ['_', 'auctionTable', 'keyServers', 'publicKeys', 'threshold']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'set_seal_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetServiceFeeArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + offerTable: RawTransactionArgument; + serviceFee: RawTransactionArgument; +} +export interface SetServiceFeeOptions { + package?: string; + arguments: + | SetServiceFeeArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + offerTable: RawTransactionArgument, + serviceFee: RawTransactionArgument, + ]; +} +export function setServiceFee(options: SetServiceFeeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['_', 'auctionTable', 'offerTable', 'serviceFee']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'set_service_fee', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddAllowedTokenArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + offerTable: RawTransactionArgument; +} +export interface AddAllowedTokenOptions { + package?: string; + arguments: + | AddAllowedTokenArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + offerTable: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function addAllowedToken(options: AddAllowedTokenOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'auctionTable', 'offerTable']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'add_allowed_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveAllowedTokenArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + offerTable: RawTransactionArgument; +} +export interface RemoveAllowedTokenOptions { + package?: string; + arguments: + | RemoveAllowedTokenArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + offerTable: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function removeAllowedToken(options: RemoveAllowedTokenOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'auctionTable', 'offerTable']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'remove_allowed_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawFeesArguments { + _: RawTransactionArgument; + auctionTable: RawTransactionArgument; + offerTable: RawTransactionArgument; +} +export interface WithdrawFeesOptions { + package?: string; + arguments: + | WithdrawFeesArguments + | [ + _: RawTransactionArgument, + auctionTable: RawTransactionArgument, + offerTable: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Withdraw accumulated fees from both auction and offer tables */ +export function withdrawFees(options: WithdrawFeesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'auctionTable', 'offerTable']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'withdraw_fees', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateAuctionArguments { + auctionTable: RawTransactionArgument; + startTime: RawTransactionArgument; + endTime: RawTransactionArgument; + minBid: RawTransactionArgument; + encryptedReservePrice: RawTransactionArgument; + suinsRegistration: RawTransactionArgument; +} +export interface CreateAuctionOptions { + package?: string; + arguments: + | CreateAuctionArguments + | [ + auctionTable: RawTransactionArgument, + startTime: RawTransactionArgument, + endTime: RawTransactionArgument, + minBid: RawTransactionArgument, + encryptedReservePrice: RawTransactionArgument, + suinsRegistration: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Create a new auction for a domain with a specific token required */ +export function createAuction(options: CreateAuctionOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + null, + 'u64', + 'u64', + 'u64', + '0x1::option::Option>', + null, + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = [ + 'auctionTable', + 'startTime', + 'endTime', + 'minBid', + 'encryptedReservePrice', + 'suinsRegistration', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'create_auction', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PlaceBidArguments { + auctionTable: RawTransactionArgument; + domainName: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface PlaceBidOptions { + package?: string; + arguments: + | PlaceBidArguments + | [ + auctionTable: RawTransactionArgument, + domainName: RawTransactionArgument, + coin: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Place a bid on an active auction */ +export function placeBid(options: PlaceBidOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['auctionTable', 'domainName', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'place_bid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FinalizeAuctionArguments { + suins: RawTransactionArgument; + auctionTable: RawTransactionArgument; + domainName: RawTransactionArgument; + derivedKeys: RawTransactionArgument; + keyServers: RawTransactionArgument; +} +export interface FinalizeAuctionOptions { + package?: string; + arguments: + | FinalizeAuctionArguments + | [ + suins: RawTransactionArgument, + auctionTable: RawTransactionArgument, + domainName: RawTransactionArgument, + derivedKeys: RawTransactionArgument, + keyServers: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Finalize an auction after it ends, transfer domain and funds */ +export function finalizeAuction(options: FinalizeAuctionOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + null, + null, + '0x1::string::String', + '0x1::option::Option>>', + '0x1::option::Option>', + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['suins', 'auctionTable', 'domainName', 'derivedKeys', 'keyServers']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'finalize_auction', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CancelAuctionArguments { + auctionTable: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface CancelAuctionOptions { + package?: string; + arguments: + | CancelAuctionArguments + | [auctionTable: RawTransactionArgument, domainName: RawTransactionArgument]; + typeArguments: [string]; +} +/** Cancel an auction */ +export function cancelAuction(options: CancelAuctionOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['auctionTable', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'cancel_auction', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetSuinsRegistrationFromAuctionArguments { + auction: RawTransactionArgument; +} +export interface GetSuinsRegistrationFromAuctionOptions { + package?: string; + arguments: GetSuinsRegistrationFromAuctionArguments | [auction: RawTransactionArgument]; + typeArguments: [string]; +} +export function getSuinsRegistrationFromAuction(options: GetSuinsRegistrationFromAuctionOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['auction']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'get_suins_registration_from_auction', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SealApproveArguments { + id: RawTransactionArgument; + auctionTable: RawTransactionArgument; +} +export interface SealApproveOptions { + package?: string; + arguments: + | SealApproveArguments + | [id: RawTransactionArgument, auctionTable: RawTransactionArgument]; + typeArguments: [string]; +} +export function sealApprove(options: SealApproveOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector', null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['id', 'auctionTable']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'seal_approve', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/bcs.ts b/packages/suins/src/contracts/suins_auction/bcs.ts new file mode 100644 index 000000000..b85a8c629 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/bcs.ts @@ -0,0 +1,40 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Utility for converting a Move value to its binary representation in BCS (Binary + * Canonical Serialization). BCS is the binary encoding for Move resources and + * other non-module values published on-chain. See + * https://github.com/diem/bcs#binary-canonical-serialization-bcs for more details + * on BCS. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { type BcsType } from '@mysten/sui/bcs'; +export interface ToBytesArguments> { + v: RawTransactionArgument; +} +export interface ToBytesOptions> { + package?: string; + arguments: ToBytesArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return the binary representation of `v` in BCS (Binary Canonical Serialization) + * format + */ +export function toBytes>(options: ToBytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/bit_vector.ts b/packages/suins/src/contracts/suins_auction/bit_vector.ts new file mode 100644 index 000000000..7dd083163 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/bit_vector.ts @@ -0,0 +1,193 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::bit_vector'; +export const BitVector = new MoveStruct({ + name: `${$moduleName}::BitVector`, + fields: { + length: bcs.u64(), + bit_field: bcs.vector(bcs.bool()), + }, +}); +export interface NewArguments { + length: RawTransactionArgument; +} +export interface NewOptions { + package?: string; + arguments: NewArguments | [length: RawTransactionArgument]; +} +export function _new(options: NewOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['length']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetArguments { + bitvector: RawTransactionArgument; + bitIndex: RawTransactionArgument; +} +export interface SetOptions { + package?: string; + arguments: + | SetArguments + | [ + bitvector: RawTransactionArgument, + bitIndex: RawTransactionArgument, + ]; +} +/** Set the bit at `bit_index` in the `bitvector` regardless of its previous state. */ +export function set(options: SetOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['bitvector', 'bitIndex']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'set', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UnsetArguments { + bitvector: RawTransactionArgument; + bitIndex: RawTransactionArgument; +} +export interface UnsetOptions { + package?: string; + arguments: + | UnsetArguments + | [ + bitvector: RawTransactionArgument, + bitIndex: RawTransactionArgument, + ]; +} +/** + * Unset the bit at `bit_index` in the `bitvector` regardless of its previous + * state. + */ +export function unset(options: UnsetOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['bitvector', 'bitIndex']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'unset', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ShiftLeftArguments { + bitvector: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface ShiftLeftOptions { + package?: string; + arguments: + | ShiftLeftArguments + | [bitvector: RawTransactionArgument, amount: RawTransactionArgument]; +} +/** + * Shift the `bitvector` left by `amount`. If `amount` is greater than the + * bitvector's length the bitvector will be zeroed out. + */ +export function shiftLeft(options: ShiftLeftOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['bitvector', 'amount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'shift_left', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsIndexSetArguments { + bitvector: RawTransactionArgument; + bitIndex: RawTransactionArgument; +} +export interface IsIndexSetOptions { + package?: string; + arguments: + | IsIndexSetArguments + | [ + bitvector: RawTransactionArgument, + bitIndex: RawTransactionArgument, + ]; +} +/** + * Return the value of the bit at `bit_index` in the `bitvector`. `true` represents + * "1" and `false` represents a 0 + */ +export function isIndexSet(options: IsIndexSetOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['bitvector', 'bitIndex']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'is_index_set', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LengthArguments { + bitvector: RawTransactionArgument; +} +export interface LengthOptions { + package?: string; + arguments: LengthArguments | [bitvector: RawTransactionArgument]; +} +/** Return the length (number of usable bits) of this bitvector */ +export function length(options: LengthOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bitvector']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LongestSetSequenceStartingAtArguments { + bitvector: RawTransactionArgument; + startIndex: RawTransactionArgument; +} +export interface LongestSetSequenceStartingAtOptions { + package?: string; + arguments: + | LongestSetSequenceStartingAtArguments + | [ + bitvector: RawTransactionArgument, + startIndex: RawTransactionArgument, + ]; +} +/** + * Returns the length of the longest sequence of set bits starting at (and + * including) `start_index` in the `bitvector`. If there is no such sequence, then + * `0` is returned. + */ +export function longestSetSequenceStartingAt(options: LongestSetSequenceStartingAtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['bitvector', 'startIndex']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bit_vector', + function: 'longest_set_sequence_starting_at', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/constants.ts b/packages/suins/src/contracts/suins_auction/constants.ts new file mode 100644 index 000000000..0d4af8f02 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/constants.ts @@ -0,0 +1,102 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +export interface VersionOptions { + package?: string; + arguments?: []; +} +/** Returns the current version of the auction contract */ +export function version(options: VersionOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'version', + }); +} +export interface BidExtendTimeOptions { + package?: string; + arguments?: []; +} +/** Returns the bid extend time in seconds */ +export function bidExtendTime(options: BidExtendTimeOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'bid_extend_time', + }); +} +export interface MaxPercentageOptions { + package?: string; + arguments?: []; +} +/** Returns the maximum percentage value */ +export function maxPercentage(options: MaxPercentageOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'max_percentage', + }); +} +export interface MinBidIncreasePercentageOptions { + package?: string; + arguments?: []; +} +/** Returns the minimum bid increase percentage */ +export function minBidIncreasePercentage(options: MinBidIncreasePercentageOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'min_bid_increase_percentage', + }); +} +export interface DefaultFeePercentageOptions { + package?: string; + arguments?: []; +} +/** Returns the default service fee percentage */ +export function defaultFeePercentage(options: DefaultFeePercentageOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'default_fee_percentage', + }); +} +export interface MinAuctionTimeOptions { + package?: string; + arguments?: []; +} +/** Returns the minimum auction time */ +export function minAuctionTime(options: MinAuctionTimeOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'min_auction_time', + }); +} +export interface MaxAuctionTimeOptions { + package?: string; + arguments?: []; +} +/** Returns the maximum auction time */ +export function maxAuctionTime(options: MaxAuctionTimeOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'max_auction_time', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/debug.ts b/packages/suins/src/contracts/suins_auction/debug.ts new file mode 100644 index 000000000..776e09c36 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/debug.ts @@ -0,0 +1,43 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Module providing debug functionality. */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { type BcsType } from '@mysten/sui/bcs'; +export interface PrintArguments> { + x: RawTransactionArgument; +} +export interface PrintOptions> { + package?: string; + arguments: PrintArguments | [x: RawTransactionArgument]; + typeArguments: [string]; +} +export function print>(options: PrintOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'debug', + function: 'print', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PrintStackTraceOptions { + package?: string; + arguments?: []; +} +export function printStackTrace(options: PrintStackTraceOptions = {}) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'debug', + function: 'print_stack_trace', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/decryption.ts b/packages/suins/src/contracts/suins_auction/decryption.ts new file mode 100644 index 000000000..0505eeec1 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/decryption.ts @@ -0,0 +1,30 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface GetEncryptionIdArguments { + startTime: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface GetEncryptionIdOptions { + package?: string; + arguments: + | GetEncryptionIdArguments + | [ + startTime: RawTransactionArgument, + domainName: RawTransactionArgument, + ]; +} +export function getEncryptionId(options: GetEncryptionIdOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'vector'] satisfies (string | null)[]; + const parameterNames = ['startTime', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'decryption', + function: 'get_encryption_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts new file mode 100644 index 000000000..cfb17f5f0 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts @@ -0,0 +1,323 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as versioned from '../sui/versioned.js'; +import * as vec_map from '../sui/vec_map.js'; +import * as committee from './committee.js'; +import * as treasury from './treasury.js'; +import * as linked_table from '../sui/linked_table.js'; +import * as message from './message.js'; +import * as limiter from './limiter.js'; +const $moduleName = 'bridge::bridge'; +export const Bridge = new MoveStruct({ + name: `${$moduleName}::Bridge`, + fields: { + id: bcs.Address, + inner: versioned.Versioned, + }, +}); +export const BridgeInner = new MoveStruct({ + name: `${$moduleName}::BridgeInner`, + fields: { + bridge_version: bcs.u64(), + message_version: bcs.u8(), + chain_id: bcs.u8(), + sequence_nums: vec_map.VecMap(bcs.u8(), bcs.u64()), + committee: committee.BridgeCommittee, + treasury: treasury.BridgeTreasury, + token_transfer_records: linked_table.LinkedTable(message.BridgeMessageKey), + limiter: limiter.TransferLimiter, + paused: bcs.bool(), + }, +}); +export const TokenDepositedEvent = new MoveStruct({ + name: `${$moduleName}::TokenDepositedEvent`, + fields: { + seq_num: bcs.u64(), + source_chain: bcs.u8(), + sender_address: bcs.vector(bcs.u8()), + target_chain: bcs.u8(), + target_address: bcs.vector(bcs.u8()), + token_type: bcs.u8(), + amount: bcs.u64(), + }, +}); +export const EmergencyOpEvent = new MoveStruct({ + name: `${$moduleName}::EmergencyOpEvent`, + fields: { + frozen: bcs.bool(), + }, +}); +export const BridgeRecord = new MoveStruct({ + name: `${$moduleName}::BridgeRecord`, + fields: { + message: message.BridgeMessage, + verified_signatures: bcs.option(bcs.vector(bcs.vector(bcs.u8()))), + claimed: bcs.bool(), + }, +}); +export const TokenTransferApproved = new MoveStruct({ + name: `${$moduleName}::TokenTransferApproved`, + fields: { + message_key: message.BridgeMessageKey, + }, +}); +export const TokenTransferClaimed = new MoveStruct({ + name: `${$moduleName}::TokenTransferClaimed`, + fields: { + message_key: message.BridgeMessageKey, + }, +}); +export const TokenTransferAlreadyApproved = new MoveStruct({ + name: `${$moduleName}::TokenTransferAlreadyApproved`, + fields: { + message_key: message.BridgeMessageKey, + }, +}); +export const TokenTransferAlreadyClaimed = new MoveStruct({ + name: `${$moduleName}::TokenTransferAlreadyClaimed`, + fields: { + message_key: message.BridgeMessageKey, + }, +}); +export const TokenTransferLimitExceed = new MoveStruct({ + name: `${$moduleName}::TokenTransferLimitExceed`, + fields: { + message_key: message.BridgeMessageKey, + }, +}); +export interface CommitteeRegistrationArguments { + bridge: RawTransactionArgument; + bridgePubkeyBytes: RawTransactionArgument; + httpRestUrl: RawTransactionArgument; +} +export interface CommitteeRegistrationOptions { + package: string; + arguments: + | CommitteeRegistrationArguments + | [ + bridge: RawTransactionArgument, + bridgePubkeyBytes: RawTransactionArgument, + httpRestUrl: RawTransactionArgument, + ]; +} +export function committeeRegistration(options: CommitteeRegistrationOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + '0x3::sui_system::SuiSystemState', + 'vector', + 'vector', + ] satisfies (string | null)[]; + const parameterNames = ['bridge', 'bridgePubkeyBytes', 'httpRestUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'committee_registration', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateNodeUrlArguments { + bridge: RawTransactionArgument; + newUrl: RawTransactionArgument; +} +export interface UpdateNodeUrlOptions { + package: string; + arguments: + | UpdateNodeUrlArguments + | [bridge: RawTransactionArgument, newUrl: RawTransactionArgument]; +} +export function updateNodeUrl(options: UpdateNodeUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; + const parameterNames = ['bridge', 'newUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'update_node_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RegisterForeignTokenArguments { + bridge: RawTransactionArgument; + tc: RawTransactionArgument; + uc: RawTransactionArgument; + metadata: RawTransactionArgument; +} +export interface RegisterForeignTokenOptions { + package: string; + arguments: + | RegisterForeignTokenArguments + | [ + bridge: RawTransactionArgument, + tc: RawTransactionArgument, + uc: RawTransactionArgument, + metadata: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function registerForeignToken(options: RegisterForeignTokenOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null, null] satisfies (string | null)[]; + const parameterNames = ['bridge', 'tc', 'uc', 'metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'register_foreign_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SendTokenArguments { + bridge: RawTransactionArgument; + targetChain: RawTransactionArgument; + targetAddress: RawTransactionArgument; + token: RawTransactionArgument; +} +export interface SendTokenOptions { + package: string; + arguments: + | SendTokenArguments + | [ + bridge: RawTransactionArgument, + targetChain: RawTransactionArgument, + targetAddress: RawTransactionArgument, + token: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function sendToken(options: SendTokenOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8', 'vector', null] satisfies (string | null)[]; + const parameterNames = ['bridge', 'targetChain', 'targetAddress', 'token']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'send_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ApproveTokenTransferArguments { + bridge: RawTransactionArgument; + message: RawTransactionArgument; + signatures: RawTransactionArgument; +} +export interface ApproveTokenTransferOptions { + package: string; + arguments: + | ApproveTokenTransferArguments + | [ + bridge: RawTransactionArgument, + message: RawTransactionArgument, + signatures: RawTransactionArgument, + ]; +} +export function approveTokenTransfer(options: ApproveTokenTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; + const parameterNames = ['bridge', 'message', 'signatures']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'approve_token_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ClaimTokenArguments { + bridge: RawTransactionArgument; + sourceChain: RawTransactionArgument; + bridgeSeqNum: RawTransactionArgument; +} +export interface ClaimTokenOptions { + package: string; + arguments: + | ClaimTokenArguments + | [ + bridge: RawTransactionArgument, + sourceChain: RawTransactionArgument, + bridgeSeqNum: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function claimToken(options: ClaimTokenOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock', 'u8', 'u64'] satisfies (string | null)[]; + const parameterNames = ['bridge', 'sourceChain', 'bridgeSeqNum']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'claim_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ClaimAndTransferTokenArguments { + bridge: RawTransactionArgument; + sourceChain: RawTransactionArgument; + bridgeSeqNum: RawTransactionArgument; +} +export interface ClaimAndTransferTokenOptions { + package: string; + arguments: + | ClaimAndTransferTokenArguments + | [ + bridge: RawTransactionArgument, + sourceChain: RawTransactionArgument, + bridgeSeqNum: RawTransactionArgument, + ]; + typeArguments: [string]; +} +export function claimAndTransferToken(options: ClaimAndTransferTokenOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock', 'u8', 'u64'] satisfies (string | null)[]; + const parameterNames = ['bridge', 'sourceChain', 'bridgeSeqNum']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'claim_and_transfer_token', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExecuteSystemMessageArguments { + bridge: RawTransactionArgument; + message: RawTransactionArgument; + signatures: RawTransactionArgument; +} +export interface ExecuteSystemMessageOptions { + package: string; + arguments: + | ExecuteSystemMessageArguments + | [ + bridge: RawTransactionArgument, + message: RawTransactionArgument, + signatures: RawTransactionArgument, + ]; +} +export function executeSystemMessage(options: ExecuteSystemMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; + const parameterNames = ['bridge', 'message', 'signatures']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bridge', + function: 'execute_system_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts new file mode 100644 index 000000000..f14f62868 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts @@ -0,0 +1,210 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'bridge::chain_ids'; +export const BridgeRoute = new MoveStruct({ + name: `${$moduleName}::BridgeRoute`, + fields: { + source: bcs.u8(), + destination: bcs.u8(), + }, +}); +export interface SuiMainnetOptions { + package: string; + arguments?: []; +} +export function suiMainnet(options: SuiMainnetOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'sui_mainnet', + }); +} +export interface SuiTestnetOptions { + package: string; + arguments?: []; +} +export function suiTestnet(options: SuiTestnetOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'sui_testnet', + }); +} +export interface SuiCustomOptions { + package: string; + arguments?: []; +} +export function suiCustom(options: SuiCustomOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'sui_custom', + }); +} +export interface EthMainnetOptions { + package: string; + arguments?: []; +} +export function ethMainnet(options: EthMainnetOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'eth_mainnet', + }); +} +export interface EthSepoliaOptions { + package: string; + arguments?: []; +} +export function ethSepolia(options: EthSepoliaOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'eth_sepolia', + }); +} +export interface EthCustomOptions { + package: string; + arguments?: []; +} +export function ethCustom(options: EthCustomOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'eth_custom', + }); +} +export interface RouteSourceArguments { + route: RawTransactionArgument; +} +export interface RouteSourceOptions { + package: string; + arguments: RouteSourceArguments | [route: RawTransactionArgument]; +} +export function routeSource(options: RouteSourceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['route']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'route_source', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RouteDestinationArguments { + route: RawTransactionArgument; +} +export interface RouteDestinationOptions { + package: string; + arguments: RouteDestinationArguments | [route: RawTransactionArgument]; +} +export function routeDestination(options: RouteDestinationOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['route']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'route_destination', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AssertValidChainIdArguments { + id: RawTransactionArgument; +} +export interface AssertValidChainIdOptions { + package: string; + arguments: AssertValidChainIdArguments | [id: RawTransactionArgument]; +} +export function assertValidChainId(options: AssertValidChainIdOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'assert_valid_chain_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidRoutesOptions { + package: string; + arguments?: []; +} +export function validRoutes(options: ValidRoutesOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'valid_routes', + }); +} +export interface IsValidRouteArguments { + source: RawTransactionArgument; + destination: RawTransactionArgument; +} +export interface IsValidRouteOptions { + package: string; + arguments: + | IsValidRouteArguments + | [source: RawTransactionArgument, destination: RawTransactionArgument]; +} +export function isValidRoute(options: IsValidRouteOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['source', 'destination']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'is_valid_route', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetRouteArguments { + source: RawTransactionArgument; + destination: RawTransactionArgument; +} +export interface GetRouteOptions { + package: string; + arguments: + | GetRouteArguments + | [source: RawTransactionArgument, destination: RawTransactionArgument]; +} +export function getRoute(options: GetRouteOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['source', 'destination']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'chain_ids', + function: 'get_route', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts new file mode 100644 index 000000000..7ec9572fa --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts @@ -0,0 +1,100 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from '../sui/vec_map.js'; +const $moduleName = 'bridge::committee'; +export const CommitteeMember = new MoveStruct({ + name: `${$moduleName}::CommitteeMember`, + fields: { + /** The Sui Address of the validator */ + sui_address: bcs.Address, + /** The public key bytes of the bridge key */ + bridge_pubkey_bytes: bcs.vector(bcs.u8()), + /** Voting power, values are voting power in the scale of 10000. */ + voting_power: bcs.u64(), + /** + * The HTTP REST URL the member's node listens to it looks like + * b'https://127.0.0.1:9191' + */ + http_rest_url: bcs.vector(bcs.u8()), + /** If this member is blocklisted */ + blocklisted: bcs.bool(), + }, +}); +export const CommitteeMemberRegistration = new MoveStruct({ + name: `${$moduleName}::CommitteeMemberRegistration`, + fields: { + /** The Sui Address of the validator */ + sui_address: bcs.Address, + /** The public key bytes of the bridge key */ + bridge_pubkey_bytes: bcs.vector(bcs.u8()), + /** + * The HTTP REST URL the member's node listens to it looks like + * b'https://127.0.0.1:9191' + */ + http_rest_url: bcs.vector(bcs.u8()), + }, +}); +export const BridgeCommittee = new MoveStruct({ + name: `${$moduleName}::BridgeCommittee`, + fields: { + members: vec_map.VecMap(bcs.vector(bcs.u8()), CommitteeMember), + member_registrations: vec_map.VecMap(bcs.Address, CommitteeMemberRegistration), + last_committee_update_epoch: bcs.u64(), + }, +}); +export const BlocklistValidatorEvent = new MoveStruct({ + name: `${$moduleName}::BlocklistValidatorEvent`, + fields: { + blocklisted: bcs.bool(), + public_keys: bcs.vector(bcs.vector(bcs.u8())), + }, +}); +export const CommitteeUpdateEvent = new MoveStruct({ + name: `${$moduleName}::CommitteeUpdateEvent`, + fields: { + members: vec_map.VecMap(bcs.vector(bcs.u8()), CommitteeMember), + stake_participation_percentage: bcs.u64(), + }, +}); +export const CommitteeMemberUrlUpdateEvent = new MoveStruct({ + name: `${$moduleName}::CommitteeMemberUrlUpdateEvent`, + fields: { + member: bcs.vector(bcs.u8()), + new_url: bcs.vector(bcs.u8()), + }, +}); +export interface VerifySignaturesArguments { + self: RawTransactionArgument; + message: RawTransactionArgument; + signatures: RawTransactionArgument; +} +export interface VerifySignaturesOptions { + package: string; + arguments: + | VerifySignaturesArguments + | [ + self: RawTransactionArgument, + message: RawTransactionArgument, + signatures: RawTransactionArgument, + ]; +} +export function verifySignatures(options: VerifySignaturesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; + const parameterNames = ['self', 'message', 'signatures']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'committee', + function: 'verify_signatures', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts new file mode 100644 index 000000000..a858a9abd --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts @@ -0,0 +1,59 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from '../sui/vec_map.js'; +import * as chain_ids from './chain_ids.js'; +const $moduleName = 'bridge::limiter'; +export const TransferRecord = new MoveStruct({ + name: `${$moduleName}::TransferRecord`, + fields: { + hour_head: bcs.u64(), + hour_tail: bcs.u64(), + per_hour_amounts: bcs.vector(bcs.u64()), + total_amount: bcs.u64(), + }, +}); +export const TransferLimiter = new MoveStruct({ + name: `${$moduleName}::TransferLimiter`, + fields: { + transfer_limits: vec_map.VecMap(chain_ids.BridgeRoute, bcs.u64()), + transfer_records: vec_map.VecMap(chain_ids.BridgeRoute, TransferRecord), + }, +}); +export const UpdateRouteLimitEvent = new MoveStruct({ + name: `${$moduleName}::UpdateRouteLimitEvent`, + fields: { + sending_chain: bcs.u8(), + receiving_chain: bcs.u8(), + new_limit: bcs.u64(), + }, +}); +export interface GetRouteLimitArguments { + self: RawTransactionArgument; + route: RawTransactionArgument; +} +export interface GetRouteLimitOptions { + package: string; + arguments: + | GetRouteLimitArguments + | [self: RawTransactionArgument, route: RawTransactionArgument]; +} +export function getRouteLimit(options: GetRouteLimitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'route']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'limiter', + function: 'get_route_limit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts new file mode 100644 index 000000000..17bee3ca6 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts @@ -0,0 +1,974 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'bridge::message'; +export const BridgeMessageKey = new MoveStruct({ + name: `${$moduleName}::BridgeMessageKey`, + fields: { + source_chain: bcs.u8(), + message_type: bcs.u8(), + bridge_seq_num: bcs.u64(), + }, +}); +export const BridgeMessage = new MoveStruct({ + name: `${$moduleName}::BridgeMessage`, + fields: { + message_type: bcs.u8(), + message_version: bcs.u8(), + seq_num: bcs.u64(), + source_chain: bcs.u8(), + payload: bcs.vector(bcs.u8()), + }, +}); +export const TokenTransferPayload = new MoveStruct({ + name: `${$moduleName}::TokenTransferPayload`, + fields: { + sender_address: bcs.vector(bcs.u8()), + target_chain: bcs.u8(), + target_address: bcs.vector(bcs.u8()), + token_type: bcs.u8(), + amount: bcs.u64(), + }, +}); +export const EmergencyOp = new MoveStruct({ + name: `${$moduleName}::EmergencyOp`, + fields: { + op_type: bcs.u8(), + }, +}); +export const Blocklist = new MoveStruct({ + name: `${$moduleName}::Blocklist`, + fields: { + blocklist_type: bcs.u8(), + validator_eth_addresses: bcs.vector(bcs.vector(bcs.u8())), + }, +}); +export const UpdateBridgeLimit = new MoveStruct({ + name: `${$moduleName}::UpdateBridgeLimit`, + fields: { + receiving_chain: bcs.u8(), + sending_chain: bcs.u8(), + limit: bcs.u64(), + }, +}); +export const UpdateAssetPrice = new MoveStruct({ + name: `${$moduleName}::UpdateAssetPrice`, + fields: { + token_id: bcs.u8(), + new_price: bcs.u64(), + }, +}); +export const AddTokenOnSui = new MoveStruct({ + name: `${$moduleName}::AddTokenOnSui`, + fields: { + native_token: bcs.bool(), + token_ids: bcs.vector(bcs.u8()), + token_type_names: bcs.vector(bcs.string()), + token_prices: bcs.vector(bcs.u64()), + }, +}); +export const ParsedTokenTransferMessage = new MoveStruct({ + name: `${$moduleName}::ParsedTokenTransferMessage`, + fields: { + message_version: bcs.u8(), + seq_num: bcs.u64(), + source_chain: bcs.u8(), + payload: bcs.vector(bcs.u8()), + parsed_payload: TokenTransferPayload, + }, +}); +export interface ExtractTokenBridgePayloadArguments { + message: RawTransactionArgument; +} +export interface ExtractTokenBridgePayloadOptions { + package: string; + arguments: ExtractTokenBridgePayloadArguments | [message: RawTransactionArgument]; +} +export function extractTokenBridgePayload(options: ExtractTokenBridgePayloadOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_token_bridge_payload', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExtractEmergencyOpPayloadArguments { + message: RawTransactionArgument; +} +export interface ExtractEmergencyOpPayloadOptions { + package: string; + arguments: ExtractEmergencyOpPayloadArguments | [message: RawTransactionArgument]; +} +/** Emergency op payload is just a single byte */ +export function extractEmergencyOpPayload(options: ExtractEmergencyOpPayloadOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_emergency_op_payload', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExtractBlocklistPayloadArguments { + message: RawTransactionArgument; +} +export interface ExtractBlocklistPayloadOptions { + package: string; + arguments: ExtractBlocklistPayloadArguments | [message: RawTransactionArgument]; +} +export function extractBlocklistPayload(options: ExtractBlocklistPayloadOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_blocklist_payload', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExtractUpdateBridgeLimitArguments { + message: RawTransactionArgument; +} +export interface ExtractUpdateBridgeLimitOptions { + package: string; + arguments: ExtractUpdateBridgeLimitArguments | [message: RawTransactionArgument]; +} +export function extractUpdateBridgeLimit(options: ExtractUpdateBridgeLimitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_update_bridge_limit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExtractUpdateAssetPriceArguments { + message: RawTransactionArgument; +} +export interface ExtractUpdateAssetPriceOptions { + package: string; + arguments: ExtractUpdateAssetPriceArguments | [message: RawTransactionArgument]; +} +export function extractUpdateAssetPrice(options: ExtractUpdateAssetPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_update_asset_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExtractAddTokensOnSuiArguments { + message: RawTransactionArgument; +} +export interface ExtractAddTokensOnSuiOptions { + package: string; + arguments: ExtractAddTokensOnSuiArguments | [message: RawTransactionArgument]; +} +export function extractAddTokensOnSui(options: ExtractAddTokensOnSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'extract_add_tokens_on_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SerializeMessageArguments { + message: RawTransactionArgument; +} +export interface SerializeMessageOptions { + package: string; + arguments: SerializeMessageArguments | [message: RawTransactionArgument]; +} +export function serializeMessage(options: SerializeMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'serialize_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateTokenBridgeMessageArguments { + sourceChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + senderAddress: RawTransactionArgument; + targetChain: RawTransactionArgument; + targetAddress: RawTransactionArgument; + tokenType: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface CreateTokenBridgeMessageOptions { + package: string; + arguments: + | CreateTokenBridgeMessageArguments + | [ + sourceChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + senderAddress: RawTransactionArgument, + targetChain: RawTransactionArgument, + targetAddress: RawTransactionArgument, + tokenType: RawTransactionArgument, + amount: RawTransactionArgument, + ]; +} +/** + * Token Transfer Message Format: [message_type: u8] [version:u8] [nonce:u64] + * [source_chain: u8] [sender_address_length:u8] [sender_address: byte[]] + * [target_chain:u8] [target_address_length:u8] [target_address: byte[]] + * [token_type:u8] [amount:u64] + */ +export function createTokenBridgeMessage(options: CreateTokenBridgeMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u64', 'vector', 'u8', 'vector', 'u8', 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = [ + 'sourceChain', + 'seqNum', + 'senderAddress', + 'targetChain', + 'targetAddress', + 'tokenType', + 'amount', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_token_bridge_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateEmergencyOpMessageArguments { + sourceChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + opType: RawTransactionArgument; +} +export interface CreateEmergencyOpMessageOptions { + package: string; + arguments: + | CreateEmergencyOpMessageArguments + | [ + sourceChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + opType: RawTransactionArgument, + ]; +} +/** + * Emergency Op Message Format: [message_type: u8] [version:u8] [nonce:u64] + * [chain_id: u8] [op_type: u8] + */ +export function createEmergencyOpMessage(options: CreateEmergencyOpMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u64', 'u8'] satisfies (string | null)[]; + const parameterNames = ['sourceChain', 'seqNum', 'opType']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_emergency_op_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateBlocklistMessageArguments { + sourceChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + blocklistType: RawTransactionArgument; + validatorEcdsaAddresses: RawTransactionArgument; +} +export interface CreateBlocklistMessageOptions { + package: string; + arguments: + | CreateBlocklistMessageArguments + | [ + sourceChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + blocklistType: RawTransactionArgument, + validatorEcdsaAddresses: RawTransactionArgument, + ]; +} +/** + * Blocklist Message Format: [message_type: u8] [version:u8] [nonce:u64] [chain_id: + * u8] [blocklist_type: u8] [validator_length: u8] [validator_ecdsa_addresses: + * byte[][]] + */ +export function createBlocklistMessage(options: CreateBlocklistMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u64', 'u8', 'vector>'] satisfies (string | null)[]; + const parameterNames = ['sourceChain', 'seqNum', 'blocklistType', 'validatorEcdsaAddresses']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_blocklist_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateUpdateBridgeLimitMessageArguments { + receivingChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + sendingChain: RawTransactionArgument; + newLimit: RawTransactionArgument; +} +export interface CreateUpdateBridgeLimitMessageOptions { + package: string; + arguments: + | CreateUpdateBridgeLimitMessageArguments + | [ + receivingChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + sendingChain: RawTransactionArgument, + newLimit: RawTransactionArgument, + ]; +} +/** + * Update bridge limit Message Format: [message_type: u8] [version:u8] [nonce:u64] + * [receiving_chain_id: u8] [sending_chain_id: u8] [new_limit: u64] + */ +export function createUpdateBridgeLimitMessage(options: CreateUpdateBridgeLimitMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u64', 'u8', 'u64'] satisfies (string | null)[]; + const parameterNames = ['receivingChain', 'seqNum', 'sendingChain', 'newLimit']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_update_bridge_limit_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateUpdateAssetPriceMessageArguments { + tokenId: RawTransactionArgument; + sourceChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + newPrice: RawTransactionArgument; +} +export interface CreateUpdateAssetPriceMessageOptions { + package: string; + arguments: + | CreateUpdateAssetPriceMessageArguments + | [ + tokenId: RawTransactionArgument, + sourceChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + newPrice: RawTransactionArgument, + ]; +} +/** + * Update asset price message [message_type: u8] [version:u8] [nonce:u64] + * [chain_id: u8] [token_id: u8] [new_price:u64] + */ +export function createUpdateAssetPriceMessage(options: CreateUpdateAssetPriceMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u8', 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['tokenId', 'sourceChain', 'seqNum', 'newPrice']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_update_asset_price_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateAddTokensOnSuiMessageArguments { + sourceChain: RawTransactionArgument; + seqNum: RawTransactionArgument; + nativeToken: RawTransactionArgument; + tokenIds: RawTransactionArgument; + typeNames: RawTransactionArgument; + tokenPrices: RawTransactionArgument; +} +export interface CreateAddTokensOnSuiMessageOptions { + package: string; + arguments: + | CreateAddTokensOnSuiMessageArguments + | [ + sourceChain: RawTransactionArgument, + seqNum: RawTransactionArgument, + nativeToken: RawTransactionArgument, + tokenIds: RawTransactionArgument, + typeNames: RawTransactionArgument, + tokenPrices: RawTransactionArgument, + ]; +} +/** + * Update Sui token message [message_type:u8] [version:u8] [nonce:u64] [chain_id: + * u8] [native_token:bool] [token_ids:vector] [token_type_name:vector] + * [token_prices:vector] + */ +export function createAddTokensOnSuiMessage(options: CreateAddTokensOnSuiMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + 'u8', + 'u64', + 'bool', + 'vector', + 'vector<0x1::string::String>', + 'vector', + ] satisfies (string | null)[]; + const parameterNames = [ + 'sourceChain', + 'seqNum', + 'nativeToken', + 'tokenIds', + 'typeNames', + 'tokenPrices', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_add_tokens_on_sui_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateKeyArguments { + sourceChain: RawTransactionArgument; + messageType: RawTransactionArgument; + bridgeSeqNum: RawTransactionArgument; +} +export interface CreateKeyOptions { + package: string; + arguments: + | CreateKeyArguments + | [ + sourceChain: RawTransactionArgument, + messageType: RawTransactionArgument, + bridgeSeqNum: RawTransactionArgument, + ]; +} +export function createKey(options: CreateKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u8', 'u8', 'u64'] satisfies (string | null)[]; + const parameterNames = ['sourceChain', 'messageType', 'bridgeSeqNum']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'create_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface KeyArguments { + self: RawTransactionArgument; +} +export interface KeyOptions { + package: string; + arguments: KeyArguments | [self: RawTransactionArgument]; +} +export function key(options: KeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MessageVersionArguments { + self: RawTransactionArgument; +} +export interface MessageVersionOptions { + package: string; + arguments: MessageVersionArguments | [self: RawTransactionArgument]; +} +export function messageVersion(options: MessageVersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'message_version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MessageTypeArguments { + self: RawTransactionArgument; +} +export interface MessageTypeOptions { + package: string; + arguments: MessageTypeArguments | [self: RawTransactionArgument]; +} +export function messageType(options: MessageTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'message_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SeqNumArguments { + self: RawTransactionArgument; +} +export interface SeqNumOptions { + package: string; + arguments: SeqNumArguments | [self: RawTransactionArgument]; +} +export function seqNum(options: SeqNumOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'seq_num', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SourceChainArguments { + self: RawTransactionArgument; +} +export interface SourceChainOptions { + package: string; + arguments: SourceChainArguments | [self: RawTransactionArgument]; +} +export function sourceChain(options: SourceChainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'source_chain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PayloadArguments { + self: RawTransactionArgument; +} +export interface PayloadOptions { + package: string; + arguments: PayloadArguments | [self: RawTransactionArgument]; +} +export function payload(options: PayloadOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'payload', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenTargetChainArguments { + self: RawTransactionArgument; +} +export interface TokenTargetChainOptions { + package: string; + arguments: TokenTargetChainArguments | [self: RawTransactionArgument]; +} +export function tokenTargetChain(options: TokenTargetChainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_target_chain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenTargetAddressArguments { + self: RawTransactionArgument; +} +export interface TokenTargetAddressOptions { + package: string; + arguments: TokenTargetAddressArguments | [self: RawTransactionArgument]; +} +export function tokenTargetAddress(options: TokenTargetAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_target_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenTypeArguments { + self: RawTransactionArgument; +} +export interface TokenTypeOptions { + package: string; + arguments: TokenTypeArguments | [self: RawTransactionArgument]; +} +export function tokenType(options: TokenTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenAmountArguments { + self: RawTransactionArgument; +} +export interface TokenAmountOptions { + package: string; + arguments: TokenAmountArguments | [self: RawTransactionArgument]; +} +export function tokenAmount(options: TokenAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface EmergencyOpTypeArguments { + self: RawTransactionArgument; +} +export interface EmergencyOpTypeOptions { + package: string; + arguments: EmergencyOpTypeArguments | [self: RawTransactionArgument]; +} +export function emergencyOpType(options: EmergencyOpTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'emergency_op_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BlocklistTypeArguments { + self: RawTransactionArgument; +} +export interface BlocklistTypeOptions { + package: string; + arguments: BlocklistTypeArguments | [self: RawTransactionArgument]; +} +export function blocklistType(options: BlocklistTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'blocklist_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BlocklistValidatorAddressesArguments { + self: RawTransactionArgument; +} +export interface BlocklistValidatorAddressesOptions { + package: string; + arguments: BlocklistValidatorAddressesArguments | [self: RawTransactionArgument]; +} +export function blocklistValidatorAddresses(options: BlocklistValidatorAddressesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'blocklist_validator_addresses', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateBridgeLimitPayloadSendingChainArguments { + self: RawTransactionArgument; +} +export interface UpdateBridgeLimitPayloadSendingChainOptions { + package: string; + arguments: UpdateBridgeLimitPayloadSendingChainArguments | [self: RawTransactionArgument]; +} +export function updateBridgeLimitPayloadSendingChain( + options: UpdateBridgeLimitPayloadSendingChainOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'update_bridge_limit_payload_sending_chain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateBridgeLimitPayloadReceivingChainArguments { + self: RawTransactionArgument; +} +export interface UpdateBridgeLimitPayloadReceivingChainOptions { + package: string; + arguments: + | UpdateBridgeLimitPayloadReceivingChainArguments + | [self: RawTransactionArgument]; +} +export function updateBridgeLimitPayloadReceivingChain( + options: UpdateBridgeLimitPayloadReceivingChainOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'update_bridge_limit_payload_receiving_chain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateBridgeLimitPayloadLimitArguments { + self: RawTransactionArgument; +} +export interface UpdateBridgeLimitPayloadLimitOptions { + package: string; + arguments: UpdateBridgeLimitPayloadLimitArguments | [self: RawTransactionArgument]; +} +export function updateBridgeLimitPayloadLimit(options: UpdateBridgeLimitPayloadLimitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'update_bridge_limit_payload_limit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateAssetPricePayloadTokenIdArguments { + self: RawTransactionArgument; +} +export interface UpdateAssetPricePayloadTokenIdOptions { + package: string; + arguments: UpdateAssetPricePayloadTokenIdArguments | [self: RawTransactionArgument]; +} +export function updateAssetPricePayloadTokenId(options: UpdateAssetPricePayloadTokenIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'update_asset_price_payload_token_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateAssetPricePayloadNewPriceArguments { + self: RawTransactionArgument; +} +export interface UpdateAssetPricePayloadNewPriceOptions { + package: string; + arguments: UpdateAssetPricePayloadNewPriceArguments | [self: RawTransactionArgument]; +} +export function updateAssetPricePayloadNewPrice(options: UpdateAssetPricePayloadNewPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'update_asset_price_payload_new_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsNativeArguments { + self: RawTransactionArgument; +} +export interface IsNativeOptions { + package: string; + arguments: IsNativeArguments | [self: RawTransactionArgument]; +} +export function isNative(options: IsNativeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'is_native', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenIdsArguments { + self: RawTransactionArgument; +} +export interface TokenIdsOptions { + package: string; + arguments: TokenIdsArguments | [self: RawTransactionArgument]; +} +export function tokenIds(options: TokenIdsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_ids', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenTypeNamesArguments { + self: RawTransactionArgument; +} +export interface TokenTypeNamesOptions { + package: string; + arguments: TokenTypeNamesArguments | [self: RawTransactionArgument]; +} +export function tokenTypeNames(options: TokenTypeNamesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_type_names', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TokenPricesArguments { + self: RawTransactionArgument; +} +export interface TokenPricesOptions { + package: string; + arguments: TokenPricesArguments | [self: RawTransactionArgument]; +} +export function tokenPrices(options: TokenPricesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'token_prices', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface EmergencyOpPauseOptions { + package: string; + arguments?: []; +} +export function emergencyOpPause(options: EmergencyOpPauseOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'emergency_op_pause', + }); +} +export interface EmergencyOpUnpauseOptions { + package: string; + arguments?: []; +} +export function emergencyOpUnpause(options: EmergencyOpUnpauseOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'emergency_op_unpause', + }); +} +export interface RequiredVotingPowerArguments { + self: RawTransactionArgument; +} +export interface RequiredVotingPowerOptions { + package: string; + arguments: RequiredVotingPowerArguments | [self: RawTransactionArgument]; +} +/** + * Return the required signature threshold for the message, values are voting power + * in the scale of 10000 + */ +export function requiredVotingPower(options: RequiredVotingPowerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'required_voting_power', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToParsedTokenTransferMessageArguments { + message: RawTransactionArgument; +} +export interface ToParsedTokenTransferMessageOptions { + package: string; + arguments: ToParsedTokenTransferMessageArguments | [message: RawTransactionArgument]; +} +export function toParsedTokenTransferMessage(options: ToParsedTokenTransferMessageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message', + function: 'to_parsed_token_transfer_message', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts new file mode 100644 index 000000000..b4ab36b8b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts @@ -0,0 +1,82 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +export interface TokenOptions { + package: string; + arguments?: []; +} +export function token(options: TokenOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'token', + }); +} +export interface CommitteeBlocklistOptions { + package: string; + arguments?: []; +} +export function committeeBlocklist(options: CommitteeBlocklistOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'committee_blocklist', + }); +} +export interface EmergencyOpOptions { + package: string; + arguments?: []; +} +export function emergencyOp(options: EmergencyOpOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'emergency_op', + }); +} +export interface UpdateBridgeLimitOptions { + package: string; + arguments?: []; +} +export function updateBridgeLimit(options: UpdateBridgeLimitOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'update_bridge_limit', + }); +} +export interface UpdateAssetPriceOptions { + package: string; + arguments?: []; +} +export function updateAssetPrice(options: UpdateAssetPriceOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'update_asset_price', + }); +} +export interface AddTokensOnSuiOptions { + package: string; + arguments?: []; +} +export function addTokensOnSui(options: AddTokensOnSuiOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'message_types', + function: 'add_tokens_on_sui', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts new file mode 100644 index 000000000..1e908de2f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts @@ -0,0 +1,130 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as object_bag from '../sui/object_bag.js'; +import * as vec_map from '../sui/vec_map.js'; +import * as type_name from '../suins_auction/type_name.js'; +import * as bag from '../sui/bag.js'; +import * as _package from '../sui/package.js'; +const $moduleName = 'bridge::treasury'; +export const BridgeTokenMetadata = new MoveStruct({ + name: `${$moduleName}::BridgeTokenMetadata`, + fields: { + id: bcs.u8(), + decimal_multiplier: bcs.u64(), + notional_value: bcs.u64(), + native_token: bcs.bool(), + }, +}); +export const BridgeTreasury = new MoveStruct({ + name: `${$moduleName}::BridgeTreasury`, + fields: { + treasuries: object_bag.ObjectBag, + supported_tokens: vec_map.VecMap(type_name.TypeName, BridgeTokenMetadata), + id_token_type_map: vec_map.VecMap(bcs.u8(), type_name.TypeName), + waiting_room: bag.Bag, + }, +}); +export const ForeignTokenRegistration = new MoveStruct({ + name: `${$moduleName}::ForeignTokenRegistration`, + fields: { + type_name: type_name.TypeName, + uc: _package.UpgradeCap, + decimal: bcs.u8(), + }, +}); +export const UpdateTokenPriceEvent = new MoveStruct({ + name: `${$moduleName}::UpdateTokenPriceEvent`, + fields: { + token_id: bcs.u8(), + new_price: bcs.u64(), + }, +}); +export const NewTokenEvent = new MoveStruct({ + name: `${$moduleName}::NewTokenEvent`, + fields: { + token_id: bcs.u8(), + type_name: type_name.TypeName, + native_token: bcs.bool(), + decimal_multiplier: bcs.u64(), + notional_value: bcs.u64(), + }, +}); +export const TokenRegistrationEvent = new MoveStruct({ + name: `${$moduleName}::TokenRegistrationEvent`, + fields: { + type_name: type_name.TypeName, + decimal: bcs.u8(), + native_token: bcs.bool(), + }, +}); +export interface TokenIdArguments { + self: RawTransactionArgument; +} +export interface TokenIdOptions { + package: string; + arguments: TokenIdArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +export function tokenId(options: TokenIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'treasury', + function: 'token_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DecimalMultiplierArguments { + self: RawTransactionArgument; +} +export interface DecimalMultiplierOptions { + package: string; + arguments: DecimalMultiplierArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +export function decimalMultiplier(options: DecimalMultiplierOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'treasury', + function: 'decimal_multiplier', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NotionalValueArguments { + self: RawTransactionArgument; +} +export interface NotionalValueOptions { + package: string; + arguments: NotionalValueArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +export function notionalValue(options: NotionalValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'treasury', + function: 'notional_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts b/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts new file mode 100644 index 000000000..3802d278d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts @@ -0,0 +1,400 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Implementation of decryption for Seal using Boneh-Franklin over BLS12-381 as KEM + * and Hmac256Ctr as DEM. Refer usage at docs + * https://seal-docs.wal.app/UsingSeal/#on-chain-decryption + */ + +import { + MoveStruct, + MoveEnum, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as group_ops from '../sui/group_ops.js'; +const $moduleName = 'seal::bf_hmac_encryption'; +export const EncryptedObject = new MoveStruct({ + name: `${$moduleName}::EncryptedObject`, + fields: { + package_id: bcs.Address, + id: bcs.vector(bcs.u8()), + indices: bcs.vector(bcs.u8()), + services: bcs.vector(bcs.Address), + threshold: bcs.u8(), + nonce: group_ops.Element, + encrypted_shares: bcs.vector(bcs.vector(bcs.u8())), + encrypted_randomness: bcs.vector(bcs.u8()), + blob: bcs.vector(bcs.u8()), + aad: bcs.option(bcs.vector(bcs.u8())), + mac: bcs.vector(bcs.u8()), + }, +}); +export const VerifiedDerivedKey = new MoveStruct({ + name: `${$moduleName}::VerifiedDerivedKey`, + fields: { + derived_key: group_ops.Element, + package_id: bcs.Address, + id: bcs.vector(bcs.u8()), + key_server: bcs.Address, + }, +}); +export const PublicKey = new MoveStruct({ + name: `${$moduleName}::PublicKey`, + fields: { + key_server: bcs.Address, + pk: group_ops.Element, + }, +}); +/** An enum representing the different purposes of the derived key. */ +export const KeyPurpose = new MoveEnum({ + name: `${$moduleName}::KeyPurpose`, + fields: { + EncryptedRandomness: null, + DEM: null, + }, +}); +export interface NewPublicKeyArguments { + keyServerId: RawTransactionArgument; + pkBytes: RawTransactionArgument; +} +export interface NewPublicKeyOptions { + package: string; + arguments: + | NewPublicKeyArguments + | [keyServerId: RawTransactionArgument, pkBytes: RawTransactionArgument]; +} +/** Creates PublicKey from key server ID and public key bytes. */ +export function newPublicKey(options: NewPublicKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', 'vector'] satisfies (string | null)[]; + const parameterNames = ['keyServerId', 'pkBytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'new_public_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DecryptArguments { + encryptedObject: RawTransactionArgument; + verifiedDerivedKeys: RawTransactionArgument; + publicKeys: RawTransactionArgument; +} +export interface DecryptOptions { + package: string; + arguments: + | DecryptArguments + | [ + encryptedObject: RawTransactionArgument, + verifiedDerivedKeys: RawTransactionArgument, + publicKeys: RawTransactionArgument, + ]; +} +/** + * Decrypts an encrypted object using the given verified derived keys. + * + * Call `verify_derived_keys` to verify derived keys before calling this function. + * + * Aborts if there are not enough verified derived keys to reach the threshold. + * Aborts if any of the key servers for the given verified derived keys are not + * among the key servers found in the encrypted object. Aborts if the given public + * keys do not contain exactly one public key for all key servers in the encrypted + * object and no more. + * + * If the decryption fails, e.g. the AAD or MAC is invalid, the function returns + * `none`. + * + * If some key servers are weighted, each derived key contributes the weight of the + * key server to the threshold. The public keys can be in any order and there + * should be exactly one per key server. The provided verified derived keys can be + * in any order, but there should be at most one per key server. + */ +export function decrypt(options: DecryptOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['encryptedObject', 'verifiedDerivedKeys', 'publicKeys']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'decrypt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VerifyDerivedKeysArguments { + derivedKeys: RawTransactionArgument; + packageId: RawTransactionArgument; + id: RawTransactionArgument; + publicKeys: RawTransactionArgument; +} +export interface VerifyDerivedKeysOptions { + package: string; + arguments: + | VerifyDerivedKeysArguments + | [ + derivedKeys: RawTransactionArgument, + packageId: RawTransactionArgument, + id: RawTransactionArgument, + publicKeys: RawTransactionArgument, + ]; +} +/** + * Returns a vector of `VerifiedDerivedKey`s, asserting that all derived_keys are + * valid for the given full ID and key servers. The order of the derived keys and + * the public keys must match. Aborts if the number of key servers does not match + * the number of derived keys. + */ +export function verifyDerivedKeys(options: VerifyDerivedKeysOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'address', 'vector', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['derivedKeys', 'packageId', 'id', 'publicKeys']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'verify_derived_keys', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ParseEncryptedObjectArguments { + object: RawTransactionArgument; +} +export interface ParseEncryptedObjectOptions { + package: string; + arguments: ParseEncryptedObjectArguments | [object: RawTransactionArgument]; +} +/** + * Deserialize a BCS encoded EncryptedObject. Fails if the version is not 0. Fails + * if the object is not a valid EncryptedObject. Fails if the encryption type is + * not Hmac256Ctr. Fails if the KEM type is not Boneh-Franklin over BLS12-381. + */ +export function parseEncryptedObject(options: ParseEncryptedObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['object']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'parse_encrypted_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PackageIdArguments { + self: RawTransactionArgument; +} +export interface PackageIdOptions { + package: string; + arguments: PackageIdArguments | [self: RawTransactionArgument]; +} +export function packageId(options: PackageIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'package_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdArguments { + self: RawTransactionArgument; +} +export interface IdOptions { + package: string; + arguments: IdArguments | [self: RawTransactionArgument]; +} +export function id(options: IdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ServicesArguments { + self: RawTransactionArgument; +} +export interface ServicesOptions { + package: string; + arguments: ServicesArguments | [self: RawTransactionArgument]; +} +export function services(options: ServicesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'services', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IndicesArguments { + self: RawTransactionArgument; +} +export interface IndicesOptions { + package: string; + arguments: IndicesArguments | [self: RawTransactionArgument]; +} +export function indices(options: IndicesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'indices', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ThresholdArguments { + self: RawTransactionArgument; +} +export interface ThresholdOptions { + package: string; + arguments: ThresholdArguments | [self: RawTransactionArgument]; +} +export function threshold(options: ThresholdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'threshold', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NonceArguments { + self: RawTransactionArgument; +} +export interface NonceOptions { + package: string; + arguments: NonceArguments | [self: RawTransactionArgument]; +} +export function nonce(options: NonceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'nonce', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface EncryptedSharesArguments { + self: RawTransactionArgument; +} +export interface EncryptedSharesOptions { + package: string; + arguments: EncryptedSharesArguments | [self: RawTransactionArgument]; +} +export function encryptedShares(options: EncryptedSharesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'encrypted_shares', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface EncryptedRandomnessArguments { + self: RawTransactionArgument; +} +export interface EncryptedRandomnessOptions { + package: string; + arguments: EncryptedRandomnessArguments | [self: RawTransactionArgument]; +} +export function encryptedRandomness(options: EncryptedRandomnessOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'encrypted_randomness', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BlobArguments { + self: RawTransactionArgument; +} +export interface BlobOptions { + package: string; + arguments: BlobArguments | [self: RawTransactionArgument]; +} +export function blob(options: BlobOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'blob', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AadArguments { + self: RawTransactionArgument; +} +export interface AadOptions { + package: string; + arguments: AadArguments | [self: RawTransactionArgument]; +} +export function aad(options: AadOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'aad', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MacArguments { + self: RawTransactionArgument; +} +export interface MacOptions { + package: string; + arguments: MacArguments | [self: RawTransactionArgument]; +} +export function mac(options: MacOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bf_hmac_encryption', + function: 'mac', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts b/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts new file mode 100644 index 000000000..cb56b7fae --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts @@ -0,0 +1,217 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'seal::key_server'; +export const KeyServer = new MoveStruct({ + name: `${$moduleName}::KeyServer`, + fields: { + id: bcs.Address, + first_version: bcs.u64(), + last_version: bcs.u64(), + }, +}); +export const KeyServerV1 = new MoveStruct({ + name: `${$moduleName}::KeyServerV1`, + fields: { + name: bcs.string(), + url: bcs.string(), + key_type: bcs.u8(), + pk: bcs.vector(bcs.u8()), + }, +}); +export interface CreateAndTransferV1Arguments { + name: RawTransactionArgument; + url: RawTransactionArgument; + keyType: RawTransactionArgument; + pk: RawTransactionArgument; +} +export interface CreateAndTransferV1Options { + package: string; + arguments: + | CreateAndTransferV1Arguments + | [ + name: RawTransactionArgument, + url: RawTransactionArgument, + keyType: RawTransactionArgument, + pk: RawTransactionArgument, + ]; +} +export function createAndTransferV1(options: CreateAndTransferV1Options) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x1::string::String', + '0x1::string::String', + 'u8', + 'vector', + ] satisfies (string | null)[]; + const parameterNames = ['name', 'url', 'keyType', 'pk']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'create_and_transfer_v1', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface V1Arguments { + s: RawTransactionArgument; +} +export interface V1Options { + package: string; + arguments: V1Arguments | [s: RawTransactionArgument]; +} +export function v1(options: V1Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'v1', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NameArguments { + s: RawTransactionArgument; +} +export interface NameOptions { + package: string; + arguments: NameArguments | [s: RawTransactionArgument]; +} +export function name(options: NameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UrlArguments { + s: RawTransactionArgument; +} +export interface UrlOptions { + package: string; + arguments: UrlArguments | [s: RawTransactionArgument]; +} +export function url(options: UrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface KeyTypeArguments { + s: RawTransactionArgument; +} +export interface KeyTypeOptions { + package: string; + arguments: KeyTypeArguments | [s: RawTransactionArgument]; +} +export function keyType(options: KeyTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'key_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PkArguments { + s: RawTransactionArgument; +} +export interface PkOptions { + package: string; + arguments: PkArguments | [s: RawTransactionArgument]; +} +export function pk(options: PkOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'pk', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdArguments { + s: RawTransactionArgument; +} +export interface IdOptions { + package: string; + arguments: IdArguments | [s: RawTransactionArgument]; +} +export function id(options: IdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PkAsBfBls12381Arguments { + s: RawTransactionArgument; +} +export interface PkAsBfBls12381Options { + package: string; + arguments: PkAsBfBls12381Arguments | [s: RawTransactionArgument]; +} +export function pkAsBfBls12381(options: PkAsBfBls12381Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'pk_as_bf_bls12381', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateArguments { + s: RawTransactionArgument; + url: RawTransactionArgument; +} +export interface UpdateOptions { + package: string; + arguments: + | UpdateArguments + | [s: RawTransactionArgument, url: RawTransactionArgument]; +} +export function update(options: UpdateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s', 'url']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'key_server', + function: 'update', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts b/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts new file mode 100644 index 000000000..65ac6309d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts @@ -0,0 +1,40 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'seal::polynomial'; +export const Polynomial = new MoveStruct({ + name: `${$moduleName}::Polynomial`, + fields: { + coefficients: bcs.vector(bcs.u8()), + }, +}); +export interface EvaluateArguments { + p: RawTransactionArgument; + x: RawTransactionArgument; +} +export interface EvaluateOptions { + package: string; + arguments: + | EvaluateArguments + | [p: RawTransactionArgument, x: RawTransactionArgument]; +} +/** Evaluate a polynomial at a given point. */ +export function evaluate(options: EvaluateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8'] satisfies (string | null)[]; + const parameterNames = ['p', 'x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'polynomial', + function: 'evaluate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts new file mode 100644 index 000000000..a9272156c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts @@ -0,0 +1,24 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = '0x2::accumulator'; +export const AccumulatorRoot = new MoveStruct({ + name: `${$moduleName}::AccumulatorRoot`, + fields: { + id: bcs.Address, + }, +}); +export const U128 = new MoveStruct({ + name: `${$moduleName}::U128`, + fields: { + value: bcs.u128(), + }, +}); +export const Key = new MoveStruct({ + name: `${$moduleName}::Key`, + fields: { + address: bcs.Address, + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts new file mode 100644 index 000000000..4f172aebc --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts @@ -0,0 +1,32 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct, MoveTuple } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import * as bag from './bag.js'; +const $moduleName = '0x2::accumulator_metadata'; +export const OwnerKey = new MoveStruct({ + name: `${$moduleName}::OwnerKey`, + fields: { + owner: bcs.Address, + }, +}); +export const Owner = new MoveStruct({ + name: `${$moduleName}::Owner`, + fields: { + /** The individual balances owned by the owner. */ + balances: bag.Bag, + owner: bcs.Address, + }, +}); +export const MetadataKey = new MoveTuple({ + name: `${$moduleName}::MetadataKey`, + fields: [bcs.bool()], +}); +export const Metadata = new MoveStruct({ + name: `${$moduleName}::Metadata`, + fields: { + /** Any per-balance fields we wish to add in the future. */ + fields: bag.Bag, + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts new file mode 100644 index 000000000..5bbf2068b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts @@ -0,0 +1,17 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = '0x2::accumulator_settlement'; +export const EventStreamHead = new MoveStruct({ + name: `${$moduleName}::EventStreamHead`, + fields: { + /** Merkle Mountain Range of all events in the stream. */ + mmr: bcs.vector(bcs.u256()), + /** Checkpoint sequence number at which the event stream was written. */ + checkpoint_seq: bcs.u64(), + /** Number of events in the stream. */ + num_events: bcs.u64(), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/address.ts b/packages/suins/src/contracts/suins_auction/deps/sui/address.ts new file mode 100644 index 000000000..c9114fa1d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/address.ts @@ -0,0 +1,189 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface ToU256Arguments { + a: RawTransactionArgument; +} +export interface ToU256Options { + package: string; + arguments: ToU256Arguments | [a: RawTransactionArgument]; +} +/** + * Convert `a` into a u256 by interpreting `a` as the bytes of a big-endian integer + * (e.g., `to_u256(0x1) == 1`) + */ +export function toU256(options: ToU256Options) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'to_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromU256Arguments { + n: RawTransactionArgument; +} +export interface FromU256Options { + package: string; + arguments: FromU256Arguments | [n: RawTransactionArgument]; +} +/** + * Convert `n` into an address by encoding it as a big-endian integer (e.g., + * `from_u256(1) = @0x1`) Aborts if `n` > `MAX_ADDRESS` + */ +export function fromU256(options: FromU256Options) { + const packageAddress = options.package; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['n']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'from_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromBytesArguments { + bytes: RawTransactionArgument; +} +export interface FromBytesOptions { + package: string; + arguments: FromBytesArguments | [bytes: RawTransactionArgument]; +} +/** + * Convert `bytes` into an address. Aborts with `EAddressParseError` if the length + * of `bytes` is not 32 + */ +export function fromBytes(options: FromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToBytesArguments { + a: RawTransactionArgument; +} +export interface ToBytesOptions { + package: string; + arguments: ToBytesArguments | [a: RawTransactionArgument]; +} +/** Convert `a` into BCS-encoded bytes. */ +export function toBytes(options: ToBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToAsciiStringArguments { + a: RawTransactionArgument; +} +export interface ToAsciiStringOptions { + package: string; + arguments: ToAsciiStringArguments | [a: RawTransactionArgument]; +} +/** Convert `a` to a hex-encoded ASCII string */ +export function toAsciiString(options: ToAsciiStringOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'to_ascii_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + a: RawTransactionArgument; +} +export interface ToStringOptions { + package: string; + arguments: ToStringArguments | [a: RawTransactionArgument]; +} +/** Convert `a` to a hex-encoded string */ +export function toString(options: ToStringOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromAsciiBytesArguments { + bytes: RawTransactionArgument; +} +export interface FromAsciiBytesOptions { + package: string; + arguments: FromAsciiBytesArguments | [bytes: RawTransactionArgument]; +} +/** + * Converts an ASCII string to an address, taking the numerical value for each + * character. The string must be Base16 encoded, and thus exactly 64 characters + * long. For example, the string + * "00000000000000000000000000000000000000000000000000000000DEADB33F" will be + * converted to the address @0xDEADB33F. Aborts with `EAddressParseError` if the + * length of `s` is not 64, or if an invalid character is encountered. + */ +export function fromAsciiBytes(options: FromAsciiBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'from_ascii_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LengthOptions { + package: string; + arguments?: []; +} +/** Length of a Sui address in bytes */ +export function length(options: LengthOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'length', + }); +} +export interface MaxOptions { + package: string; + arguments?: []; +} +/** Largest possible address */ +export function max(options: MaxOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'address', + function: 'max', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts b/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts new file mode 100644 index 000000000..cdeed12f6 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts @@ -0,0 +1,45 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = '0x2::authenticator_state'; +export const AuthenticatorState = new MoveStruct({ + name: `${$moduleName}::AuthenticatorState`, + fields: { + id: bcs.Address, + version: bcs.u64(), + }, +}); +export const JwkId = new MoveStruct({ + name: `${$moduleName}::JwkId`, + fields: { + iss: bcs.string(), + kid: bcs.string(), + }, +}); +export const JWK = new MoveStruct({ + name: `${$moduleName}::JWK`, + fields: { + kty: bcs.string(), + e: bcs.string(), + n: bcs.string(), + alg: bcs.string(), + }, +}); +export const ActiveJwk = new MoveStruct({ + name: `${$moduleName}::ActiveJwk`, + fields: { + jwk_id: JwkId, + jwk: JWK, + epoch: bcs.u64(), + }, +}); +export const AuthenticatorStateInner = new MoveStruct({ + name: `${$moduleName}::AuthenticatorStateInner`, + fields: { + version: bcs.u64(), + /** List of currently active JWKs. */ + active_jwks: bcs.vector(ActiveJwk), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts new file mode 100644 index 000000000..d96ca431b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts @@ -0,0 +1,310 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A bag is a heterogeneous map-like collection. The collection is similar to + * `sui::table` in that its keys and values are not stored within the `Bag` value, + * but instead are stored using Sui's object system. The `Bag` struct acts only as + * a handle into the object system to retrieve those keys and values. Note that + * this means that `Bag` values with exactly the same key-value mapping will not be + * equal, with `==`, at runtime. For example + * + * ``` + * let bag1 = bag::new(); + * let bag2 = bag::new(); + * bag::add(&mut bag1, 0, false); + * bag::add(&mut bag1, 1, true); + * bag::add(&mut bag2, 0, false); + * bag::add(&mut bag2, 1, true); + * // bag1 does not equal bag2, despite having the same entries + * assert!(&bag1 != &bag2); + * ``` + * + * At it's core, `sui::bag` is a wrapper around `UID` that allows for access to + * `sui::dynamic_field` while preventing accidentally stranding field values. A + * `UID` can be deleted, even if it has dynamic fields associated with it, but a + * bag, on the other hand, must be empty to be destroyed. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::bag'; +export const Bag = new MoveStruct({ + name: `${$moduleName}::Bag`, + fields: { + /** the ID of this bag */ + id: bcs.Address, + /** the number of key-value pairs in the bag */ + size: bcs.u64(), + }, +}); +export interface NewOptions { + package: string; + arguments?: []; +} +/** Creates a new, empty bag */ +export function _new(options: NewOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'new', + }); +} +export interface AddArguments, V extends BcsType> { + bag: RawTransactionArgument; + k: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface AddOptions, V extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + bag: RawTransactionArgument, + k: RawTransactionArgument, + v: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a key-value pair to the bag `bag: &mut Bag` Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with + * that key `k: K`. + */ +export function add, V extends BcsType>(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['bag', 'k', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutable borrows the value associated with the key in the bag `bag: &Bag`. + * Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an + * entry with that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` + * if the bag has an entry for the key, but the value does not have the specified + * type. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the value associated with the key in the bag `bag: &mut Bag`. + * Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an + * entry with that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` + * if the bag has an entry for the key, but the value does not have the specified + * type. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the key-value pair in the bag `bag: &mut Bag` and returns the + * value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not + * have an entry with that key `k: K`. Aborts with + * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, + * but the value does not have the specified type. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns true iff there is an value associated with the key `k: K` in the bag + * `bag: &Bag` + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsWithTypeArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsWithTypeOptions> { + package: string; + arguments: + | ContainsWithTypeArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true iff there is an value associated with the key `k: K` in the bag + * `bag: &Bag` with an assigned value of type `V` + */ +export function containsWithType>(options: ContainsWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'contains_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + bag: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [bag: RawTransactionArgument]; +} +/** Returns the size of the bag, the number of key-value pairs */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsEmptyArguments { + bag: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [bag: RawTransactionArgument]; +} +/** Returns true iff the bag is empty (if `length` returns `0`) */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DestroyEmptyArguments { + bag: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [bag: RawTransactionArgument]; +} +/** + * Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains + * values + */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bag', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts b/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts new file mode 100644 index 000000000..7a08778f8 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts @@ -0,0 +1,306 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A storable handler for Balances in general. Is used in the `Coin` module to + * allow balance operations and can be used to implement custom coins with `Supply` + * and `Balance`s. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::balance'; +export const Supply = new MoveStruct({ + name: `${$moduleName}::Supply`, + fields: { + value: bcs.u64(), + }, +}); +export const Balance = new MoveStruct({ + name: `${$moduleName}::Balance`, + fields: { + value: bcs.u64(), + }, +}); +export interface ValueArguments { + self: RawTransactionArgument; +} +export interface ValueOptions { + package: string; + arguments: ValueArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the amount stored in a `Balance`. */ +export function value(options: ValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SupplyValueArguments { + supply: RawTransactionArgument; +} +export interface SupplyValueOptions { + package: string; + arguments: SupplyValueArguments | [supply: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `Supply` value. */ +export function supplyValue(options: SupplyValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['supply']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'supply_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateSupplyArguments> { + _: RawTransactionArgument; +} +export interface CreateSupplyOptions> { + package: string; + arguments: CreateSupplyArguments | [_: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a new supply for type T. */ +export function createSupply>(options: CreateSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'create_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IncreaseSupplyArguments { + self: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface IncreaseSupplyOptions { + package: string; + arguments: + | IncreaseSupplyArguments + | [self: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Increase supply by `value` and create a new `Balance` with this value. */ +export function increaseSupply(options: IncreaseSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'increase_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DecreaseSupplyArguments { + self: RawTransactionArgument; + balance: RawTransactionArgument; +} +export interface DecreaseSupplyOptions { + package: string; + arguments: + | DecreaseSupplyArguments + | [self: RawTransactionArgument, balance: RawTransactionArgument]; + typeArguments: [string]; +} +/** Burn a Balance and decrease Supply. */ +export function decreaseSupply(options: DecreaseSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'decrease_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ZeroOptions { + package: string; + arguments?: []; + typeArguments: [string]; +} +/** Create a zero `Balance` for type `T`. */ +export function zero(options: ZeroOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'zero', + typeArguments: options.typeArguments, + }); +} +export interface JoinArguments { + self: RawTransactionArgument; + balance: RawTransactionArgument; +} +export interface JoinOptions { + package: string; + arguments: + | JoinArguments + | [self: RawTransactionArgument, balance: RawTransactionArgument]; + typeArguments: [string]; +} +/** Join two balances together. */ +export function join(options: JoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'join', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitArguments { + self: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface SplitOptions { + package: string; + arguments: + | SplitArguments + | [self: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Split a `Balance` and take a sub balance from it. */ +export function split(options: SplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawAllArguments { + self: RawTransactionArgument; +} +export interface WithdrawAllOptions { + package: string; + arguments: WithdrawAllArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Withdraw all balance. After this the remaining balance must be 0. */ +export function withdrawAll(options: WithdrawAllOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'withdraw_all', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyZeroArguments { + balance: RawTransactionArgument; +} +export interface DestroyZeroOptions { + package: string; + arguments: DestroyZeroArguments | [balance: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy a zero `Balance`. */ +export function destroyZero(options: DestroyZeroOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'destroy_zero', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SendFundsArguments { + balance: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface SendFundsOptions { + package: string; + arguments: + | SendFundsArguments + | [balance: RawTransactionArgument, recipient: RawTransactionArgument]; + typeArguments: [string]; +} +/** Send a `Balance` to an address's funds accumulator. */ +export function sendFunds(options: SendFundsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['balance', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'send_funds', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RedeemFundsArguments { + withdrawal: RawTransactionArgument; +} +export interface RedeemFundsOptions { + package: string; + arguments: RedeemFundsArguments | [withdrawal: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Redeem a `Withdrawal>` to get the underlying `Balance` from an + * address's funds accumulator. + */ +export function redeemFunds(options: RedeemFundsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['withdrawal']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'balance', + function: 'redeem_funds', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts new file mode 100644 index 000000000..e934d9a19 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts @@ -0,0 +1,683 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * This module implements BCS (de)serialization in Move. Full specification can be + * found here: https://github.com/diem/bcs + * + * Short summary (for Move-supported types): + * + * - address - sequence of X bytes + * - bool - byte with 0 or 1 + * - u8 - a single u8 byte + * - u16 / u32 / u64 / u128 / u256 - LE bytes + * - vector - ULEB128 length + LEN elements + * - option - first byte bool: None (0) or Some (1), then value + * + * Usage example: + * + * ``` + * /// This function reads u8 and u64 value from the input + * /// and returns the rest of the bytes. + * fun deserialize(bytes: vector): (u8, u64, vector) { + * use sui::bcs::{Self, BCS}; + * + * let prepared: BCS = bcs::new(bytes); + * let (u8_value, u64_value) = ( + * prepared.peel_u8(), + * prepared.peel_u64() + * ); + * + * // unpack bcs struct + * let leftovers = prepared.into_remainder_bytes(); + * + * (u8_value, u64_value, leftovers) + * } + * ``` + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::bcs'; +export const BCS = new MoveStruct({ + name: `${$moduleName}::BCS`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export interface ToBytesArguments> { + value: RawTransactionArgument; +} +export interface ToBytesOptions> { + package: string; + arguments: ToBytesArguments | [value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get BCS serialized bytes for any value. Re-exports stdlib `bcs::to_bytes`. */ +export function toBytes>(options: ToBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewArguments { + bytes: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [bytes: RawTransactionArgument]; +} +/** + * Creates a new instance of BCS wrapper that holds inversed bytes for better + * performance. + */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntoRemainderBytesArguments { + bcs: RawTransactionArgument; +} +export interface IntoRemainderBytesOptions { + package: string; + arguments: IntoRemainderBytesArguments | [bcs: RawTransactionArgument]; +} +/** + * Unpack the `BCS` struct returning the leftover bytes. Useful for passing the + * data further after partial deserialization. + */ +export function intoRemainderBytes(options: IntoRemainderBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'into_remainder_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelAddressArguments { + bcs: RawTransactionArgument; +} +export interface PeelAddressOptions { + package: string; + arguments: PeelAddressArguments | [bcs: RawTransactionArgument]; +} +/** Read address from the bcs-serialized bytes. */ +export function peelAddress(options: PeelAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelBoolArguments { + bcs: RawTransactionArgument; +} +export interface PeelBoolOptions { + package: string; + arguments: PeelBoolArguments | [bcs: RawTransactionArgument]; +} +/** Read a `bool` value from bcs-serialized bytes. */ +export function peelBool(options: PeelBoolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_bool', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU8Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU8Options { + package: string; + arguments: PeelU8Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u8` value from bcs-serialized bytes. */ +export function peelU8(options: PeelU8Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU16Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU16Options { + package: string; + arguments: PeelU16Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u16` value from bcs-serialized bytes. */ +export function peelU16(options: PeelU16Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU32Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU32Options { + package: string; + arguments: PeelU32Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u32` value from bcs-serialized bytes. */ +export function peelU32(options: PeelU32Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU64Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU64Options { + package: string; + arguments: PeelU64Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u64` value from bcs-serialized bytes. */ +export function peelU64(options: PeelU64Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU128Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU128Options { + package: string; + arguments: PeelU128Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u128` value from bcs-serialized bytes. */ +export function peelU128(options: PeelU128Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelU256Arguments { + bcs: RawTransactionArgument; +} +export interface PeelU256Options { + package: string; + arguments: PeelU256Arguments | [bcs: RawTransactionArgument]; +} +/** Read `u256` value from bcs-serialized bytes. */ +export function peelU256(options: PeelU256Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecLengthArguments { + bcs: RawTransactionArgument; +} +export interface PeelVecLengthOptions { + package: string; + arguments: PeelVecLengthArguments | [bcs: RawTransactionArgument]; +} +/** + * Read ULEB bytes expecting a vector length. Result should then be used to perform + * `peel_*` operation LEN times. + * + * In BCS `vector` length is implemented with ULEB128; See more here: + * https://en.wikipedia.org/wiki/LEB128 + */ +export function peelVecLength(options: PeelVecLengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecAddressArguments { + bcs: RawTransactionArgument; +} +export interface PeelVecAddressOptions { + package: string; + arguments: PeelVecAddressArguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `address` from serialized bytes. */ +export function peelVecAddress(options: PeelVecAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecBoolArguments { + bcs: RawTransactionArgument; +} +export interface PeelVecBoolOptions { + package: string; + arguments: PeelVecBoolArguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `address` from serialized bytes. */ +export function peelVecBool(options: PeelVecBoolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_bool', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU8Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU8Options { + package: string; + arguments: PeelVecU8Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u8` (eg string) from serialized bytes. */ +export function peelVecU8(options: PeelVecU8Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecVecU8Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecVecU8Options { + package: string; + arguments: PeelVecVecU8Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a `vector>` (eg vec of string) from serialized bytes. */ +export function peelVecVecU8(options: PeelVecVecU8Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_vec_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU16Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU16Options { + package: string; + arguments: PeelVecU16Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u16` from serialized bytes. */ +export function peelVecU16(options: PeelVecU16Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU32Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU32Options { + package: string; + arguments: PeelVecU32Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u32` from serialized bytes. */ +export function peelVecU32(options: PeelVecU32Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU64Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU64Options { + package: string; + arguments: PeelVecU64Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u64` from serialized bytes. */ +export function peelVecU64(options: PeelVecU64Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU128Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU128Options { + package: string; + arguments: PeelVecU128Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u128` from serialized bytes. */ +export function peelVecU128(options: PeelVecU128Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelVecU256Arguments { + bcs: RawTransactionArgument; +} +export interface PeelVecU256Options { + package: string; + arguments: PeelVecU256Arguments | [bcs: RawTransactionArgument]; +} +/** Peel a vector of `u256` from serialized bytes. */ +export function peelVecU256(options: PeelVecU256Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_vec_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelEnumTagArguments { + bcs: RawTransactionArgument; +} +export interface PeelEnumTagOptions { + package: string; + arguments: PeelEnumTagArguments | [bcs: RawTransactionArgument]; +} +/** + * Peel enum from serialized bytes, where `$f` takes a `tag` value and returns the + * corresponding enum variant. Move enums are limited to 127 variants, however the + * tag can be any `u32` value. + * + * Example: + * + * ```rust + * let my_enum = match (bcs.peel_enum_tag()) { + * 0 => Enum::Empty, + * 1 => Enum::U8(bcs.peel_u8()), + * 2 => Enum::U16(bcs.peel_u16()), + * 3 => Enum::Struct { a: bcs.peel_address(), b: bcs.peel_u8() }, + * _ => abort, + * }; + * ``` + */ +export function peelEnumTag(options: PeelEnumTagOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_enum_tag', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionAddressArguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionAddressOptions { + package: string; + arguments: PeelOptionAddressArguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option
` from serialized bytes. */ +export function peelOptionAddress(options: PeelOptionAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionBoolArguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionBoolOptions { + package: string; + arguments: PeelOptionBoolArguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionBool(options: PeelOptionBoolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_bool', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU8Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU8Options { + package: string; + arguments: PeelOptionU8Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU8(options: PeelOptionU8Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU16Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU16Options { + package: string; + arguments: PeelOptionU16Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU16(options: PeelOptionU16Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU32Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU32Options { + package: string; + arguments: PeelOptionU32Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU32(options: PeelOptionU32Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU64Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU64Options { + package: string; + arguments: PeelOptionU64Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU64(options: PeelOptionU64Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU128Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU128Options { + package: string; + arguments: PeelOptionU128Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU128(options: PeelOptionU128Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PeelOptionU256Arguments { + bcs: RawTransactionArgument; +} +export interface PeelOptionU256Options { + package: string; + arguments: PeelOptionU256Arguments | [bcs: RawTransactionArgument]; +} +/** Peel `Option` from serialized bytes. */ +export function peelOptionU256(options: PeelOptionU256Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bcs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bcs', + function: 'peel_option_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts new file mode 100644 index 000000000..55f44534e --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts @@ -0,0 +1,929 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Group operations of BLS12-381. */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::bls12381'; +export const Scalar = new MoveStruct({ + name: `${$moduleName}::Scalar`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const G1 = new MoveStruct({ + name: `${$moduleName}::G1`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const G2 = new MoveStruct({ + name: `${$moduleName}::G2`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const GT = new MoveStruct({ + name: `${$moduleName}::GT`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const UncompressedG1 = new MoveStruct({ + name: `${$moduleName}::UncompressedG1`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface Bls12381MinSigVerifyArguments { + signature: RawTransactionArgument; + publicKey: RawTransactionArgument; + msg: RawTransactionArgument; +} +export interface Bls12381MinSigVerifyOptions { + package: string; + arguments: + | Bls12381MinSigVerifyArguments + | [ + signature: RawTransactionArgument, + publicKey: RawTransactionArgument, + msg: RawTransactionArgument, + ]; +} +/** + * @param signature: A 48-bytes signature that is a point on the G1 subgroup. + * @param public_key: A 96-bytes public key that is a point on the G2 subgroup. + * @param msg: The message that we test the signature against. + * + * If the signature is a valid signature of the message and public key according to + * BLS*SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL*, return true. Otherwise, return + * false. + */ +export function bls12381MinSigVerify(options: Bls12381MinSigVerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['signature', 'publicKey', 'msg']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'bls12381_min_sig_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface Bls12381MinPkVerifyArguments { + signature: RawTransactionArgument; + publicKey: RawTransactionArgument; + msg: RawTransactionArgument; +} +export interface Bls12381MinPkVerifyOptions { + package: string; + arguments: + | Bls12381MinPkVerifyArguments + | [ + signature: RawTransactionArgument, + publicKey: RawTransactionArgument, + msg: RawTransactionArgument, + ]; +} +/** + * @param signature: A 96-bytes signature that is a point on the G2 subgroup. + * @param public_key: A 48-bytes public key that is a point on the G1 subgroup. + * @param msg: The message that we test the signature against. + * + * If the signature is a valid signature of the message and public key according to + * BLS*SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL*, return true. Otherwise, return + * false. + */ +export function bls12381MinPkVerify(options: Bls12381MinPkVerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['signature', 'publicKey', 'msg']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'bls12381_min_pk_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarFromBytesArguments { + bytes: RawTransactionArgument; +} +export interface ScalarFromBytesOptions { + package: string; + arguments: ScalarFromBytesArguments | [bytes: RawTransactionArgument]; +} +export function scalarFromBytes(options: ScalarFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarFromU64Arguments { + x: RawTransactionArgument; +} +export interface ScalarFromU64Options { + package: string; + arguments: ScalarFromU64Arguments | [x: RawTransactionArgument]; +} +export function scalarFromU64(options: ScalarFromU64Options) { + const packageAddress = options.package; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_from_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarZeroOptions { + package: string; + arguments?: []; +} +export function scalarZero(options: ScalarZeroOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_zero', + }); +} +export interface ScalarOneOptions { + package: string; + arguments?: []; +} +export function scalarOne(options: ScalarOneOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_one', + }); +} +export interface ScalarAddArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface ScalarAddOptions { + package: string; + arguments: + | ScalarAddArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function scalarAdd(options: ScalarAddOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarSubArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface ScalarSubOptions { + package: string; + arguments: + | ScalarSubArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function scalarSub(options: ScalarSubOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarMulArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface ScalarMulOptions { + package: string; + arguments: + | ScalarMulArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function scalarMul(options: ScalarMulOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarDivArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface ScalarDivOptions { + package: string; + arguments: + | ScalarDivArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +/** Returns e2/e1, fails if a is zero. */ +export function scalarDiv(options: ScalarDivOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarNegArguments { + e: RawTransactionArgument; +} +export interface ScalarNegOptions { + package: string; + arguments: ScalarNegArguments | [e: RawTransactionArgument]; +} +export function scalarNeg(options: ScalarNegOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_neg', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ScalarInvArguments { + e: RawTransactionArgument; +} +export interface ScalarInvOptions { + package: string; + arguments: ScalarInvArguments | [e: RawTransactionArgument]; +} +export function scalarInv(options: ScalarInvOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'scalar_inv', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1FromBytesArguments { + bytes: RawTransactionArgument; +} +export interface G1FromBytesOptions { + package: string; + arguments: G1FromBytesArguments | [bytes: RawTransactionArgument]; +} +export function g1FromBytes(options: G1FromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1IdentityOptions { + package: string; + arguments?: []; +} +export function g1Identity(options: G1IdentityOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_identity', + }); +} +export interface G1GeneratorOptions { + package: string; + arguments?: []; +} +export function g1Generator(options: G1GeneratorOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_generator', + }); +} +export interface G1AddArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G1AddOptions { + package: string; + arguments: + | G1AddArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g1Add(options: G1AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1SubArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G1SubOptions { + package: string; + arguments: + | G1SubArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g1Sub(options: G1SubOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1MulArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G1MulOptions { + package: string; + arguments: + | G1MulArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g1Mul(options: G1MulOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1DivArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G1DivOptions { + package: string; + arguments: + | G1DivArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +/** Returns e2 / e1, fails if scalar is zero. */ +export function g1Div(options: G1DivOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1NegArguments { + e: RawTransactionArgument; +} +export interface G1NegOptions { + package: string; + arguments: G1NegArguments | [e: RawTransactionArgument]; +} +export function g1Neg(options: G1NegOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_neg', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HashToG1Arguments { + m: RawTransactionArgument; +} +export interface HashToG1Options { + package: string; + arguments: HashToG1Arguments | [m: RawTransactionArgument]; +} +/** Hash using DST = BLS*SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL* */ +export function hashToG1(options: HashToG1Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['m']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'hash_to_g1', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1MultiScalarMultiplicationArguments { + scalars: RawTransactionArgument; + elements: RawTransactionArgument; +} +export interface G1MultiScalarMultiplicationOptions { + package: string; + arguments: + | G1MultiScalarMultiplicationArguments + | [scalars: RawTransactionArgument, elements: RawTransactionArgument]; +} +/** + * Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, + * e2, ..., en]. Returns s1*e1 + s2*e2 + ... + sn\*en. Aborts with `EInputTooLong` + * if the vectors are larger than 32 (may increase in the future). + */ +export function g1MultiScalarMultiplication(options: G1MultiScalarMultiplicationOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['scalars', 'elements']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_multi_scalar_multiplication', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G1ToUncompressedG1Arguments { + e: RawTransactionArgument; +} +export interface G1ToUncompressedG1Options { + package: string; + arguments: G1ToUncompressedG1Arguments | [e: RawTransactionArgument]; +} +/** Convert an `Element` to uncompressed form. */ +export function g1ToUncompressedG1(options: G1ToUncompressedG1Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g1_to_uncompressed_g1', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2FromBytesArguments { + bytes: RawTransactionArgument; +} +export interface G2FromBytesOptions { + package: string; + arguments: G2FromBytesArguments | [bytes: RawTransactionArgument]; +} +export function g2FromBytes(options: G2FromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2IdentityOptions { + package: string; + arguments?: []; +} +export function g2Identity(options: G2IdentityOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_identity', + }); +} +export interface G2GeneratorOptions { + package: string; + arguments?: []; +} +export function g2Generator(options: G2GeneratorOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_generator', + }); +} +export interface G2AddArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G2AddOptions { + package: string; + arguments: + | G2AddArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g2Add(options: G2AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2SubArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G2SubOptions { + package: string; + arguments: + | G2SubArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g2Sub(options: G2SubOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2MulArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G2MulOptions { + package: string; + arguments: + | G2MulArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function g2Mul(options: G2MulOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2DivArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface G2DivOptions { + package: string; + arguments: + | G2DivArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +/** Returns e2 / e1, fails if scalar is zero. */ +export function g2Div(options: G2DivOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2NegArguments { + e: RawTransactionArgument; +} +export interface G2NegOptions { + package: string; + arguments: G2NegArguments | [e: RawTransactionArgument]; +} +export function g2Neg(options: G2NegOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_neg', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HashToG2Arguments { + m: RawTransactionArgument; +} +export interface HashToG2Options { + package: string; + arguments: HashToG2Arguments | [m: RawTransactionArgument]; +} +/** Hash using DST = BLS*SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL* */ +export function hashToG2(options: HashToG2Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['m']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'hash_to_g2', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface G2MultiScalarMultiplicationArguments { + scalars: RawTransactionArgument; + elements: RawTransactionArgument; +} +export interface G2MultiScalarMultiplicationOptions { + package: string; + arguments: + | G2MultiScalarMultiplicationArguments + | [scalars: RawTransactionArgument, elements: RawTransactionArgument]; +} +/** + * Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, + * e2, ..., en]. Returns s1*e1 + s2*e2 + ... + sn\*en. Aborts with `EInputTooLong` + * if the vectors are larger than 32 (may increase in the future). + */ +export function g2MultiScalarMultiplication(options: G2MultiScalarMultiplicationOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['scalars', 'elements']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'g2_multi_scalar_multiplication', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtIdentityOptions { + package: string; + arguments?: []; +} +export function gtIdentity(options: GtIdentityOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_identity', + }); +} +export interface GtGeneratorOptions { + package: string; + arguments?: []; +} +export function gtGenerator(options: GtGeneratorOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_generator', + }); +} +export interface GtAddArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface GtAddOptions { + package: string; + arguments: + | GtAddArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function gtAdd(options: GtAddOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtSubArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface GtSubOptions { + package: string; + arguments: + | GtSubArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function gtSub(options: GtSubOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtMulArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface GtMulOptions { + package: string; + arguments: + | GtMulArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function gtMul(options: GtMulOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtDivArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface GtDivOptions { + package: string; + arguments: + | GtDivArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +/** Returns e2 / e1, fails if scalar is zero. */ +export function gtDiv(options: GtDivOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtNegArguments { + e: RawTransactionArgument; +} +export interface GtNegOptions { + package: string; + arguments: GtNegArguments | [e: RawTransactionArgument]; +} +export function gtNeg(options: GtNegOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'gt_neg', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PairingArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface PairingOptions { + package: string; + arguments: + | PairingArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; +} +export function pairing(options: PairingOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'pairing', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UncompressedG1ToG1Arguments { + e: RawTransactionArgument; +} +export interface UncompressedG1ToG1Options { + package: string; + arguments: UncompressedG1ToG1Arguments | [e: RawTransactionArgument]; +} +/** + * UncompressedG1 group operations /// Create a `Element` from its uncompressed + * form. + */ +export function uncompressedG1ToG1(options: UncompressedG1ToG1Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'uncompressed_g1_to_g1', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UncompressedG1SumArguments { + terms: RawTransactionArgument; +} +export interface UncompressedG1SumOptions { + package: string; + arguments: UncompressedG1SumArguments | [terms: RawTransactionArgument]; +} +/** + * Compute the sum of a list of uncompressed elements. This is significantly faster + * and cheaper than summing the elements. + */ +export function uncompressedG1Sum(options: UncompressedG1SumOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['terms']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'bls12381', + function: 'uncompressed_g1_sum', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts b/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts new file mode 100644 index 000000000..7a2dd270c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts @@ -0,0 +1,133 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A simple library that enables hot-potato-locked borrow mechanics. + * + * With Programmable transactions, it is possible to borrow a value within a + * transaction, use it and put back in the end. Hot-potato `Borrow` makes sure the + * object is returned and was not swapped for another one. + */ + +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::borrow'; +/** An object wrapping a `T` and providing the borrow API. */ +export function Referent>(...typeParameters: [T]) { + return new MoveStruct({ + name: `${$moduleName}::Referent<${typeParameters[0].name as T['name']}>`, + fields: { + id: bcs.Address, + value: bcs.option(typeParameters[0]), + }, + }); +} +export const Borrow = new MoveStruct({ + name: `${$moduleName}::Borrow`, + fields: { + ref: bcs.Address, + obj: bcs.Address, + }, +}); +export interface NewArguments> { + value: RawTransactionArgument; +} +export interface NewOptions> { + package: string; + arguments: NewArguments | [value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a new `Referent` struct */ +export function _new>(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'borrow', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments { + self: RawTransactionArgument; +} +export interface BorrowOptions { + package: string; + arguments: BorrowArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Borrow the `T` from the `Referent`, receiving the `T` and a `Borrow` hot potato. */ +export function borrow(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'borrow', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PutBackArguments> { + self: RawTransactionArgument; + value: RawTransactionArgument; + borrow: RawTransactionArgument; +} +export interface PutBackOptions> { + package: string; + arguments: + | PutBackArguments + | [ + self: RawTransactionArgument, + value: RawTransactionArgument, + borrow: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Put an object and the `Borrow` hot potato back. */ +export function putBack>(options: PutBackOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['self', 'value', 'borrow']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'borrow', + function: 'put_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyArguments { + self: RawTransactionArgument; +} +export interface DestroyOptions { + package: string; + arguments: DestroyArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Unpack the `Referent` struct and return the value. */ +export function destroy(options: DestroyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'borrow', + function: 'destroy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts b/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts new file mode 100644 index 000000000..ece3b1ba9 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts @@ -0,0 +1,46 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * APIs for accessing time from move calls, via the `Clock`: a unique shared object + * that is created at 0x6 during genesis. + */ + +import { MoveStruct, normalizeMoveArguments } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::clock'; +export const Clock = new MoveStruct({ + name: `${$moduleName}::Clock`, + fields: { + id: bcs.Address, + /** + * The clock's timestamp, which is set automatically by a system transaction every + * time consensus commits a schedule, or by `sui::clock::increment_for_testing` + * during testing. + */ + timestamp_ms: bcs.u64(), + }, +}); +export interface TimestampMsArguments {} +export interface TimestampMsOptions { + package: string; + arguments?: TimestampMsArguments | []; +} +/** + * The `clock`'s current timestamp as a running total of milliseconds since an + * arbitrary point in the past. + */ +export function timestampMs(options: TimestampMsOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'clock', + function: 'timestamp_ms', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts b/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts new file mode 100644 index 000000000..e252f9252 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts @@ -0,0 +1,1348 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the `Coin` type - platform wide representation of fungible tokens and + * coins. `Coin` can be described as a secure wrapper around `Balance` type. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance_1 from './balance.js'; +import * as url from './url.js'; +const $moduleName = '0x2::coin'; +export const Coin = new MoveStruct({ + name: `${$moduleName}::Coin`, + fields: { + id: bcs.Address, + balance: balance_1.Balance, + }, +}); +export const CoinMetadata = new MoveStruct({ + name: `${$moduleName}::CoinMetadata`, + fields: { + id: bcs.Address, + /** + * Number of decimal places the coin uses. A coin with `value ` N and `decimals` D + * should be shown as N / 10^D E.g., a coin with `value` 7002 and decimals 3 should + * be displayed as 7.002 This is metadata for display usage only. + */ + decimals: bcs.u8(), + /** Name for the token */ + name: bcs.string(), + /** Symbol for the token */ + symbol: bcs.string(), + /** Description of the token */ + description: bcs.string(), + /** URL for the token logo */ + icon_url: bcs.option(url.Url), + }, +}); +export const RegulatedCoinMetadata = new MoveStruct({ + name: `${$moduleName}::RegulatedCoinMetadata`, + fields: { + id: bcs.Address, + /** The ID of the coin's CoinMetadata object. */ + coin_metadata_object: bcs.Address, + /** The ID of the coin's DenyCap object. */ + deny_cap_object: bcs.Address, + }, +}); +export const TreasuryCap = new MoveStruct({ + name: `${$moduleName}::TreasuryCap`, + fields: { + id: bcs.Address, + total_supply: balance_1.Supply, + }, +}); +export const DenyCapV2 = new MoveStruct({ + name: `${$moduleName}::DenyCapV2`, + fields: { + id: bcs.Address, + allow_global_pause: bcs.bool(), + }, +}); +export const CurrencyCreated = new MoveStruct({ + name: `${$moduleName}::CurrencyCreated`, + fields: { + decimals: bcs.u8(), + }, +}); +export const DenyCap = new MoveStruct({ + name: `${$moduleName}::DenyCap`, + fields: { + id: bcs.Address, + }, +}); +export interface TotalSupplyArguments { + cap: RawTransactionArgument; +} +export interface TotalSupplyOptions { + package: string; + arguments: TotalSupplyArguments | [cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the total number of `T`'s in circulation. */ +export function totalSupply(options: TotalSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'total_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TreasuryIntoSupplyArguments { + treasury: RawTransactionArgument; +} +export interface TreasuryIntoSupplyOptions { + package: string; + arguments: TreasuryIntoSupplyArguments | [treasury: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Unwrap `TreasuryCap` getting the `Supply`. + * + * Operation is irreversible. Supply cannot be converted into a `TreasuryCap` due + * to different security guarantees (TreasuryCap can be created only once for a + * type) + */ +export function treasuryIntoSupply(options: TreasuryIntoSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['treasury']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'treasury_into_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SupplyImmutArguments { + treasury: RawTransactionArgument; +} +export interface SupplyImmutOptions { + package: string; + arguments: SupplyImmutArguments | [treasury: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get immutable reference to the treasury's `Supply`. */ +export function supplyImmut(options: SupplyImmutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['treasury']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'supply_immut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SupplyMutArguments { + treasury: RawTransactionArgument; +} +export interface SupplyMutOptions { + package: string; + arguments: SupplyMutArguments | [treasury: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get mutable reference to the treasury's `Supply`. */ +export function supplyMut(options: SupplyMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['treasury']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'supply_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ValueArguments { + self: RawTransactionArgument; +} +export interface ValueOptions { + package: string; + arguments: ValueArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Public getter for the coin's value */ +export function value(options: ValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BalanceArguments { + coin: RawTransactionArgument; +} +export interface BalanceOptions { + package: string; + arguments: BalanceArguments | [coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get immutable reference to the balance of a coin. */ +export function balance(options: BalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BalanceMutArguments { + coin: RawTransactionArgument; +} +export interface BalanceMutOptions { + package: string; + arguments: BalanceMutArguments | [coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get a mutable reference to the balance of a coin. */ +export function balanceMut(options: BalanceMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'balance_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromBalanceArguments { + balance: RawTransactionArgument; +} +export interface FromBalanceOptions { + package: string; + arguments: FromBalanceArguments | [balance: RawTransactionArgument]; + typeArguments: [string]; +} +/** Wrap a balance into a Coin to make it transferable. */ +export function fromBalance(options: FromBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'from_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IntoBalanceArguments { + coin: RawTransactionArgument; +} +export interface IntoBalanceOptions { + package: string; + arguments: IntoBalanceArguments | [coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destruct a Coin wrapper and keep the balance. */ +export function intoBalance(options: IntoBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'into_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TakeArguments { + balance: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface TakeOptions { + package: string; + arguments: + | TakeArguments + | [balance: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Take a `Coin` worth of `value` from `Balance`. Aborts if `value > balance.value` */ +export function take(options: TakeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['balance', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'take', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PutArguments { + balance: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface PutOptions { + package: string; + arguments: + | PutArguments + | [balance: RawTransactionArgument, coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** Put a `Coin` to the `Balance`. */ +export function put(options: PutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['balance', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'put', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RedeemFundsArguments { + withdrawal: RawTransactionArgument; +} +export interface RedeemFundsOptions { + package: string; + arguments: RedeemFundsArguments | [withdrawal: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Redeem a `Withdrawal>` and create a `Coin` from the withdrawn + * Balance. + */ +export function redeemFunds(options: RedeemFundsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['withdrawal']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'redeem_funds', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SendFundsArguments { + coin: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface SendFundsOptions { + package: string; + arguments: + | SendFundsArguments + | [coin: RawTransactionArgument, recipient: RawTransactionArgument]; + typeArguments: [string]; +} +/** Send a coin to an address balance */ +export function sendFunds(options: SendFundsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['coin', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'send_funds', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface JoinArguments { + self: RawTransactionArgument; + c: RawTransactionArgument; +} +export interface JoinOptions { + package: string; + arguments: + | JoinArguments + | [self: RawTransactionArgument, c: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Consume the coin `c` and add its value to `self`. Aborts if + * `c.value + self.value > U64_MAX` + */ +export function join(options: JoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'c']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'join', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitArguments { + self: RawTransactionArgument; + splitAmount: RawTransactionArgument; +} +export interface SplitOptions { + package: string; + arguments: + | SplitArguments + | [self: RawTransactionArgument, splitAmount: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Split coin `self` to two coins, one with balance `split_amount`, and the + * remaining balance is left is `self`. + */ +export function split(options: SplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'splitAmount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DivideIntoNArguments { + self: RawTransactionArgument; + n: RawTransactionArgument; +} +export interface DivideIntoNOptions { + package: string; + arguments: + | DivideIntoNArguments + | [self: RawTransactionArgument, n: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Split coin `self` into `n - 1` coins with equal balances. The remainder is left + * in `self`. Return newly created coins. + */ +export function divideIntoN(options: DivideIntoNOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'n']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'divide_into_n', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ZeroOptions { + package: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Make any Coin with a zero value. Useful for placeholding bids/payments or + * preemptively making empty balances. + */ +export function zero(options: ZeroOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'zero', + typeArguments: options.typeArguments, + }); +} +export interface DestroyZeroArguments { + c: RawTransactionArgument; +} +export interface DestroyZeroOptions { + package: string; + arguments: DestroyZeroArguments | [c: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy a coin with value zero */ +export function destroyZero(options: DestroyZeroOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['c']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'destroy_zero', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateCurrencyArguments> { + witness: RawTransactionArgument; + decimals: RawTransactionArgument; + symbol: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + iconUrl: RawTransactionArgument; +} +export interface CreateCurrencyOptions> { + package: string; + arguments: + | CreateCurrencyArguments + | [ + witness: RawTransactionArgument, + decimals: RawTransactionArgument, + symbol: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + iconUrl: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Create a new currency type `T` as and return the `TreasuryCap` for `T` to the + * caller. Can only be called with a `one-time-witness` type, ensuring that there's + * only one `TreasuryCap` per `T`. + */ +export function createCurrency>(options: CreateCurrencyOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + 'u8', + 'vector', + 'vector', + 'vector', + '0x1::option::Option', + ] satisfies (string | null)[]; + const parameterNames = ['witness', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'create_currency', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateRegulatedCurrencyV2Arguments> { + witness: RawTransactionArgument; + decimals: RawTransactionArgument; + symbol: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + iconUrl: RawTransactionArgument; + allowGlobalPause: RawTransactionArgument; +} +export interface CreateRegulatedCurrencyV2Options> { + package: string; + arguments: + | CreateRegulatedCurrencyV2Arguments + | [ + witness: RawTransactionArgument, + decimals: RawTransactionArgument, + symbol: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + iconUrl: RawTransactionArgument, + allowGlobalPause: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * This creates a new currency, via `create_currency`, but with an extra capability + * that allows for specific addresses to have their coins frozen. When an address + * is added to the deny list, it is immediately unable to interact with the + * currency's coin as input objects. Additionally at the start of the next epoch, + * they will be unable to receive the currency's coin. The `allow_global_pause` + * flag enables an additional API that will cause all addresses to be denied. Note + * however, that this doesn't affect per-address entries of the deny list and will + * not change the result of the "contains" APIs. + */ +export function createRegulatedCurrencyV2>( + options: CreateRegulatedCurrencyV2Options, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + 'u8', + 'vector', + 'vector', + 'vector', + '0x1::option::Option', + 'bool', + ] satisfies (string | null)[]; + const parameterNames = [ + 'witness', + 'decimals', + 'symbol', + 'name', + 'description', + 'iconUrl', + 'allowGlobalPause', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'create_regulated_currency_v2', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MigrateRegulatedCurrencyToV2Arguments { + cap: RawTransactionArgument; + allowGlobalPause: RawTransactionArgument; +} +export interface MigrateRegulatedCurrencyToV2Options { + package: string; + arguments: + | MigrateRegulatedCurrencyToV2Arguments + | [cap: RawTransactionArgument, allowGlobalPause: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Given the `DenyCap` for a regulated currency, migrate it to the new `DenyCapV2` + * type. All entries in the deny list will be migrated to the new format. See + * `create_regulated_currency_v2` for details on the new v2 of the deny list. + */ +export function migrateRegulatedCurrencyToV2(options: MigrateRegulatedCurrencyToV2Options) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null, 'bool'] satisfies (string | null)[]; + const parameterNames = ['cap', 'allowGlobalPause']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'migrate_regulated_currency_to_v2', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MintArguments { + cap: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface MintOptions { + package: string; + arguments: + | MintArguments + | [cap: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a coin worth `value` and increase the total supply in `cap` accordingly. */ +export function mint(options: MintOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['cap', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'mint', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MintBalanceArguments { + cap: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface MintBalanceOptions { + package: string; + arguments: + | MintBalanceArguments + | [cap: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Mint some amount of T as a `Balance` and increase the total supply in `cap` + * accordingly. Aborts if `value` + `cap.total_supply` >= U64_MAX + */ +export function mintBalance(options: MintBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['cap', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'mint_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BurnArguments { + cap: RawTransactionArgument; + c: RawTransactionArgument; +} +export interface BurnOptions { + package: string; + arguments: + | BurnArguments + | [cap: RawTransactionArgument, c: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy the coin `c` and decrease the total supply in `cap` accordingly. */ +export function burn(options: BurnOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['cap', 'c']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'burn', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2AddArguments { + DenyCap: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface DenyListV2AddOptions { + package: string; + arguments: + | DenyListV2AddArguments + | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Adds the given address to the deny list, preventing it from interacting with the + * specified coin type as an input to a transaction. Additionally at the start of + * the next epoch, the address will be unable to receive objects of this coin type. + */ +export function denyListV2Add(options: DenyListV2AddOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; + const parameterNames = ['DenyCap', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2RemoveArguments { + DenyCap: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface DenyListV2RemoveOptions { + package: string; + arguments: + | DenyListV2RemoveArguments + | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Removes an address from the deny list. Similar to `deny_list_v2_add`, the effect + * for input objects will be immediate, but the effect for receiving objects will + * be delayed until the next epoch. + */ +export function denyListV2Remove(options: DenyListV2RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; + const parameterNames = ['DenyCap', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2ContainsCurrentEpochArguments { + addr: RawTransactionArgument; +} +export interface DenyListV2ContainsCurrentEpochOptions { + package: string; + arguments: DenyListV2ContainsCurrentEpochArguments | [addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Check if the deny list contains the given address for the current epoch. Denied + * addresses in the current epoch will be unable to receive objects of this coin + * type. + */ +export function denyListV2ContainsCurrentEpoch(options: DenyListV2ContainsCurrentEpochOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; + const parameterNames = ['addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_contains_current_epoch', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2ContainsNextEpochArguments { + addr: RawTransactionArgument; +} +export interface DenyListV2ContainsNextEpochOptions { + package: string; + arguments: DenyListV2ContainsNextEpochArguments | [addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Check if the deny list contains the given address for the next epoch. Denied + * addresses in the next epoch will immediately be unable to use objects of this + * coin type as inputs. At the start of the next epoch, the address will be unable + * to receive objects of this coin type. + */ +export function denyListV2ContainsNextEpoch(options: DenyListV2ContainsNextEpochOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; + const parameterNames = ['addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_contains_next_epoch', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2EnableGlobalPauseArguments { + denyCap: RawTransactionArgument; +} +export interface DenyListV2EnableGlobalPauseOptions { + package: string; + arguments: DenyListV2EnableGlobalPauseArguments | [denyCap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Enable the global pause for the given coin type. This will immediately prevent + * all addresses from using objects of this coin type as inputs. At the start of + * the next epoch, all addresses will be unable to receive objects of this coin + * type. + */ +export function denyListV2EnableGlobalPause(options: DenyListV2EnableGlobalPauseOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null] satisfies (string | null)[]; + const parameterNames = ['denyCap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_enable_global_pause', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2DisableGlobalPauseArguments { + denyCap: RawTransactionArgument; +} +export interface DenyListV2DisableGlobalPauseOptions { + package: string; + arguments: DenyListV2DisableGlobalPauseArguments | [denyCap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Disable the global pause for the given coin type. This will immediately allow + * all addresses to resume using objects of this coin type as inputs. However, + * receiving objects of this coin type will still be paused until the start of the + * next epoch. + */ +export function denyListV2DisableGlobalPause(options: DenyListV2DisableGlobalPauseOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null] satisfies (string | null)[]; + const parameterNames = ['denyCap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_disable_global_pause', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2IsGlobalPauseEnabledCurrentEpochArguments {} +export interface DenyListV2IsGlobalPauseEnabledCurrentEpochOptions { + package: string; + arguments?: DenyListV2IsGlobalPauseEnabledCurrentEpochArguments | []; + typeArguments: [string]; +} +/** + * Check if the global pause is enabled for the given coin type in the current + * epoch. + */ +export function denyListV2IsGlobalPauseEnabledCurrentEpoch( + options: DenyListV2IsGlobalPauseEnabledCurrentEpochOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_is_global_pause_enabled_current_epoch', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListV2IsGlobalPauseEnabledNextEpochArguments {} +export interface DenyListV2IsGlobalPauseEnabledNextEpochOptions { + package: string; + arguments?: DenyListV2IsGlobalPauseEnabledNextEpochArguments | []; + typeArguments: [string]; +} +/** Check if the global pause is enabled for the given coin type in the next epoch. */ +export function denyListV2IsGlobalPauseEnabledNextEpoch( + options: DenyListV2IsGlobalPauseEnabledNextEpochOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_v2_is_global_pause_enabled_next_epoch', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MintAndTransferArguments { + c: RawTransactionArgument; + amount: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface MintAndTransferOptions { + package: string; + arguments: + | MintAndTransferArguments + | [ + c: RawTransactionArgument, + amount: RawTransactionArgument, + recipient: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Mint `amount` of `Coin` and send it to `recipient`. Invokes `mint()`. */ +export function mintAndTransfer(options: MintAndTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', 'address'] satisfies (string | null)[]; + const parameterNames = ['c', 'amount', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'mint_and_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateNameArguments { + Treasury: RawTransactionArgument; + metadata: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface UpdateNameOptions { + package: string; + arguments: + | UpdateNameArguments + | [ + Treasury: RawTransactionArgument, + metadata: RawTransactionArgument, + name: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update name of the coin in `CoinMetadata` */ +export function updateName(options: UpdateNameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['Treasury', 'metadata', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'update_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateSymbolArguments { + Treasury: RawTransactionArgument; + metadata: RawTransactionArgument; + symbol: RawTransactionArgument; +} +export interface UpdateSymbolOptions { + package: string; + arguments: + | UpdateSymbolArguments + | [ + Treasury: RawTransactionArgument, + metadata: RawTransactionArgument, + symbol: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the symbol of the coin in `CoinMetadata` */ +export function updateSymbol(options: UpdateSymbolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['Treasury', 'metadata', 'symbol']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'update_symbol', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateDescriptionArguments { + Treasury: RawTransactionArgument; + metadata: RawTransactionArgument; + description: RawTransactionArgument; +} +export interface UpdateDescriptionOptions { + package: string; + arguments: + | UpdateDescriptionArguments + | [ + Treasury: RawTransactionArgument, + metadata: RawTransactionArgument, + description: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the description of the coin in `CoinMetadata` */ +export function updateDescription(options: UpdateDescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['Treasury', 'metadata', 'description']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'update_description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateIconUrlArguments { + Treasury: RawTransactionArgument; + metadata: RawTransactionArgument; + url: RawTransactionArgument; +} +export interface UpdateIconUrlOptions { + package: string; + arguments: + | UpdateIconUrlArguments + | [ + Treasury: RawTransactionArgument, + metadata: RawTransactionArgument, + url: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the url of the coin in `CoinMetadata` */ +export function updateIconUrl(options: UpdateIconUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['Treasury', 'metadata', 'url']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'update_icon_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetDecimalsArguments { + metadata: RawTransactionArgument; +} +export interface GetDecimalsOptions { + package: string; + arguments: GetDecimalsArguments | [metadata: RawTransactionArgument]; + typeArguments: [string]; +} +export function getDecimals(options: GetDecimalsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'get_decimals', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetNameArguments { + metadata: RawTransactionArgument; +} +export interface GetNameOptions { + package: string; + arguments: GetNameArguments | [metadata: RawTransactionArgument]; + typeArguments: [string]; +} +export function getName(options: GetNameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'get_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetSymbolArguments { + metadata: RawTransactionArgument; +} +export interface GetSymbolOptions { + package: string; + arguments: GetSymbolArguments | [metadata: RawTransactionArgument]; + typeArguments: [string]; +} +export function getSymbol(options: GetSymbolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'get_symbol', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetDescriptionArguments { + metadata: RawTransactionArgument; +} +export interface GetDescriptionOptions { + package: string; + arguments: GetDescriptionArguments | [metadata: RawTransactionArgument]; + typeArguments: [string]; +} +export function getDescription(options: GetDescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'get_description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetIconUrlArguments { + metadata: RawTransactionArgument; +} +export interface GetIconUrlOptions { + package: string; + arguments: GetIconUrlArguments | [metadata: RawTransactionArgument]; + typeArguments: [string]; +} +export function getIconUrl(options: GetIconUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'get_icon_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SupplyArguments { + treasury: RawTransactionArgument; +} +export interface SupplyOptions { + package: string; + arguments: SupplyArguments | [treasury: RawTransactionArgument]; + typeArguments: [string]; +} +export function supply(options: SupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['treasury']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateRegulatedCurrencyArguments> { + witness: RawTransactionArgument; + decimals: RawTransactionArgument; + symbol: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + iconUrl: RawTransactionArgument; +} +export interface CreateRegulatedCurrencyOptions> { + package: string; + arguments: + | CreateRegulatedCurrencyArguments + | [ + witness: RawTransactionArgument, + decimals: RawTransactionArgument, + symbol: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + iconUrl: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * This creates a new currency, via `create_currency`, but with an extra capability + * that allows for specific addresses to have their coins frozen. Those addresses + * cannot interact with the coin as input objects. + */ +export function createRegulatedCurrency>( + options: CreateRegulatedCurrencyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + 'u8', + 'vector', + 'vector', + 'vector', + '0x1::option::Option', + ] satisfies (string | null)[]; + const parameterNames = ['witness', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'create_regulated_currency', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListAddArguments { + DenyCap: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface DenyListAddOptions { + package: string; + arguments: + | DenyListAddArguments + | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Adds the given address to the deny list, preventing it from interacting with the + * specified coin type as an input to a transaction. + */ +export function denyListAdd(options: DenyListAddOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; + const parameterNames = ['DenyCap', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListRemoveArguments { + DenyCap: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface DenyListRemoveOptions { + package: string; + arguments: + | DenyListRemoveArguments + | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Removes an address from the deny list. Aborts with `ENotFrozen` if the address + * is not already in the list. + */ +export function denyListRemove(options: DenyListRemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; + const parameterNames = ['DenyCap', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyListContainsArguments { + addr: RawTransactionArgument; +} +export interface DenyListContainsOptions { + package: string; + arguments: DenyListContainsArguments | [addr: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns true iff the given address is denied for the given coin type. It will + * return false if given a non-coin type. + */ +export function denyListContains(options: DenyListContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; + const parameterNames = ['addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin', + function: 'deny_list_contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts b/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts new file mode 100644 index 000000000..405c9567c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts @@ -0,0 +1,1236 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the system object for managing coin data in a central registry. This + * module provides a centralized way to store and manage metadata for all + * currencies in the Sui ecosystem, including their supply information, regulatory + * status, and metadata capabilities. + */ + +import { + MoveStruct, + MoveTuple, + MoveEnum, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as type_name from '../suins_auction/type_name.js'; +import * as balance from './balance.js'; +import * as vec_map from './vec_map.js'; +import * as bag from './bag.js'; +const $moduleName = '0x2::coin_registry'; +export const CoinRegistry = new MoveStruct({ + name: `${$moduleName}::CoinRegistry`, + fields: { + id: bcs.Address, + }, +}); +export const ExtraField = new MoveTuple({ + name: `${$moduleName}::ExtraField`, + fields: [type_name.TypeName, bcs.vector(bcs.u8())], +}); +export const CurrencyKey = new MoveTuple({ + name: `${$moduleName}::CurrencyKey`, + fields: [bcs.bool()], +}); +export const LegacyMetadataKey = new MoveTuple({ + name: `${$moduleName}::LegacyMetadataKey`, + fields: [bcs.bool()], +}); +export const MetadataCap = new MoveStruct({ + name: `${$moduleName}::MetadataCap`, + fields: { + id: bcs.Address, + }, +}); +export const Borrow = new MoveStruct({ + name: `${$moduleName}::Borrow`, + fields: { + dummy_field: bcs.bool(), + }, +}); +/** + * Supply state marks the type of Currency Supply, which can be + * + * - Fixed: no minting or burning; + * - BurnOnly: no minting, burning is allowed; + * - Unknown: flexible (supply is controlled by its `TreasuryCap`); + */ +export const SupplyState = new MoveEnum({ + name: `${$moduleName}::SupplyState`, + fields: { + /** Coin has a fixed supply with the given Supply object. */ + Fixed: balance.Supply, + /** Coin has a supply that can ONLY decrease. */ + BurnOnly: balance.Supply, + /** Supply information is not yet known or registered. */ + Unknown: null, + }, +}); +/** + * Regulated state of a coin type. + * + * - Regulated: `DenyCap` exists or a `RegulatedCoinMetadata` used to mark currency + * as regulated; + * - Unregulated: the currency was created without deny list; + * - Unknown: the regulatory status is unknown. + */ +export const RegulatedState = new MoveEnum({ + name: `${$moduleName}::RegulatedState`, + fields: { + /** + * Coin is regulated with a deny cap for address restrictions. `allow_global_pause` + * is `None` if the information is unknown (has not been migrated from + * `DenyCapV2`). + */ + Regulated: new MoveStruct({ + name: `RegulatedState.Regulated`, + fields: { + cap: bcs.Address, + allow_global_pause: bcs.option(bcs.bool()), + variant: bcs.u8(), + }, + }), + /** The coin has been created without deny list. */ + Unregulated: null, + /** + * Regulatory status is unknown. Result of a legacy migration for that coin (from + * `coin.move` constructors) + */ + Unknown: null, + }, +}); +/** State of the `MetadataCap` for a single `Currency`. */ +export const MetadataCapState = new MoveEnum({ + name: `${$moduleName}::MetadataCapState`, + fields: { + /** The metadata cap has been claimed. */ + Claimed: bcs.Address, + /** The metadata cap has not been claimed. */ + Unclaimed: null, + /** The metadata cap has been claimed and then deleted. */ + Deleted: null, + }, +}); +export const Currency = new MoveStruct({ + name: `${$moduleName}::Currency`, + fields: { + id: bcs.Address, + /** Number of decimal places the coin uses for display purposes. */ + decimals: bcs.u8(), + /** Human-readable name for the coin. */ + name: bcs.string(), + /** Short symbol/ticker for the coin. */ + symbol: bcs.string(), + /** Detailed description of the coin. */ + description: bcs.string(), + /** URL for the coin's icon/logo. */ + icon_url: bcs.string(), + /** + * Current supply state of the coin (fixed supply or unknown) Note: We're using + * `Option` because `SupplyState` does not have drop, meaning we cannot swap out + * its value at a later state. + */ + supply: bcs.option(SupplyState), + /** Regulatory status of the coin (regulated with deny cap or unknown) */ + regulated: RegulatedState, + /** ID of the treasury cap for this coin type, if registered. */ + treasury_cap_id: bcs.option(bcs.Address), + /** ID of the metadata capability for this coin type, if claimed. */ + metadata_cap_id: MetadataCapState, + /** Additional fields for extensibility. */ + extra_fields: vec_map.VecMap(bcs.string(), ExtraField), + }, +}); +export const CurrencyInitializer = new MoveStruct({ + name: `${$moduleName}::CurrencyInitializer`, + fields: { + currency: Currency, + extra_fields: bag.Bag, + is_otw: bcs.bool(), + }, +}); +export interface NewCurrencyArguments { + registry: RawTransactionArgument; + decimals: RawTransactionArgument; + symbol: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + iconUrl: RawTransactionArgument; +} +export interface NewCurrencyOptions { + package: string; + arguments: + | NewCurrencyArguments + | [ + registry: RawTransactionArgument, + decimals: RawTransactionArgument, + symbol: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + iconUrl: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Creates a new currency. + * + * Note: This constructor has no long term difference from `new_currency_with_otw`. + * This can be called from the module that defines `T` any time after it has been + * published. + */ +export function newCurrency(options: NewCurrencyOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + 'u8', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + ] satisfies (string | null)[]; + const parameterNames = ['registry', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'new_currency', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewCurrencyWithOtwArguments> { + otw: RawTransactionArgument; + decimals: RawTransactionArgument; + symbol: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + iconUrl: RawTransactionArgument; +} +export interface NewCurrencyWithOtwOptions> { + package: string; + arguments: + | NewCurrencyWithOtwArguments + | [ + otw: RawTransactionArgument, + decimals: RawTransactionArgument, + symbol: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + iconUrl: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Creates a new currency with using an OTW as proof of uniqueness. + * + * This is a two-step operation: + * + * 1. `Currency` is constructed in the `init` function and sent to the + * `CoinRegistry`; + * 2. `Currency` is promoted to a shared object in the `finalize_registration` + * call; + */ +export function newCurrencyWithOtw>(options: NewCurrencyWithOtwOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + 'u8', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + ] satisfies (string | null)[]; + const parameterNames = ['otw', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'new_currency_with_otw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ClaimMetadataCapArguments { + currency: RawTransactionArgument; + _: RawTransactionArgument; +} +export interface ClaimMetadataCapOptions { + package: string; + arguments: + | ClaimMetadataCapArguments + | [currency: RawTransactionArgument, _: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Claim a `MetadataCap` for a coin type. Only allowed from the owner of + * `TreasuryCap`, and only once. + * + * Aborts if the `MetadataCap` has already been claimed. Deleted `MetadataCap` + * cannot be reclaimed. + */ +export function claimMetadataCap(options: ClaimMetadataCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', '_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'claim_metadata_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeRegulatedArguments { + init: RawTransactionArgument; + allowGlobalPause: RawTransactionArgument; +} +export interface MakeRegulatedOptions { + package: string; + arguments: + | MakeRegulatedArguments + | [init: RawTransactionArgument, allowGlobalPause: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Allows converting a currency, on init, to regulated, which creates a `DenyCapV2` + * object, and a denylist entry. Sets regulated state to `Regulated`. + * + * This action is irreversible. + */ +export function makeRegulated(options: MakeRegulatedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'bool'] satisfies (string | null)[]; + const parameterNames = ['init', 'allowGlobalPause']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'make_regulated', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeSupplyFixedInitArguments { + init: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface MakeSupplyFixedInitOptions { + package: string; + arguments: + | MakeSupplyFixedInitArguments + | [init: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Initializer function to make the supply fixed. Aborts if Supply is `0` to + * enforce minting during initialization. + */ +export function makeSupplyFixedInit(options: MakeSupplyFixedInitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['init', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'make_supply_fixed_init', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeSupplyBurnOnlyInitArguments { + init: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface MakeSupplyBurnOnlyInitOptions { + package: string; + arguments: + | MakeSupplyBurnOnlyInitArguments + | [init: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Initializer function to make the supply burn-only. Aborts if Supply is `0` to + * enforce minting during initialization. + */ +export function makeSupplyBurnOnlyInit(options: MakeSupplyBurnOnlyInitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['init', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'make_supply_burn_only_init', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeSupplyFixedArguments { + currency: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface MakeSupplyFixedOptions { + package: string; + arguments: + | MakeSupplyFixedArguments + | [currency: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Freeze the supply by destroying the `TreasuryCap` and storing it in the + * `Currency`. + */ +export function makeSupplyFixed(options: MakeSupplyFixedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'make_supply_fixed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeSupplyBurnOnlyArguments { + currency: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface MakeSupplyBurnOnlyOptions { + package: string; + arguments: + | MakeSupplyBurnOnlyArguments + | [currency: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Make the supply `BurnOnly` by giving up the `TreasuryCap`, and allowing burning + * of Coins through the `Currency`. + */ +export function makeSupplyBurnOnly(options: MakeSupplyBurnOnlyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'make_supply_burn_only', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FinalizeArguments { + builder: RawTransactionArgument; +} +export interface FinalizeOptions { + package: string; + arguments: FinalizeArguments | [builder: RawTransactionArgument]; + typeArguments: [string]; +} +/** Finalize the coin initialization, returning `MetadataCap` */ +export function finalize(options: FinalizeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['builder']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'finalize', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FinalizeAndDeleteMetadataCapArguments { + builder: RawTransactionArgument; +} +export interface FinalizeAndDeleteMetadataCapOptions { + package: string; + arguments: FinalizeAndDeleteMetadataCapArguments | [builder: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Does the same as `finalize`, but also deletes the `MetadataCap` after + * finalization. + */ +export function finalizeAndDeleteMetadataCap(options: FinalizeAndDeleteMetadataCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['builder']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'finalize_and_delete_metadata_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FinalizeRegistrationArguments { + registry: RawTransactionArgument; + currency: RawTransactionArgument; +} +export interface FinalizeRegistrationOptions { + package: string; + arguments: + | FinalizeRegistrationArguments + | [registry: RawTransactionArgument, currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * The second step in the "otw" initialization of coin metadata, that takes in the + * `Currency` that was transferred from init, and transforms it in to a "derived + * address" shared object. + * + * Can be performed by anyone. + */ +export function finalizeRegistration(options: FinalizeRegistrationOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['registry', 'currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'finalize_registration', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DeleteMetadataCapArguments { + currency: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface DeleteMetadataCapOptions { + package: string; + arguments: + | DeleteMetadataCapArguments + | [currency: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Delete the metadata cap making further updates of `Currency` metadata + * impossible. This action is IRREVERSIBLE, and the `MetadataCap` can no longer be + * claimed. + */ +export function deleteMetadataCap(options: DeleteMetadataCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'delete_metadata_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BurnArguments { + currency: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface BurnOptions { + package: string; + arguments: + | BurnArguments + | [currency: RawTransactionArgument, coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** Burn the `Coin` if the `Currency` has a `BurnOnly` supply state. */ +export function burn(options: BurnOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'burn', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BurnBalanceArguments { + currency: RawTransactionArgument; + balance: RawTransactionArgument; +} +export interface BurnBalanceOptions { + package: string; + arguments: + | BurnBalanceArguments + | [currency: RawTransactionArgument, balance: RawTransactionArgument]; + typeArguments: [string]; +} +/** Burn the `Balance` if the `Currency` has a `BurnOnly` supply state. */ +export function burnBalance(options: BurnBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'burn_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SetNameArguments { + currency: RawTransactionArgument; + _: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface SetNameOptions { + package: string; + arguments: + | SetNameArguments + | [ + currency: RawTransactionArgument, + _: RawTransactionArgument, + name: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the name of the `Currency`. */ +export function setName(options: SetNameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['currency', '_', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'set_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SetDescriptionArguments { + currency: RawTransactionArgument; + _: RawTransactionArgument; + description: RawTransactionArgument; +} +export interface SetDescriptionOptions { + package: string; + arguments: + | SetDescriptionArguments + | [ + currency: RawTransactionArgument, + _: RawTransactionArgument, + description: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the description of the `Currency`. */ +export function setDescription(options: SetDescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['currency', '_', 'description']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'set_description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SetIconUrlArguments { + currency: RawTransactionArgument; + _: RawTransactionArgument; + iconUrl: RawTransactionArgument; +} +export interface SetIconUrlOptions { + package: string; + arguments: + | SetIconUrlArguments + | [ + currency: RawTransactionArgument, + _: RawTransactionArgument, + iconUrl: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Update the icon URL of the `Currency`. */ +export function setIconUrl(options: SetIconUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['currency', '_', 'iconUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'set_icon_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SetTreasuryCapIdArguments { + currency: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface SetTreasuryCapIdOptions { + package: string; + arguments: + | SetTreasuryCapIdArguments + | [currency: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Register the treasury cap ID for a migrated `Currency`. All currencies created + * with `new_currency` or `new_currency_with_otw` have their treasury cap ID set + * during initialization. + */ +export function setTreasuryCapId(options: SetTreasuryCapIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'set_treasury_cap_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MigrateLegacyMetadataArguments { + registry: RawTransactionArgument; + legacy: RawTransactionArgument; +} +export interface MigrateLegacyMetadataOptions { + package: string; + arguments: + | MigrateLegacyMetadataArguments + | [registry: RawTransactionArgument, legacy: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Register `CoinMetadata` in the `CoinRegistry`. This can happen only once, if the + * `Currency` did not exist yet. Further updates are possible through + * `update_from_legacy_metadata`. + */ +export function migrateLegacyMetadata(options: MigrateLegacyMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['registry', 'legacy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'migrate_legacy_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateFromLegacyMetadataArguments { + currency: RawTransactionArgument; + legacy: RawTransactionArgument; +} +export interface UpdateFromLegacyMetadataOptions { + package: string; + arguments: + | UpdateFromLegacyMetadataArguments + | [currency: RawTransactionArgument, legacy: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Update `Currency` from `CoinMetadata` if the `MetadataCap` is not claimed. After + * the `MetadataCap` is claimed, updates can only be made through `set_*` + * functions. + */ +export function updateFromLegacyMetadata(options: UpdateFromLegacyMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'legacy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'update_from_legacy_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DeleteMigratedLegacyMetadataOptions { + package: string; + arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; + typeArguments: [string]; +} +export function deleteMigratedLegacyMetadata(options: DeleteMigratedLegacyMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'delete_migrated_legacy_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + typeArguments: options.typeArguments, + }); +} +export interface MigrateRegulatedStateByMetadataArguments { + currency: RawTransactionArgument; + metadata: RawTransactionArgument; +} +export interface MigrateRegulatedStateByMetadataOptions { + package: string; + arguments: + | MigrateRegulatedStateByMetadataArguments + | [currency: RawTransactionArgument, metadata: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Allow migrating the regulated state by access to `RegulatedCoinMetadata` frozen + * object. This is a permissionless operation which can be performed only once. + */ +export function migrateRegulatedStateByMetadata(options: MigrateRegulatedStateByMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'migrate_regulated_state_by_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MigrateRegulatedStateByCapArguments { + currency: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface MigrateRegulatedStateByCapOptions { + package: string; + arguments: + | MigrateRegulatedStateByCapArguments + | [currency: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** Mark regulated state by showing the `DenyCapV2` object for the `Currency`. */ +export function migrateRegulatedStateByCap(options: MigrateRegulatedStateByCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'migrate_regulated_state_by_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowLegacyMetadataArguments { + currency: RawTransactionArgument; +} +export interface BorrowLegacyMetadataOptions { + package: string; + arguments: BorrowLegacyMetadataArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Borrow the legacy `CoinMetadata` from a new `Currency`. To preserve the `ID` of + * the legacy `CoinMetadata`, we create it on request and then store it as a + * dynamic field for future borrows. + * + * `Borrow` ensures that the `CoinMetadata` is returned in the same transaction. + */ +export function borrowLegacyMetadata(options: BorrowLegacyMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'borrow_legacy_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReturnBorrowedLegacyMetadataArguments { + currency: RawTransactionArgument; + legacy: RawTransactionArgument; + borrow: RawTransactionArgument; +} +export interface ReturnBorrowedLegacyMetadataOptions { + package: string; + arguments: + | ReturnBorrowedLegacyMetadataArguments + | [ + currency: RawTransactionArgument, + legacy: RawTransactionArgument, + borrow: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Return the borrowed `CoinMetadata` and the `Borrow` potato to the `Currency`. + * + * Note to self: Borrow requirement prevents deletion through this method. + */ +export function returnBorrowedLegacyMetadata(options: ReturnBorrowedLegacyMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['currency', 'legacy', 'borrow']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'return_borrowed_legacy_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DecimalsArguments { + currency: RawTransactionArgument; +} +export interface DecimalsOptions { + package: string; + arguments: DecimalsArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the number of decimal places for the coin type. */ +export function decimals(options: DecimalsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'decimals', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NameArguments { + currency: RawTransactionArgument; +} +export interface NameOptions { + package: string; + arguments: NameArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the human-readable name of the coin. */ +export function name(options: NameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SymbolArguments { + currency: RawTransactionArgument; +} +export interface SymbolOptions { + package: string; + arguments: SymbolArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the symbol/ticker of the coin. */ +export function symbol(options: SymbolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'symbol', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DescriptionArguments { + currency: RawTransactionArgument; +} +export interface DescriptionOptions { + package: string; + arguments: DescriptionArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the description of the coin. */ +export function description(options: DescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IconUrlArguments { + currency: RawTransactionArgument; +} +export interface IconUrlOptions { + package: string; + arguments: IconUrlArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the icon URL for the coin. */ +export function iconUrl(options: IconUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'icon_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsMetadataCapClaimedArguments { + currency: RawTransactionArgument; +} +export interface IsMetadataCapClaimedOptions { + package: string; + arguments: IsMetadataCapClaimedArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if the metadata capability has been claimed for this `Currency` type. */ +export function isMetadataCapClaimed(options: IsMetadataCapClaimedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'is_metadata_cap_claimed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsMetadataCapDeletedArguments { + currency: RawTransactionArgument; +} +export interface IsMetadataCapDeletedOptions { + package: string; + arguments: IsMetadataCapDeletedArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if the metadata capability has been deleted for this `Currency` type. */ +export function isMetadataCapDeleted(options: IsMetadataCapDeletedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'is_metadata_cap_deleted', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MetadataCapIdArguments { + currency: RawTransactionArgument; +} +export interface MetadataCapIdOptions { + package: string; + arguments: MetadataCapIdArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the metadata cap ID, or none if it has not been claimed. */ +export function metadataCapId(options: MetadataCapIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'metadata_cap_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TreasuryCapIdArguments { + currency: RawTransactionArgument; +} +export interface TreasuryCapIdOptions { + package: string; + arguments: TreasuryCapIdArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the treasury cap ID for this coin type, if registered. */ +export function treasuryCapId(options: TreasuryCapIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'treasury_cap_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DenyCapIdArguments { + currency: RawTransactionArgument; +} +export interface DenyCapIdOptions { + package: string; + arguments: DenyCapIdArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get the deny cap ID for this coin type, if it's a regulated coin. Returns `None` + * if: + * + * - The `Currency` is not regulated; + * - The `Currency` is migrated from legacy, and its regulated state has not been + * set; + */ +export function denyCapId(options: DenyCapIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'deny_cap_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsSupplyFixedArguments { + currency: RawTransactionArgument; +} +export interface IsSupplyFixedOptions { + package: string; + arguments: IsSupplyFixedArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if the supply is fixed. */ +export function isSupplyFixed(options: IsSupplyFixedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'is_supply_fixed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsSupplyBurnOnlyArguments { + currency: RawTransactionArgument; +} +export interface IsSupplyBurnOnlyOptions { + package: string; + arguments: IsSupplyBurnOnlyArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if the supply is burn-only. */ +export function isSupplyBurnOnly(options: IsSupplyBurnOnlyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'is_supply_burn_only', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsRegulatedArguments { + currency: RawTransactionArgument; +} +export interface IsRegulatedOptions { + package: string; + arguments: IsRegulatedArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if the currency is regulated. */ +export function isRegulated(options: IsRegulatedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'is_regulated', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TotalSupplyArguments { + currency: RawTransactionArgument; +} +export interface TotalSupplyOptions { + package: string; + arguments: TotalSupplyArguments | [currency: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get the total supply for the `Currency` if the Supply is in fixed or + * burn-only state. Returns `None` if the SupplyState is Unknown. + */ +export function totalSupply(options: TotalSupplyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['currency']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'total_supply', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExistsArguments { + registry: RawTransactionArgument; +} +export interface ExistsOptions { + package: string; + arguments: ExistsArguments | [registry: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if coin data exists for the given type T in the registry. */ +export function exists(options: ExistsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['registry']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'coin_registry', + function: 'exists', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/config.ts b/packages/suins/src/contracts/suins_auction/deps/sui/config.ts new file mode 100644 index 000000000..50e55d2de --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/config.ts @@ -0,0 +1,30 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +const $moduleName = '0x2::config'; +export const Config = new MoveStruct({ + name: `${$moduleName}::Config`, + fields: { + id: bcs.Address, + }, +}); +export function SettingData>(...typeParameters: [Value]) { + return new MoveStruct({ + name: `${$moduleName}::SettingData<${typeParameters[0].name as Value['name']}>`, + fields: { + newer_value_epoch: bcs.u64(), + newer_value: bcs.option(typeParameters[0]), + older_value_opt: bcs.option(typeParameters[0]), + }, + }); +} +export function Setting>(...typeParameters: [Value]) { + return new MoveStruct({ + name: `${$moduleName}::Setting<${typeParameters[0].name as Value['name']}>`, + fields: { + data: bcs.option(SettingData(typeParameters[0])), + }, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts b/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts new file mode 100644 index 000000000..63cceff6f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts @@ -0,0 +1,67 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the `DenyList` type. The `DenyList` shared object is used to restrict + * access to instances of certain core types from being used as inputs by specified + * addresses in the deny list. + */ + +import { MoveStruct, MoveTuple } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import * as bag from './bag.js'; +import * as table from './table.js'; +const $moduleName = '0x2::deny_list'; +export const DenyList = new MoveStruct({ + name: `${$moduleName}::DenyList`, + fields: { + id: bcs.Address, + /** The individual deny lists. */ + lists: bag.Bag, + }, +}); +export const ConfigWriteCap = new MoveTuple({ + name: `${$moduleName}::ConfigWriteCap`, + fields: [bcs.bool()], +}); +export const ConfigKey = new MoveStruct({ + name: `${$moduleName}::ConfigKey`, + fields: { + per_type_index: bcs.u64(), + per_type_key: bcs.vector(bcs.u8()), + }, +}); +export const AddressKey = new MoveTuple({ + name: `${$moduleName}::AddressKey`, + fields: [bcs.Address], +}); +export const GlobalPauseKey = new MoveTuple({ + name: `${$moduleName}::GlobalPauseKey`, + fields: [bcs.bool()], +}); +export const PerTypeConfigCreated = new MoveStruct({ + name: `${$moduleName}::PerTypeConfigCreated`, + fields: { + key: ConfigKey, + config_id: bcs.Address, + }, +}); +export const PerTypeList = new MoveStruct({ + name: `${$moduleName}::PerTypeList`, + fields: { + id: bcs.Address, + /** + * Number of object types that have been banned for a given address. Used to + * quickly skip checks for most addresses. + */ + denied_count: table.Table, + /** + * Set of addresses that are banned for a given type. For example with + * `sui::coin::Coin`: If addresses A and B are banned from using + * "0...0123::my_coin::MY_COIN", this will be "0...0123::my_coin::MY_COIN" -> {A, + * B}. + */ + denied_addresses: table.Table, + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts b/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts new file mode 100644 index 000000000..9820e693d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts @@ -0,0 +1,140 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Enables the creation of objects with deterministic addresses derived from a + * parent object's UID. This module provides a way to generate objects with + * predictable addresses based on a parent UID and a key, creating a namespace that + * ensures uniqueness for each parent-key combination, which is usually how + * registries are built. + * + * Key features: + * + * - Deterministic address generation based on parent object UID and key + * - Derived objects can exist and operate independently of their parent + * + * The derived UIDs, once created, are independent and do not require sequencing on + * the parent object. They can be used without affecting the parent. The parent + * only maintains a record of which derived addresses have been claimed to prevent + * duplicates. + */ + +import { + MoveTuple, + MoveEnum, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::derived_object'; +export const Claimed = new MoveTuple({ name: `${$moduleName}::Claimed`, fields: [bcs.Address] }); +/** + * An internal key to protect from generating the same UID twice (e.g. collide with + * DFs) + */ +export function DerivedObjectKey>(...typeParameters: [K]) { + return new MoveTuple({ + name: `${$moduleName}::DerivedObjectKey<${typeParameters[0].name as K['name']}>`, + fields: [typeParameters[0]], + }); +} +/** + * The possible values of a claimed UID. We make it an enum to make upgradeability + * easier in the future. + */ +export const ClaimedStatus = new MoveEnum({ + name: `${$moduleName}::ClaimedStatus`, + fields: { + /** The UID has been claimed and cannot be re-claimed or used. */ + Reserved: null, + }, +}); +export interface ClaimArguments> { + parent: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface ClaimOptions> { + package: string; + arguments: + | ClaimArguments + | [parent: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Claim a deterministic UID, using the parent's UID & any key. */ +export function claim>(options: ClaimOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['parent', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'derived_object', + function: 'claim', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExistsArguments> { + parent: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface ExistsOptions> { + package: string; + arguments: + | ExistsArguments + | [parent: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Checks if a provided `key` has been claimed for the given parent. Note: If the + * UID has been deleted through `object::delete`, this will always return true. + */ +export function exists>(options: ExistsOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['parent', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'derived_object', + function: 'exists', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DeriveAddressArguments> { + parent: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface DeriveAddressOptions> { + package: string; + arguments: + | DeriveAddressArguments + | [parent: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Given an ID and a Key, it calculates the derived address. */ +export function deriveAddress>(options: DeriveAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['parent', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'derived_object', + function: 'derive_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/display.ts b/packages/suins/src/contracts/suins_auction/deps/sui/display.ts new file mode 100644 index 000000000..30bada5a2 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/display.ts @@ -0,0 +1,349 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines a Display struct which defines the way an Object should be displayed. + * The intention is to keep data as independent from its display as possible, + * protecting the development process and keeping it separate from the ecosystem + * agreements. + * + * Each of the fields of the Display object should allow for pattern substitution + * and filling-in the pieces using the data from the object T. + * + * More entry functions might be added in the future depending on the use cases. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from './vec_map.js'; +const $moduleName = '0x2::display'; +export const Display = new MoveStruct({ + name: `${$moduleName}::Display`, + fields: { + id: bcs.Address, + /** + * Contains fields for display. Currently supported fields are: name, link, image + * and description. + */ + fields: vec_map.VecMap(bcs.string(), bcs.string()), + /** Version that can only be updated manually by the Publisher. */ + version: bcs.u16(), + }, +}); +export const DisplayCreated = new MoveStruct({ + name: `${$moduleName}::DisplayCreated`, + fields: { + id: bcs.Address, + }, +}); +export const VersionUpdated = new MoveStruct({ + name: `${$moduleName}::VersionUpdated`, + fields: { + id: bcs.Address, + version: bcs.u16(), + fields: vec_map.VecMap(bcs.string(), bcs.string()), + }, +}); +export interface NewArguments { + pub: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [pub: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Create an empty Display object. It can either be shared empty or filled with + * data right away via cheaper `set_owned` method. + */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pub']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewWithFieldsArguments { + pub: RawTransactionArgument; + fields: RawTransactionArgument; + values: RawTransactionArgument; +} +export interface NewWithFieldsOptions { + package: string; + arguments: + | NewWithFieldsArguments + | [ + pub: RawTransactionArgument, + fields: RawTransactionArgument, + values: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Create a new Display object with a set of fields. */ +export function newWithFields(options: NewWithFieldsOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + 'vector<0x1::string::String>', + 'vector<0x1::string::String>', + ] satisfies (string | null)[]; + const parameterNames = ['pub', 'fields', 'values']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'new_with_fields', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateAndKeepArguments { + pub: RawTransactionArgument; +} +export interface CreateAndKeepOptions { + package: string; + arguments: CreateAndKeepArguments | [pub: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a new empty Display object and keep it. */ +export function createAndKeep(options: CreateAndKeepOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pub']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'create_and_keep', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpdateVersionArguments { + display: RawTransactionArgument; +} +export interface UpdateVersionOptions { + package: string; + arguments: UpdateVersionArguments | [display: RawTransactionArgument]; + typeArguments: [string]; +} +/** Manually bump the version and emit an event with the updated version's contents. */ +export function updateVersion(options: UpdateVersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['display']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'update_version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddArguments { + self: RawTransactionArgument; + name: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface AddOptions { + package: string; + arguments: + | AddArguments + | [ + self: RawTransactionArgument, + name: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Sets a custom `name` field with the `value`. */ +export function add(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String', '0x1::string::String'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'name', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddMultipleArguments { + self: RawTransactionArgument; + fields: RawTransactionArgument; + values: RawTransactionArgument; +} +export interface AddMultipleOptions { + package: string; + arguments: + | AddMultipleArguments + | [ + self: RawTransactionArgument, + fields: RawTransactionArgument, + values: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Sets multiple `fields` with `values`. */ +export function addMultiple(options: AddMultipleOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + 'vector<0x1::string::String>', + 'vector<0x1::string::String>', + ] satisfies (string | null)[]; + const parameterNames = ['self', 'fields', 'values']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'add_multiple', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface EditArguments { + self: RawTransactionArgument; + name: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface EditOptions { + package: string; + arguments: + | EditArguments + | [ + self: RawTransactionArgument, + name: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Change the value of the field. TODO (long run): version changes; */ +export function edit(options: EditOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String', '0x1::string::String'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'name', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'edit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments { + self: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface RemoveOptions { + package: string; + arguments: + | RemoveArguments + | [self: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string]; +} +/** Remove the key from the Display. */ +export function remove(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsAuthorizedArguments { + pub: RawTransactionArgument; +} +export interface IsAuthorizedOptions { + package: string; + arguments: IsAuthorizedArguments | [pub: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Authorization check; can be performed externally to implement protection rules + * for Display. + */ +export function isAuthorized(options: IsAuthorizedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pub']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'is_authorized', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface VersionArguments { + d: RawTransactionArgument; +} +export interface VersionOptions { + package: string; + arguments: VersionArguments | [d: RawTransactionArgument]; + typeArguments: [string]; +} +/** Read the `version` field. */ +export function version(options: VersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['d']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FieldsArguments { + d: RawTransactionArgument; +} +export interface FieldsOptions { + package: string; + arguments: FieldsArguments | [d: RawTransactionArgument]; + typeArguments: [string]; +} +/** Read the `fields` field. */ +export function fields(options: FieldsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['d']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'display', + function: 'fields', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts new file mode 100644 index 000000000..89fc1c85d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts @@ -0,0 +1,273 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * In addition to the fields declared in its type definition, a Sui object can have + * dynamic fields that can be added after the object has been constructed. Unlike + * ordinary field names (which are always statically declared identifiers) a + * dynamic field name can be any value with the `copy`, `drop`, and `store` + * abilities, e.g. an integer, a boolean, or a string. This gives Sui programmers + * the flexibility to extend objects on-the-fly, and it also serves as a building + * block for core collection types + */ + +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::dynamic_field'; +/** Internal object used for storing the field and value */ +export function Field, Value extends BcsType>( + ...typeParameters: [Name, Value] +) { + return new MoveStruct({ + name: `${$moduleName}::Field<${typeParameters[0].name as Name['name']}, ${typeParameters[1].name as Value['name']}>`, + fields: { + /** + * Determined by the hash of the object ID, the field name value and it's type, + * i.e. hash(parent.id || name || Name) + */ + id: bcs.Address, + /** The value for the name of this field */ + name: typeParameters[0], + /** The value bound to this field */ + value: typeParameters[1], + }, + }); +} +export interface AddArguments, Value extends BcsType> { + object: RawTransactionArgument; + name: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface AddOptions, Value extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + object: RawTransactionArgument, + name: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a dynamic field to the object `object: &mut UID` at field specified by + * `name: Name`. Aborts with `EFieldAlreadyExists` if the object already has that + * field with that name. + */ +export function add, Value extends BcsType>( + options: AddOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x2::object::ID', + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['object', 'name', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutably borrows the `object`s dynamic field with the name specified by + * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a + * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but + * the value does not have the specified type. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the `object`s dynamic field with the name specified by + * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a + * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but + * the value does not have the specified type. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the `object`s dynamic field with the name specified by `name: Name` and + * returns the bound value. Aborts with `EFieldDoesNotExist` if the object does not + * have a field with that name. Aborts with `EFieldTypeMismatch` if the field + * exists, but the value does not have the specified type. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface Exists_Arguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface Exists_Options> { + package: string; + arguments: + | Exists_Arguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns true if and only if the `object` has a dynamic field with the name + * specified by `name: Name` but without specifying the `Value` type + */ +export function exists_>(options: Exists_Options) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'exists_', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveIfExistsArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface RemoveIfExistsOptions> { + package: string; + arguments: + | RemoveIfExistsArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the dynamic field if it exists. Returns the `some(Value)` if it exists + * or none otherwise. + */ +export function removeIfExists>(options: RemoveIfExistsOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'remove_if_exists', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExistsWithTypeArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface ExistsWithTypeOptions> { + package: string; + arguments: + | ExistsWithTypeArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true if and only if the `object` has a dynamic field with the name + * specified by `name: Name` with an assigned value of type `Value`. + */ +export function existsWithType>(options: ExistsWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_field', + function: 'exists_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts new file mode 100644 index 000000000..b4b439ee9 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts @@ -0,0 +1,261 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Similar to `sui::dynamic_field`, this module allows for the access of dynamic + * fields. But unlike, `sui::dynamic_field` the values bound to these dynamic + * fields _must_ be objects themselves. This allows for the objects to still exist + * within in storage, which may be important for external tools. The difference is + * otherwise not observable from within Move. + */ + +import { type BcsType } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::dynamic_object_field'; +export function Wrapper>(...typeParameters: [Name]) { + return new MoveStruct({ + name: `${$moduleName}::Wrapper<${typeParameters[0].name as Name['name']}>`, + fields: { + name: typeParameters[0], + }, + }); +} +export interface AddArguments, Value extends BcsType> { + object: RawTransactionArgument; + name: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface AddOptions, Value extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + object: RawTransactionArgument, + name: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a dynamic object field to the object `object: &mut UID` at field specified + * by `name: Name`. Aborts with `EFieldAlreadyExists` if the object already has + * that field with that name. + */ +export function add, Value extends BcsType>( + options: AddOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x2::object::ID', + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['object', 'name', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutably borrows the `object`s dynamic object field with the name specified by + * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a + * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but + * the value object does not have the specified type. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the `object`s dynamic object field with the name specified by + * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a + * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but + * the value object does not have the specified type. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the `object`s dynamic object field with the name specified by + * `name: Name` and returns the bound object. Aborts with `EFieldDoesNotExist` if + * the object does not have a field with that name. Aborts with + * `EFieldTypeMismatch` if the field exists, but the value object does not have the + * specified type. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface Exists_Arguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface Exists_Options> { + package: string; + arguments: + | Exists_Arguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns true if and only if the `object` has a dynamic object field with the + * name specified by `name: Name`. + */ +export function exists_>(options: Exists_Options) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'exists_', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExistsWithTypeArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface ExistsWithTypeOptions> { + package: string; + arguments: + | ExistsWithTypeArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true if and only if the `object` has a dynamic field with the name + * specified by `name: Name` with an assigned value of type `Value`. + */ +export function existsWithType>(options: ExistsWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'exists_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IdArguments> { + object: RawTransactionArgument; + name: RawTransactionArgument; +} +export interface IdOptions> { + package: string; + arguments: + | IdArguments + | [object: RawTransactionArgument, name: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns the ID of the object associated with the dynamic object field Returns + * none otherwise + */ +export function id>(options: IdOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['object', 'name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'dynamic_object_field', + function: 'id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts new file mode 100644 index 000000000..374b67222 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts @@ -0,0 +1,115 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface Secp256k1EcrecoverArguments { + signature: RawTransactionArgument; + msg: RawTransactionArgument; + hash: RawTransactionArgument; +} +export interface Secp256k1EcrecoverOptions { + package: string; + arguments: + | Secp256k1EcrecoverArguments + | [ + signature: RawTransactionArgument, + msg: RawTransactionArgument, + hash: RawTransactionArgument, + ]; +} +/** + * @param signature: A 65-bytes signature in form (r, s, v) that is signed using + * Secp256k1. Reference implementation on signature generation using RFC6979: + * https://github.com/MystenLabs/narwhal/blob/5d6f6df8ccee94446ff88786c0dbbc98be7cfc09/crypto/src/secp256k1.rs + * The accepted v values are {0, 1, 2, 3}. @param msg: The message that the + * signature is signed against, this is raw message without hashing. @param hash: + * The hash function used to hash the message when signing. + * + * If the signature is valid, return the corresponding recovered Secpk256k1 public + * key, otherwise throw error. This is similar to ecrecover in Ethereum, can only + * be applied to Secp256k1 signatures. May abort with `EFailToRecoverPubKey` or + * `EInvalidSignature`. + */ +export function secp256k1Ecrecover(options: Secp256k1EcrecoverOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'u8'] satisfies (string | null)[]; + const parameterNames = ['signature', 'msg', 'hash']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecdsa_k1', + function: 'secp256k1_ecrecover', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DecompressPubkeyArguments { + pubkey: RawTransactionArgument; +} +export interface DecompressPubkeyOptions { + package: string; + arguments: DecompressPubkeyArguments | [pubkey: RawTransactionArgument]; +} +/** + * @param pubkey: A 33-bytes compressed public key, a prefix either 0x02 or 0x03 + * and a 256-bit integer. + * + * If the compressed public key is valid, return the 65-bytes uncompressed public + * key, otherwise throw error. May abort with `EInvalidPubKey`. + */ +export function decompressPubkey(options: DecompressPubkeyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['pubkey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecdsa_k1', + function: 'decompress_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface Secp256k1VerifyArguments { + signature: RawTransactionArgument; + publicKey: RawTransactionArgument; + msg: RawTransactionArgument; + hash: RawTransactionArgument; +} +export interface Secp256k1VerifyOptions { + package: string; + arguments: + | Secp256k1VerifyArguments + | [ + signature: RawTransactionArgument, + publicKey: RawTransactionArgument, + msg: RawTransactionArgument, + hash: RawTransactionArgument, + ]; +} +/** + * @param signature: A 64-bytes signature in form (r, s) that is signed using + * Secp256k1. This is an non-recoverable signature without recovery id. Reference + * implementation on signature generation using RFC6979: + * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256k1/mod.rs#L193 + * @param public_key: The public key to verify the signature against @param msg: + * The message that the signature is signed against, this is raw message without + * hashing. @param hash: The hash function used to hash the message when signing. + * + * If the signature is valid to the pubkey and hashed message, return true. Else + * false. + */ +export function secp256k1Verify(options: Secp256k1VerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector', 'u8'] satisfies ( + | string + | null + )[]; + const parameterNames = ['signature', 'publicKey', 'msg', 'hash']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecdsa_k1', + function: 'secp256k1_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts new file mode 100644 index 000000000..d6ee72a74 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts @@ -0,0 +1,91 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface Secp256r1EcrecoverArguments { + signature: RawTransactionArgument; + msg: RawTransactionArgument; + hash: RawTransactionArgument; +} +export interface Secp256r1EcrecoverOptions { + package: string; + arguments: + | Secp256r1EcrecoverArguments + | [ + signature: RawTransactionArgument, + msg: RawTransactionArgument, + hash: RawTransactionArgument, + ]; +} +/** + * @param signature: A 65-bytes signature in form (r, s, v) that is signed using + * Secp256r1. Reference implementation on signature generation using RFC6979: + * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs + * The accepted v values are {0, 1, 2, 3}. @param msg: The message that the + * signature is signed against, this is raw message without hashing. @param hash: + * The u8 representing the name of hash function used to hash the message when + * signing. + * + * If the signature is valid, return the corresponding recovered Secpk256r1 public + * key, otherwise throw error. This is similar to ecrecover in Ethereum, can only + * be applied to Secp256r1 signatures. May fail with `EFailToRecoverPubKey` or + * `EInvalidSignature`. + */ +export function secp256r1Ecrecover(options: Secp256r1EcrecoverOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'u8'] satisfies (string | null)[]; + const parameterNames = ['signature', 'msg', 'hash']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecdsa_r1', + function: 'secp256r1_ecrecover', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface Secp256r1VerifyArguments { + signature: RawTransactionArgument; + publicKey: RawTransactionArgument; + msg: RawTransactionArgument; + hash: RawTransactionArgument; +} +export interface Secp256r1VerifyOptions { + package: string; + arguments: + | Secp256r1VerifyArguments + | [ + signature: RawTransactionArgument, + publicKey: RawTransactionArgument, + msg: RawTransactionArgument, + hash: RawTransactionArgument, + ]; +} +/** + * @param signature: A 64-bytes signature in form (r, s) that is signed using + * Secp256r1. This is an non-recoverable signature without recovery id. Reference + * implementation on signature generation using RFC6979: + * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs + * @param public_key: The public key to verify the signature against @param msg: + * The message that the signature is signed against, this is raw message without + * hashing. @param hash: The u8 representing the name of hash function used to hash + * the message when signing. + * + * If the signature is valid to the pubkey and hashed message, return true. Else + * false. + */ +export function secp256r1Verify(options: Secp256r1VerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector', 'u8'] satisfies ( + | string + | null + )[]; + const parameterNames = ['signature', 'publicKey', 'msg', 'hash']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecdsa_r1', + function: 'secp256r1_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts new file mode 100644 index 000000000..f2f397b95 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts @@ -0,0 +1,46 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface EcvrfVerifyArguments { + hash: RawTransactionArgument; + alphaString: RawTransactionArgument; + publicKey: RawTransactionArgument; + proof: RawTransactionArgument; +} +export interface EcvrfVerifyOptions { + package: string; + arguments: + | EcvrfVerifyArguments + | [ + hash: RawTransactionArgument, + alphaString: RawTransactionArgument, + publicKey: RawTransactionArgument, + proof: RawTransactionArgument, + ]; +} +/** + * @param hash: The hash/output from a ECVRF to be verified. @param alpha_string: + * Input/seed to the ECVRF used to generate the output. @param public_key: The + * public key corresponding to the private key used to generate the output. @param + * proof: The proof of validity of the output. Verify a proof for a Ristretto + * ECVRF. Returns true if the proof is valid and corresponds to the given output. + * May abort with `EInvalidHashLength`, `EInvalidPublicKeyEncoding` or + * `EInvalidProofEncoding`. + */ +export function ecvrfVerify(options: EcvrfVerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['hash', 'alphaString', 'publicKey', 'proof']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ecvrf', + function: 'ecvrf_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts new file mode 100644 index 000000000..21f5469cc --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts @@ -0,0 +1,40 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface Ed25519VerifyArguments { + signature: RawTransactionArgument; + publicKey: RawTransactionArgument; + msg: RawTransactionArgument; +} +export interface Ed25519VerifyOptions { + package: string; + arguments: + | Ed25519VerifyArguments + | [ + signature: RawTransactionArgument, + publicKey: RawTransactionArgument, + msg: RawTransactionArgument, + ]; +} +/** + * @param signature: 32-byte signature that is a point on the Ed25519 elliptic + * curve. @param public_key: 32-byte signature that is a point on the Ed25519 + * elliptic curve. @param msg: The message that we test the signature against. + * + * If the signature is a valid Ed25519 signature of the message and public key, + * return true. Otherwise, return false. + */ +export function ed25519Verify(options: Ed25519VerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['signature', 'publicKey', 'msg']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'ed25519', + function: 'ed25519_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/event.ts b/packages/suins/src/contracts/suins_auction/deps/sui/event.ts new file mode 100644 index 000000000..3a7162d08 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/event.ts @@ -0,0 +1,94 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Events module. Defines the `sui::event::emit` function which creates and sends a + * custom MoveEvent as a part of the effects certificate of the transaction. + * + * Every MoveEvent has the following properties: + * + * - sender + * - type signature (`T`) + * - event data (the value of `T`) + * - timestamp (local to a node) + * - transaction digest + * + * Example: + * + * ``` + * module my::marketplace { + * use sui::event; + * /* ... *\/ + * struct ItemPurchased has copy, drop { + * item_id: ID, buyer: address + * } + * entry fun buy(/* .... *\/) { + * /* ... *\/ + * event::emit(ItemPurchased { item_id: ..., buyer: .... }) + * } + * } + * ``` + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +import { type BcsType } from '@mysten/sui/bcs'; +export interface EmitArguments> { + event: RawTransactionArgument; +} +export interface EmitOptions> { + package: string; + arguments: EmitArguments | [event: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Emit a custom Move event, sending the data offchain. + * + * Used for creating custom indexes and tracking onchain activity in a way that + * suits a specific application the most. + * + * The type `T` is the main way to index the event, and can contain phantom + * parameters, eg `emit(MyEvent)`. + */ +export function emit>(options: EmitOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['event']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'event', + function: 'emit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface EmitAuthenticatedArguments> { + event: RawTransactionArgument; +} +export interface EmitAuthenticatedOptions> { + package: string; + arguments: EmitAuthenticatedArguments | [event: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Emits a custom Move event which can be authenticated by a light client. + * + * This method emits the authenticated event to the event stream for the Move + * package that defines the event type `T`. Only the package that defines the type + * `T` can emit authenticated events to this stream. + */ +export function emitAuthenticated>(options: EmitAuthenticatedOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['event']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'event', + function: 'emit_authenticated', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts b/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts new file mode 100644 index 000000000..9d064b1af --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts @@ -0,0 +1,130 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** A module for accumulating funds, i.e. Balance-like types. */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::funds_accumulator'; +export const Withdrawal = new MoveStruct({ + name: `${$moduleName}::Withdrawal`, + fields: { + /** The owner of the funds, either an object or a transaction sender */ + owner: bcs.Address, + /** + * At signing we check the limit <= balance when taking this as a call arg. If this + * was generated from an object, we cannot check this until redemption. + */ + limit: bcs.u256(), + }, +}); +export interface WithdrawalOwnerArguments { + withdrawal: RawTransactionArgument; +} +export interface WithdrawalOwnerOptions { + package: string; + arguments: WithdrawalOwnerArguments | [withdrawal: RawTransactionArgument]; + typeArguments: [string]; +} +/** Returns the owner, either a sender's address or an object, of the withdrawal. */ +export function withdrawalOwner(options: WithdrawalOwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['withdrawal']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'funds_accumulator', + function: 'withdrawal_owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawalLimitArguments { + withdrawal: RawTransactionArgument; +} +export interface WithdrawalLimitOptions { + package: string; + arguments: WithdrawalLimitArguments | [withdrawal: RawTransactionArgument]; + typeArguments: [string]; +} +/** Returns the remaining limit of the withdrawal. */ +export function withdrawalLimit(options: WithdrawalLimitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['withdrawal']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'funds_accumulator', + function: 'withdrawal_limit', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawalSplitArguments { + withdrawal: RawTransactionArgument; + subLimit: RawTransactionArgument; +} +export interface WithdrawalSplitOptions { + package: string; + arguments: + | WithdrawalSplitArguments + | [ + withdrawal: RawTransactionArgument, + subLimit: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Split a `Withdrawal` and take a sub-withdrawal from it with the specified + * sub-limit. + */ +export function withdrawalSplit(options: WithdrawalSplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u256'] satisfies (string | null)[]; + const parameterNames = ['withdrawal', 'subLimit']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'funds_accumulator', + function: 'withdrawal_split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawalJoinArguments { + withdrawal: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface WithdrawalJoinOptions { + package: string; + arguments: + | WithdrawalJoinArguments + | [withdrawal: RawTransactionArgument, other: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Join two withdrawals together, increasing the limit of `self` by the limit of + * `other`. Aborts with `EOwnerMismatch` if the owners are not equal. Aborts with + * `EOverflow` if the resulting limit would overflow `u256`. + */ +export function withdrawalJoin(options: WithdrawalJoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['withdrawal', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'funds_accumulator', + function: 'withdrawal_join', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts b/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts new file mode 100644 index 000000000..52462c37b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts @@ -0,0 +1,244 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::groth16'; +export const Curve = new MoveStruct({ + name: `${$moduleName}::Curve`, + fields: { + id: bcs.u8(), + }, +}); +export const PreparedVerifyingKey = new MoveStruct({ + name: `${$moduleName}::PreparedVerifyingKey`, + fields: { + vk_gamma_abc_g1_bytes: bcs.vector(bcs.u8()), + alpha_g1_beta_g2_bytes: bcs.vector(bcs.u8()), + gamma_g2_neg_pc_bytes: bcs.vector(bcs.u8()), + delta_g2_neg_pc_bytes: bcs.vector(bcs.u8()), + }, +}); +export const PublicProofInputs = new MoveStruct({ + name: `${$moduleName}::PublicProofInputs`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export const ProofPoints = new MoveStruct({ + name: `${$moduleName}::ProofPoints`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export interface Bls12381Options { + package: string; + arguments?: []; +} +/** + * Return the `Curve` value indicating that the BLS12-381 construction should be + * used in a given function. + */ +export function bls12381(options: Bls12381Options = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'bls12381', + }); +} +export interface Bn254Options { + package: string; + arguments?: []; +} +/** + * Return the `Curve` value indicating that the BN254 construction should be used + * in a given function. + */ +export function bn254(options: Bn254Options = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'bn254', + }); +} +export interface PvkFromBytesArguments { + vkGammaAbcG1Bytes: RawTransactionArgument; + alphaG1BetaG2Bytes: RawTransactionArgument; + gammaG2NegPcBytes: RawTransactionArgument; + deltaG2NegPcBytes: RawTransactionArgument; +} +export interface PvkFromBytesOptions { + package: string; + arguments: + | PvkFromBytesArguments + | [ + vkGammaAbcG1Bytes: RawTransactionArgument, + alphaG1BetaG2Bytes: RawTransactionArgument, + gammaG2NegPcBytes: RawTransactionArgument, + deltaG2NegPcBytes: RawTransactionArgument, + ]; +} +/** Creates a `PreparedVerifyingKey` from bytes. */ +export function pvkFromBytes(options: PvkFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = [ + 'vkGammaAbcG1Bytes', + 'alphaG1BetaG2Bytes', + 'gammaG2NegPcBytes', + 'deltaG2NegPcBytes', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'pvk_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PvkToBytesArguments { + pvk: RawTransactionArgument; +} +export interface PvkToBytesOptions { + package: string; + arguments: PvkToBytesArguments | [pvk: RawTransactionArgument]; +} +/** Returns bytes of the four components of the `PreparedVerifyingKey`. */ +export function pvkToBytes(options: PvkToBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pvk']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'pvk_to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PublicProofInputsFromBytesArguments { + bytes: RawTransactionArgument; +} +export interface PublicProofInputsFromBytesOptions { + package: string; + arguments: PublicProofInputsFromBytesArguments | [bytes: RawTransactionArgument]; +} +/** + * Creates a `PublicProofInputs` wrapper from bytes. The `bytes` parameter should + * be a concatenation of a number of 32 bytes scalar field elements to be used as + * public inputs in little-endian format to a circuit. + */ +export function publicProofInputsFromBytes(options: PublicProofInputsFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'public_proof_inputs_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProofPointsFromBytesArguments { + bytes: RawTransactionArgument; +} +export interface ProofPointsFromBytesOptions { + package: string; + arguments: ProofPointsFromBytesArguments | [bytes: RawTransactionArgument]; +} +/** Creates a Groth16 `ProofPoints` from bytes. */ +export function proofPointsFromBytes(options: ProofPointsFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'proof_points_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PrepareVerifyingKeyArguments { + curve: RawTransactionArgument; + verifyingKey: RawTransactionArgument; +} +export interface PrepareVerifyingKeyOptions { + package: string; + arguments: + | PrepareVerifyingKeyArguments + | [curve: RawTransactionArgument, verifyingKey: RawTransactionArgument]; +} +/** + * @param curve: What elliptic curve construction to use. See `bls12381` and + * `bn254`. @param verifying_key: An Arkworks canonical compressed serialization of + * a verifying key. + * + * Returns four vectors of bytes representing the four components of a prepared + * verifying key. This step computes one pairing e(P, Q), and binds the + * verification to one particular proof statement. This can be used as inputs for + * the `verify_groth16_proof` function. + */ +export function prepareVerifyingKey(options: PrepareVerifyingKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; + const parameterNames = ['curve', 'verifyingKey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'prepare_verifying_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VerifyGroth16ProofArguments { + curve: RawTransactionArgument; + preparedVerifyingKey: RawTransactionArgument; + publicProofInputs: RawTransactionArgument; + proofPoints: RawTransactionArgument; +} +export interface VerifyGroth16ProofOptions { + package: string; + arguments: + | VerifyGroth16ProofArguments + | [ + curve: RawTransactionArgument, + preparedVerifyingKey: RawTransactionArgument, + publicProofInputs: RawTransactionArgument, + proofPoints: RawTransactionArgument, + ]; +} +/** + * @param curve: What elliptic curve construction to use. See the `bls12381` and + * `bn254` functions. @param prepared_verifying_key: Consists of four vectors of + * bytes representing the four components of a prepared verifying key. @param + * public_proof_inputs: Represent inputs that are public. @param proof_points: + * Represent three proof points. + * + * Returns a boolean indicating whether the proof is valid. + */ +export function verifyGroth16Proof(options: VerifyGroth16ProofOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null, null] satisfies (string | null)[]; + const parameterNames = ['curve', 'preparedVerifyingKey', 'publicProofInputs', 'proofPoints']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'groth16', + function: 'verify_groth16_proof', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts b/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts new file mode 100644 index 000000000..bbd1820ea --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts @@ -0,0 +1,65 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Generic Move and native functions for group operations. */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::group_ops'; +export const Element = new MoveStruct({ + name: `${$moduleName}::Element`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export interface BytesArguments { + e: RawTransactionArgument; +} +export interface BytesOptions { + package: string; + arguments: BytesArguments | [e: RawTransactionArgument]; + typeArguments: [string]; +} +export function bytes(options: BytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'group_ops', + function: 'bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface EqualArguments { + e1: RawTransactionArgument; + e2: RawTransactionArgument; +} +export interface EqualOptions { + package: string; + arguments: + | EqualArguments + | [e1: RawTransactionArgument, e2: RawTransactionArgument]; + typeArguments: [string]; +} +export function equal(options: EqualOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['e1', 'e2']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'group_ops', + function: 'equal', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts new file mode 100644 index 000000000..476def426 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts @@ -0,0 +1,57 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Module which defines hash functions. Note that Sha-256 and Sha3-256 is available + * in the std::hash module in the standard library. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface Blake2b256Arguments { + data: RawTransactionArgument; +} +export interface Blake2b256Options { + package: string; + arguments: Blake2b256Arguments | [data: RawTransactionArgument]; +} +/** + * @param data: Arbitrary binary data to hash Hash the input bytes using + * Blake2b-256 and returns 32 bytes. + */ +export function blake2b256(options: Blake2b256Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hash', + function: 'blake2b256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface Keccak256Arguments { + data: RawTransactionArgument; +} +export interface Keccak256Options { + package: string; + arguments: Keccak256Arguments | [data: RawTransactionArgument]; +} +/** + * @param data: Arbitrary binary data to hash Hash the input bytes using keccak256 + * and returns 32 bytes. + */ +export function keccak256(options: Keccak256Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hash', + function: 'keccak256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts new file mode 100644 index 000000000..8e6f4f6b3 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts @@ -0,0 +1,55 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** HEX (Base16) encoding utility. */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface EncodeArguments { + bytes: RawTransactionArgument; +} +export interface EncodeOptions { + package: string; + arguments: EncodeArguments | [bytes: RawTransactionArgument]; +} +/** Encode `bytes` in lowercase hex */ +export function encode(options: EncodeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hex', + function: 'encode', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DecodeArguments { + hex: RawTransactionArgument; +} +export interface DecodeOptions { + package: string; + arguments: DecodeArguments | [hex: RawTransactionArgument]; +} +/** + * Decode hex into `bytes` Takes a hex string (no 0x prefix) (e.g. b"0f3a") Returns + * vector of `bytes` that represents the hex string (e.g. x"0f3a") Hex string can + * be case insensitive (e.g. b"0F3A" and b"0f3a" both return x"0f3a") Aborts if the + * hex string does not have an even number of characters (as each hex character is + * 2 characters long) Aborts if the hex string contains non-valid hex characters + * (valid characters are 0 - 9, a - f, A - F) + */ +export function decode(options: DecodeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['hex']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hex', + function: 'decode', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts new file mode 100644 index 000000000..20fa6085f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts @@ -0,0 +1,31 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface HmacSha3_256Arguments { + key: RawTransactionArgument; + msg: RawTransactionArgument; +} +export interface HmacSha3_256Options { + package: string; + arguments: + | HmacSha3_256Arguments + | [key: RawTransactionArgument, msg: RawTransactionArgument]; +} +/** + * @param key: HMAC key, arbitrary bytes. @param msg: message to sign, arbitrary + * bytes. Returns the 32 bytes digest of HMAC-SHA3-256(key, msg). + */ +export function hmacSha3_256(options: HmacSha3_256Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['key', 'msg']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hmac', + function: 'hmac_sha3_256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts new file mode 100644 index 000000000..69d7da6d1 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts @@ -0,0 +1,1222 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Kiosk is a primitive for building safe, decentralized and trustless trading + * experiences. It allows storing and trading any types of assets as long as the + * creator of these assets implements a `TransferPolicy` for them. + * + * ### Principles and philosophy: + * + * - Kiosk provides guarantees of "true ownership"; - just like single owner + * objects, assets stored in the Kiosk can only be managed by the Kiosk owner. + * Only the owner can `place`, `take`, `list`, perform any other actions on + * assets in the Kiosk. + * + * - Kiosk aims to be generic - allowing for a small set of default behaviors and + * not imposing any restrictions on how the assets can be traded. The only + * default scenario is a `list` + `purchase` flow; any other trading logic can be + * implemented on top using the `list_with_purchase_cap` (and a matching + * `purchase_with_cap`) flow. + * + * - For every transaction happening with a third party a `TransferRequest` is + * created - this way creators are fully in control of the trading experience. + * + * ### Asset states in the Kiosk: + * + * - `placed` - An asset is `place`d into the Kiosk and can be `take`n out by the + * Kiosk owner; it's freely tradable and modifiable via the `borrow_mut` and + * `borrow_val` functions. + * + * - `locked` - Similar to `placed` except that `take` is disabled and the only way + * to move the asset out of the Kiosk is to `list` it or `list_with_purchase_cap` + * therefore performing a trade (issuing a `TransferRequest`). The check on the + * `lock` function makes sure that the `TransferPolicy` exists to not lock the + * item in a `Kiosk` forever. + * + * - `listed` - A `place`d or a `lock`ed item can be `list`ed for a fixed price + * allowing anyone to `purchase` it from the Kiosk. While listed, an item can not + * be taken or modified. However, an immutable borrow via `borrow` call is still + * available. The `delist` function returns the asset to the previous state. + * + * - `listed_exclusively` - An item is listed via the `list_with_purchase_cap` + * function (and a `PurchaseCap` is created). While listed this way, an item can + * not be `delist`-ed unless a `PurchaseCap` is returned. All actions available + * at this item state require a `PurchaseCap`: + * + * 1. `purchase_with_cap` - to purchase the item for a price equal or higher than + * the `min_price` set in the `PurchaseCap`. + * 2. `return_purchase_cap` - to return the `PurchaseCap` and return the asset + * into the previous state. + * + * When an item is listed exclusively it cannot be modified nor taken and losing a + * `PurchaseCap` would lock the item in the Kiosk forever. Therefore, it is + * recommended to only use `PurchaseCap` functionality in trusted applications and + * not use it for direct trading (eg sending to another account). + * + * ### Using multiple Transfer Policies for different "tracks": + * + * Every `purchase` or `purchase_with_purchase_cap` creates a `TransferRequest` hot + * potato which must be resolved in a matching `TransferPolicy` for the transaction + * to pass. While the default scenario implies that there should be a single + * `TransferPolicy` for `T`; it is possible to have multiple, each one having + * its own set of rules. + * + * ### Examples: + * + * - I create one `TransferPolicy` with "Royalty Rule" for everyone + * - I create a special `TransferPolicy` for bearers of a "Club Membership" object + * so they don't have to pay anything + * - I create and wrap a `TransferPolicy` so that players of my game can transfer + * items between `Kiosk`s in game without any charge (and maybe not even paying + * the price with a 0 SUI PurchaseCap) + * + * ``` + * Kiosk -> (Item, TransferRequest) + * ... TransferRequest ------> Common Transfer Policy + * ... TransferRequest ------> In-game Wrapped Transfer Policy + * ... TransferRequest ------> Club Membership Transfer Policy + * ``` + * + * See `transfer_policy` module for more details on how they function. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from './balance.js'; +const $moduleName = '0x2::kiosk'; +export const Kiosk = new MoveStruct({ + name: `${$moduleName}::Kiosk`, + fields: { + id: bcs.Address, + /** Balance of the Kiosk - all profits from sales go here. */ + profits: balance.Balance, + /** + * Always point to `sender` of the transaction. Can be changed by calling + * `set_owner` with Cap. + */ + owner: bcs.Address, + /** + * Number of items stored in a Kiosk. Used to allow unpacking an empty Kiosk if it + * was wrapped or has a single owner. + */ + item_count: bcs.u32(), + /** + * [DEPRECATED] Please, don't use the `allow_extensions` and the matching + * `set_allow_extensions` function - it is a legacy feature that is being replaced + * by the `kiosk_extension` module and its Extensions API. + * + * Exposes `uid_mut` publicly when set to `true`, set to `false` by default. + */ + allow_extensions: bcs.bool(), + }, +}); +export const KioskOwnerCap = new MoveStruct({ + name: `${$moduleName}::KioskOwnerCap`, + fields: { + id: bcs.Address, + for: bcs.Address, + }, +}); +export const PurchaseCap = new MoveStruct({ + name: `${$moduleName}::PurchaseCap`, + fields: { + id: bcs.Address, + /** ID of the `Kiosk` the cap belongs to. */ + kiosk_id: bcs.Address, + /** ID of the listed item. */ + item_id: bcs.Address, + /** Minimum price for which the item can be purchased. */ + min_price: bcs.u64(), + }, +}); +export const Borrow = new MoveStruct({ + name: `${$moduleName}::Borrow`, + fields: { + kiosk_id: bcs.Address, + item_id: bcs.Address, + }, +}); +export const Item = new MoveStruct({ + name: `${$moduleName}::Item`, + fields: { + id: bcs.Address, + }, +}); +export const Listing = new MoveStruct({ + name: `${$moduleName}::Listing`, + fields: { + id: bcs.Address, + is_exclusive: bcs.bool(), + }, +}); +export const Lock = new MoveStruct({ + name: `${$moduleName}::Lock`, + fields: { + id: bcs.Address, + }, +}); +export const ItemListed = new MoveStruct({ + name: `${$moduleName}::ItemListed`, + fields: { + kiosk: bcs.Address, + id: bcs.Address, + price: bcs.u64(), + }, +}); +export const ItemPurchased = new MoveStruct({ + name: `${$moduleName}::ItemPurchased`, + fields: { + kiosk: bcs.Address, + id: bcs.Address, + price: bcs.u64(), + }, +}); +export const ItemDelisted = new MoveStruct({ + name: `${$moduleName}::ItemDelisted`, + fields: { + kiosk: bcs.Address, + id: bcs.Address, + }, +}); +export interface DefaultOptions { + package: string; + arguments?: []; +} +/** + * Creates a new Kiosk in a default configuration: sender receives the + * `KioskOwnerCap` and becomes the Owner, the `Kiosk` is shared. + */ +export function _default(options: DefaultOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'default', + }); +} +export interface NewOptions { + package: string; + arguments?: []; +} +/** Creates a new `Kiosk` with a matching `KioskOwnerCap`. */ +export function _new(options: NewOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'new', + }); +} +export interface CloseAndWithdrawArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface CloseAndWithdrawOptions { + package: string; + arguments: + | CloseAndWithdrawArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; +} +/** + * Unpacks and destroys a Kiosk returning the profits (even if "0"). Can only be + * performed by the bearer of the `KioskOwnerCap` in the case where there's no + * items inside and a `Kiosk` is not shared. + */ +export function closeAndWithdraw(options: CloseAndWithdrawOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'close_and_withdraw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetOwnerArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface SetOwnerOptions { + package: string; + arguments: + | SetOwnerArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; +} +/** + * Change the `owner` field to the transaction sender. The change is purely + * cosmetical and does not affect any of the basic kiosk functions unless some + * logic for this is implemented in a third party module. + */ +export function setOwner(options: SetOwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'set_owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetOwnerCustomArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + owner: RawTransactionArgument; +} +export interface SetOwnerCustomOptions { + package: string; + arguments: + | SetOwnerCustomArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + owner: RawTransactionArgument, + ]; +} +/** + * Update the `owner` field with a custom address. Can be used for implementing a + * custom logic that relies on the `Kiosk` owner. + */ +export function setOwnerCustom(options: SetOwnerCustomOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'owner']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'set_owner_custom', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PlaceArguments> { + self: RawTransactionArgument; + cap: RawTransactionArgument; + item: RawTransactionArgument; +} +export interface PlaceOptions> { + package: string; + arguments: + | PlaceArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + item: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Place any object into a Kiosk. Performs an authorization check to make sure only + * owner can do that. + */ +export function place>(options: PlaceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'item']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'place', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LockArguments> { + self: RawTransactionArgument; + cap: RawTransactionArgument; + Policy: RawTransactionArgument; + item: RawTransactionArgument; +} +export interface LockOptions> { + package: string; + arguments: + | LockArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + Policy: RawTransactionArgument, + item: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Place an item to the `Kiosk` and issue a `Lock` for it. Once placed this way, an + * item can only be listed either with a `list` function or with a + * `list_with_purchase_cap`. + * + * Requires policy for `T` to make sure that there's an issued `TransferPolicy` and + * the item can be sold, otherwise the asset might be locked forever. + */ +export function lock>(options: LockOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null, `${options.typeArguments[0]}`] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'cap', 'Policy', 'item']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'lock', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TakeArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface TakeOptions { + package: string; + arguments: + | TakeArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Take any object from the Kiosk. Performs an authorization check to make sure + * only owner can do that. + */ +export function take(options: TakeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'take', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ListArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; + price: RawTransactionArgument; +} +export interface ListOptions { + package: string; + arguments: + | ListArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + price: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * List the item by setting a price and making it available for purchase. Performs + * an authorization check to make sure only owner can sell. + */ +export function list(options: ListOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID', 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id', 'price']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'list', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PlaceAndListArguments> { + self: RawTransactionArgument; + cap: RawTransactionArgument; + item: RawTransactionArgument; + price: RawTransactionArgument; +} +export interface PlaceAndListOptions> { + package: string; + arguments: + | PlaceAndListArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + item: RawTransactionArgument, + price: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Calls `place` and `list` together - simplifies the flow. */ +export function placeAndList>(options: PlaceAndListOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, `${options.typeArguments[0]}`, 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'cap', 'item', 'price']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'place_and_list', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DelistArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface DelistOptions { + package: string; + arguments: + | DelistArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Remove an existing listing from the `Kiosk` and keep the item in the user Kiosk. + * Can only be performed by the owner of the `Kiosk`. + */ +export function delist(options: DelistOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'delist', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PurchaseArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; + payment: RawTransactionArgument; +} +export interface PurchaseOptions { + package: string; + arguments: + | PurchaseArguments + | [ + self: RawTransactionArgument, + id: RawTransactionArgument, + payment: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Make a trade: pay the owner of the item and request a Transfer to the `target` + * kiosk (to prevent item being taken by the approving party). + * + * Received `TransferRequest` needs to be handled by the publisher of the T, if + * they have a method implemented that allows a trade, it is possible to request + * their approval (by calling some function) so that the trade can be finalized. + */ +export function purchase(options: PurchaseOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID', null] satisfies (string | null)[]; + const parameterNames = ['self', 'id', 'payment']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'purchase', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ListWithPurchaseCapArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; + minPrice: RawTransactionArgument; +} +export interface ListWithPurchaseCapOptions { + package: string; + arguments: + | ListWithPurchaseCapArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + minPrice: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Creates a `PurchaseCap` which gives the right to purchase an item for any price + * equal or higher than the `min_price`. + */ +export function listWithPurchaseCap(options: ListWithPurchaseCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID', 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id', 'minPrice']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'list_with_purchase_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PurchaseWithCapArguments { + self: RawTransactionArgument; + purchaseCap: RawTransactionArgument; + payment: RawTransactionArgument; +} +export interface PurchaseWithCapOptions { + package: string; + arguments: + | PurchaseWithCapArguments + | [ + self: RawTransactionArgument, + purchaseCap: RawTransactionArgument, + payment: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Unpack the `PurchaseCap` and call `purchase`. Sets the payment amount as the + * price for the listing making sure it's no less than `min_amount`. + */ +export function purchaseWithCap(options: PurchaseWithCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'purchaseCap', 'payment']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'purchase_with_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReturnPurchaseCapArguments { + self: RawTransactionArgument; + purchaseCap: RawTransactionArgument; +} +export interface ReturnPurchaseCapOptions { + package: string; + arguments: + | ReturnPurchaseCapArguments + | [self: RawTransactionArgument, purchaseCap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return the `PurchaseCap` without making a purchase; remove an active offer and + * allow the item for taking. Can only be returned to its `Kiosk`, aborts + * otherwise. + */ +export function returnPurchaseCap(options: ReturnPurchaseCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'purchaseCap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'return_purchase_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface WithdrawOptions { + package: string; + arguments: + | WithdrawArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + amount: RawTransactionArgument, + ]; +} +/** Withdraw profits from the Kiosk. */ +export function withdraw(options: WithdrawOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::option::Option'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'amount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'withdraw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasItemArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface HasItemOptions { + package: string; + arguments: + | HasItemArguments + | [self: RawTransactionArgument, id: RawTransactionArgument]; +} +/** Check whether the `item` is present in the `Kiosk`. */ +export function hasItem(options: HasItemOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'has_item', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasItemWithTypeArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface HasItemWithTypeOptions { + package: string; + arguments: + | HasItemWithTypeArguments + | [self: RawTransactionArgument, id: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether the `item` is present in the `Kiosk` and has type T. */ +export function hasItemWithType(options: HasItemWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'has_item_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsLockedArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface IsLockedOptions { + package: string; + arguments: + | IsLockedArguments + | [self: RawTransactionArgument, id: RawTransactionArgument]; +} +/** + * Check whether an item with the `id` is locked in the `Kiosk`. Meaning that the + * only two actions that can be performed on it are `list` and + * `list_with_purchase_cap`, it cannot be `take`n out of the `Kiosk`. + */ +export function isLocked(options: IsLockedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'is_locked', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsListedArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface IsListedOptions { + package: string; + arguments: + | IsListedArguments + | [self: RawTransactionArgument, id: RawTransactionArgument]; +} +/** Check whether an `item` is listed (exclusively or non exclusively). */ +export function isListed(options: IsListedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'is_listed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsListedExclusivelyArguments { + self: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface IsListedExclusivelyOptions { + package: string; + arguments: + | IsListedExclusivelyArguments + | [self: RawTransactionArgument, id: RawTransactionArgument]; +} +/** Check whether there's a `PurchaseCap` issued for an item. */ +export function isListedExclusively(options: IsListedExclusivelyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'is_listed_exclusively', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasAccessArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface HasAccessOptions { + package: string; + arguments: + | HasAccessArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; +} +/** Check whether the `KioskOwnerCap` matches the `Kiosk`. */ +export function hasAccess(options: HasAccessOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'has_access', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidMutAsOwnerArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface UidMutAsOwnerOptions { + package: string; + arguments: + | UidMutAsOwnerArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; +} +/** Access the `UID` using the `KioskOwnerCap`. */ +export function uidMutAsOwner(options: UidMutAsOwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'uid_mut_as_owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetAllowExtensionsArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + allowExtensions: RawTransactionArgument; +} +export interface SetAllowExtensionsOptions { + package: string; + arguments: + | SetAllowExtensionsArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + allowExtensions: RawTransactionArgument, + ]; +} +/** + * [DEPRECATED] Allow or disallow `uid` and `uid_mut` access via the + * `allow_extensions` setting. + */ +export function setAllowExtensions(options: SetAllowExtensionsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'bool'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'allowExtensions']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'set_allow_extensions', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidArguments { + self: RawTransactionArgument; +} +export interface UidOptions { + package: string; + arguments: UidArguments | [self: RawTransactionArgument]; +} +/** + * Get the immutable `UID` for dynamic field access. Always enabled. + * + * Given the &UID can be used for reading keys and authorization, its access + */ +export function uid(options: UidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'uid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidMutArguments { + self: RawTransactionArgument; +} +export interface UidMutOptions { + package: string; + arguments: UidMutArguments | [self: RawTransactionArgument]; +} +/** + * Get the mutable `UID` for dynamic field access and extensions. Aborts if + * `allow_extensions` set to `false`. + */ +export function uidMut(options: UidMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'uid_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface OwnerArguments { + self: RawTransactionArgument; +} +export interface OwnerOptions { + package: string; + arguments: OwnerArguments | [self: RawTransactionArgument]; +} +/** Get the owner of the Kiosk. */ +export function owner(options: OwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ItemCountArguments { + self: RawTransactionArgument; +} +export interface ItemCountOptions { + package: string; + arguments: ItemCountArguments | [self: RawTransactionArgument]; +} +/** Get the number of items stored in a Kiosk. */ +export function itemCount(options: ItemCountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'item_count', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProfitsAmountArguments { + self: RawTransactionArgument; +} +export interface ProfitsAmountOptions { + package: string; + arguments: ProfitsAmountArguments | [self: RawTransactionArgument]; +} +/** Get the amount of profits collected by selling items. */ +export function profitsAmount(options: ProfitsAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'profits_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProfitsMutArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface ProfitsMutOptions { + package: string; + arguments: + | ProfitsMutArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; +} +/** Get mutable access to `profits` - owner only action. */ +export function profitsMut(options: ProfitsMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'profits_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BorrowArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface BorrowOptions { + package: string; + arguments: + | BorrowArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Immutably borrow an item from the `Kiosk`. Any item can be `borrow`ed at any + * time. + */ +export function borrow(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface BorrowMutOptions { + package: string; + arguments: + | BorrowMutArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Mutably borrow an item from the `Kiosk`. Item can be `borrow_mut`ed only if it's + * not `is_listed`. + */ +export function borrowMut(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowValArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + id: RawTransactionArgument; +} +export interface BorrowValOptions { + package: string; + arguments: + | BorrowValArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + id: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Take the item from the `Kiosk` with a guarantee that it will be returned. Item + * can be `borrow_val`-ed only if it's not `is_listed`. + */ +export function borrowVal(options: BorrowValOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'borrow_val', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReturnValArguments> { + self: RawTransactionArgument; + item: RawTransactionArgument; + borrow: RawTransactionArgument; +} +export interface ReturnValOptions> { + package: string; + arguments: + | ReturnValArguments + | [ + self: RawTransactionArgument, + item: RawTransactionArgument, + borrow: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Return the borrowed item to the `Kiosk`. This method cannot be avoided if + * `borrow_val` is used. + */ +export function returnVal>(options: ReturnValOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['self', 'item', 'borrow']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'return_val', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface KioskOwnerCapForArguments { + cap: RawTransactionArgument; +} +export interface KioskOwnerCapForOptions { + package: string; + arguments: KioskOwnerCapForArguments | [cap: RawTransactionArgument]; +} +/** Get the `for` field of the `KioskOwnerCap`. */ +export function kioskOwnerCapFor(options: KioskOwnerCapForOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'kiosk_owner_cap_for', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PurchaseCapKioskArguments { + self: RawTransactionArgument; +} +export interface PurchaseCapKioskOptions { + package: string; + arguments: PurchaseCapKioskArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `kiosk_id` from the `PurchaseCap`. */ +export function purchaseCapKiosk(options: PurchaseCapKioskOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'purchase_cap_kiosk', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PurchaseCapItemArguments { + self: RawTransactionArgument; +} +export interface PurchaseCapItemOptions { + package: string; + arguments: PurchaseCapItemArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `Item_id` from the `PurchaseCap`. */ +export function purchaseCapItem(options: PurchaseCapItemOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'purchase_cap_item', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PurchaseCapMinPriceArguments { + self: RawTransactionArgument; +} +export interface PurchaseCapMinPriceOptions { + package: string; + arguments: PurchaseCapMinPriceArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `min_price` from the `PurchaseCap`. */ +export function purchaseCapMinPrice(options: PurchaseCapMinPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk', + function: 'purchase_cap_min_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts new file mode 100644 index 000000000..b75aa51c9 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts @@ -0,0 +1,467 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * This module implements the Kiosk Extensions functionality. It allows exposing + * previously protected (only-owner) methods to third-party apps. + * + * A Kiosk Extension is a module that implements any functionality on top of the + * `Kiosk` without discarding nor blocking the base. Given that `Kiosk` itself is a + * trading primitive, most of the extensions are expected to be related to trading. + * However, there's no limit to what can be built using the `kiosk_extension` + * module, as it gives certain benefits such as using `Kiosk` as the storage for + * any type of data / assets. + * + * ### Flow: + * + * - An extension can only be installed by the Kiosk Owner and requires an + * authorization via the `KioskOwnerCap`. + * - When installed, the extension is given a permission bitmap that allows it to + * perform certain protected actions (eg `place`, `lock`). However, it is + * possible to install an extension that does not have any permissions. + * - Kiosk Owner can `disable` the extension at any time, which prevents it from + * performing any protected actions. The storage is still available to the + * extension until it is completely removed. + * - A disabled extension can be `enable`d at any time giving the permissions back + * to the extension. + * - An extension permissions follow the all-or-nothing policy. Either all of the + * requested permissions are granted or none of them (can't install). + * + * ### Examples: + * + * - An Auction extension can utilize the storage to store Auction-related data + * while utilizing the same `Kiosk` object that the items are stored in. + * - A Marketplace extension that implements custom events and fees for the default + * trading functionality. + * + * ### Notes: + * + * - Trading functionality can utilize the `PurchaseCap` to build a custom logic + * around the purchase flow. However, it should be carefully managed to prevent + * asset locking. + * - `kiosk_extension` is a friend module to `kiosk` and has access to its internal + * functions (such as `place_internal` and `lock_internal` to implement custom + * authorization scheme for `place` and `lock` respectively). + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as bag from './bag.js'; +const $moduleName = '0x2::kiosk_extension'; +export const Extension = new MoveStruct({ + name: `${$moduleName}::Extension`, + fields: { + /** + * Storage for the extension, an isolated Bag. By putting the extension into a + * single dynamic field, we reduce the amount of fields on the top level (eg items + * / listings) while giving extension developers the ability to store any data they + * want. + */ + storage: bag.Bag, + /** + * Bitmap of permissions that the extension has (can be revoked any moment). It's + * all or nothing policy - either the extension has the required permissions or no + * permissions at all. + * + * 1st bit - `place` - allows to place items for sale 2nd bit - `lock` and + * `place` - allows to lock items (and place) + * + * For example: + * + * - `10` - allows to place items and lock them. + * - `11` - allows to place items and lock them (`lock` includes `place`). + * - `01` - allows to place items, but not lock them. + * - `00` - no permissions. + */ + permissions: bcs.u128(), + /** + * Whether the extension can call protected actions. By default, all extensions are + * enabled (on `add` call), however the Kiosk owner can disable them at any time. + * + * Disabling the extension does not limit its access to the storage. + */ + is_enabled: bcs.bool(), + }, +}); +export const ExtensionKey = new MoveStruct({ + name: `${$moduleName}::ExtensionKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface AddArguments> { + Ext: RawTransactionArgument; + self: RawTransactionArgument; + cap: RawTransactionArgument; + permissions: RawTransactionArgument; +} +export interface AddOptions> { + package: string; + arguments: + | AddArguments + | [ + Ext: RawTransactionArgument, + self: RawTransactionArgument, + cap: RawTransactionArgument, + permissions: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Add an extension to the Kiosk. Can only be performed by the owner. The extension + * witness is required to allow extensions define their set of permissions in the + * custom `add` call. + */ +export function add>(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null, null, 'u128'] satisfies ( + | string + | null + )[]; + const parameterNames = ['Ext', 'self', 'cap', 'permissions']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DisableArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface DisableOptions { + package: string; + arguments: + | DisableArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Revoke permissions from the extension. While it does not remove the extension + * completely, it keeps it from performing any protected actions. The storage is + * still available to the extension (until it's removed). + */ +export function disable(options: DisableOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'disable', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface EnableArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface EnableOptions { + package: string; + arguments: + | EnableArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Re-enable the extension allowing it to call protected actions (eg `place`, + * `lock`). By default, all added extensions are enabled. Kiosk owner can disable + * them via `disable` call. + */ +export function enable(options: EnableOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'enable', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface RemoveOptions { + package: string; + arguments: + | RemoveArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Remove an extension from the Kiosk. Can only be performed by the owner, the + * extension storage must be empty for the transaction to succeed. + */ +export function remove(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface StorageArguments> { + Ext: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface StorageOptions> { + package: string; + arguments: + | StorageArguments + | [Ext: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get immutable access to the extension storage. Can only be performed by the + * extension as long as the extension is installed. + */ +export function storage>(options: StorageOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['Ext', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'storage', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface StorageMutArguments> { + Ext: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface StorageMutOptions> { + package: string; + arguments: + | StorageMutArguments + | [Ext: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get mutable access to the extension storage. Can only be performed by the + * extension as long as the extension is installed. Disabling the extension does + * not prevent it from accessing the storage. + * + * Potentially dangerous: extension developer can keep data in a Bag therefore + * never really allowing the KioskOwner to remove the extension. However, it is the + * case with any other solution (1) and this way we prevent intentional extension + * freeze when the owner wants to ruin a trade (2) - eg locking extension while an + * auction is in progress. + * + * Extensions should be crafted carefully, and the KioskOwner should be aware of + * the risks. + */ +export function storageMut>(options: StorageMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['Ext', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'storage_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PlaceArguments, T extends BcsType> { + Ext: RawTransactionArgument; + self: RawTransactionArgument; + item: RawTransactionArgument; + Policy: RawTransactionArgument; +} +export interface PlaceOptions, T extends BcsType> { + package: string; + arguments: + | PlaceArguments + | [ + Ext: RawTransactionArgument, + self: RawTransactionArgument, + item: RawTransactionArgument, + Policy: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Protected action: place an item into the Kiosk. Can be performed by an + * authorized extension. The extension must have the `place` permission or a `lock` + * permission. + * + * To prevent non-tradable items from being placed into `Kiosk` the method requires + * a `TransferPolicy` for the placed type to exist. + */ +export function place, T extends BcsType>( + options: PlaceOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + null, + `${options.typeArguments[1]}`, + null, + ] satisfies (string | null)[]; + const parameterNames = ['Ext', 'self', 'item', 'Policy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'place', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LockArguments, T extends BcsType> { + Ext: RawTransactionArgument; + self: RawTransactionArgument; + item: RawTransactionArgument; + Policy: RawTransactionArgument; +} +export interface LockOptions, T extends BcsType> { + package: string; + arguments: + | LockArguments + | [ + Ext: RawTransactionArgument, + self: RawTransactionArgument, + item: RawTransactionArgument, + Policy: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Protected action: lock an item in the Kiosk. Can be performed by an authorized + * extension. The extension must have the `lock` permission. + */ +export function lock, T extends BcsType>( + options: LockOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[0]}`, + null, + `${options.typeArguments[1]}`, + null, + ] satisfies (string | null)[]; + const parameterNames = ['Ext', 'self', 'item', 'Policy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'lock', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsInstalledArguments { + self: RawTransactionArgument; +} +export interface IsInstalledOptions { + package: string; + arguments: IsInstalledArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether an extension of type `Ext` is installed. */ +export function isInstalled(options: IsInstalledOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'is_installed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEnabledArguments { + self: RawTransactionArgument; +} +export interface IsEnabledOptions { + package: string; + arguments: IsEnabledArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether an extension of type `Ext` is enabled. */ +export function isEnabled(options: IsEnabledOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'is_enabled', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CanPlaceArguments { + self: RawTransactionArgument; +} +export interface CanPlaceOptions { + package: string; + arguments: CanPlaceArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether an extension of type `Ext` can `place` into Kiosk. */ +export function canPlace(options: CanPlaceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'can_place', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CanLockArguments { + self: RawTransactionArgument; +} +export interface CanLockOptions { + package: string; + arguments: CanLockArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Check whether an extension of type `Ext` can `lock` items in Kiosk. Locking also + * enables `place`. + */ +export function canLock(options: CanLockOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'kiosk_extension', + function: 'can_lock', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts new file mode 100644 index 000000000..37f9652d1 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts @@ -0,0 +1,512 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Similar to `sui::table` but the values are linked together, allowing for ordered + * insertion and removal + */ + +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::linked_table'; +export function LinkedTable>(...typeParameters: [K]) { + return new MoveStruct({ + name: `${$moduleName}::LinkedTable<${typeParameters[0].name as K['name']}, phantom V>`, + fields: { + /** the ID of this table */ + id: bcs.Address, + /** the number of key-value pairs in the table */ + size: bcs.u64(), + /** the front of the table, i.e. the key of the first entry */ + head: bcs.option(typeParameters[0]), + /** the back of the table, i.e. the key of the last entry */ + tail: bcs.option(typeParameters[0]), + }, + }); +} +export function Node, V extends BcsType>(...typeParameters: [K, V]) { + return new MoveStruct({ + name: `${$moduleName}::Node<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, + fields: { + /** the previous key */ + prev: bcs.option(typeParameters[0]), + /** the next key */ + next: bcs.option(typeParameters[0]), + /** the value being stored */ + value: typeParameters[1], + }, + }); +} +export interface NewOptions { + package: string; + arguments?: []; + typeArguments: [string, string]; +} +/** Creates a new, empty table */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'new', + typeArguments: options.typeArguments, + }); +} +export interface FrontArguments { + table: RawTransactionArgument; +} +export interface FrontOptions { + package: string; + arguments: FrontArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns the key for the first element in the table, or None if the table is + * empty + */ +export function front(options: FrontOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'front', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BackArguments { + table: RawTransactionArgument; +} +export interface BackOptions { + package: string; + arguments: BackArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns the key for the last element in the table, or None if the table is empty */ +export function back(options: BackOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PushFrontArguments, V extends BcsType> { + table: RawTransactionArgument; + k: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface PushFrontOptions, V extends BcsType> { + package: string; + arguments: + | PushFrontArguments + | [ + table: RawTransactionArgument, + k: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Inserts a key-value pair at the front of the table, i.e. the newly inserted pair + * will be the first element in the table Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with + * that key `k: K`. + */ +export function pushFront, V extends BcsType>( + options: PushFrontOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['table', 'k', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'push_front', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PushBackArguments, V extends BcsType> { + table: RawTransactionArgument; + k: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface PushBackOptions, V extends BcsType> { + package: string; + arguments: + | PushBackArguments + | [ + table: RawTransactionArgument, + k: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Inserts a key-value pair at the back of the table, i.e. the newly inserted pair + * will be the last element in the table Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with + * that key `k: K`. + */ +export function pushBack, V extends BcsType>( + options: PushBackOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['table', 'k', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'push_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutable borrows the value associated with the key in the table + * `table: &LinkedTable`. Aborts with + * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry + * with that key `k: K`. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the value associated with the key in the table + * `table: &mut LinkedTable`. Aborts with + * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry + * with that key `k: K`. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PrevArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface PrevOptions> { + package: string; + arguments: + | PrevArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Borrows the key for the previous entry of the specified key `k: K` in the table + * `table: &LinkedTable`. Returns None if the entry does not have a + * predecessor. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table + * does not have an entry with that key `k: K` + */ +export function prev>(options: PrevOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'prev', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NextArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface NextOptions> { + package: string; + arguments: + | NextArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Borrows the key for the next entry of the specified key `k: K` in the table + * `table: &LinkedTable`. Returns None if the entry does not have a + * predecessor. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table + * does not have an entry with that key `k: K` + */ +export function next>(options: NextOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'next', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the key-value pair in the table `table: &mut LinkedTable` and + * returns the value. This splices the element out of the ordering. Aborts with + * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry + * with that key `k: K`. Note: this is also what happens when the table is empty. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopFrontArguments { + table: RawTransactionArgument; +} +export interface PopFrontOptions { + package: string; + arguments: PopFrontArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the front of the table `table: &mut LinkedTable`, returns the key + * and value. Aborts with `ETableIsEmpty` if the table is empty + */ +export function popFront(options: PopFrontOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'pop_front', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopBackArguments { + table: RawTransactionArgument; +} +export interface PopBackOptions { + package: string; + arguments: PopBackArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the back of the table `table: &mut LinkedTable`, returns the key + * and value. Aborts with `ETableIsEmpty` if the table is empty + */ +export function popBack(options: PopBackOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'pop_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true iff there is a value associated with the key `k: K` in table + * `table: &LinkedTable` + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + table: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns the size of the table, the number of key-value pairs */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + table: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns true iff the table is empty (if `length` returns `0`) */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments { + table: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains + * values + */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DropArguments { + table: RawTransactionArgument; +} +export interface DropOptions { + package: string; + arguments: DropArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Drop a possibly non-empty table. Usable only if the value type `V` has the + * `drop` ability + */ +export function drop(options: DropOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'linked_table', + function: 'drop', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/math.ts b/packages/suins/src/contracts/suins_auction/deps/sui/math.ts new file mode 100644 index 000000000..a3d30fb52 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/math.ts @@ -0,0 +1,166 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * DEPRECATED, use the each integer type's individual module instead, e.g. + * `std::u64` + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package: string; + arguments: + | MaxArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::max` instead */ +export function max(options: MaxOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package: string; + arguments: + | MinArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::min` instead */ +export function min(options: MinOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package: string; + arguments: + | DiffArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::diff` instead */ +export function diff(options: DiffOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::pow` instead */ +export function pow(options: PowOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::sqrt` instead */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtU128Arguments { + x: RawTransactionArgument; +} +export interface SqrtU128Options { + package: string; + arguments: SqrtU128Arguments | [x: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u128::sqrt` instead */ +export function sqrtU128(options: SqrtU128Options) { + const packageAddress = options.package; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'sqrt_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** DEPRECATED, use `std::u64::divide_and_round_up` instead */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'math', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts b/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts new file mode 100644 index 000000000..865f6d334 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts @@ -0,0 +1,247 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::nitro_attestation'; +export const PCREntry = new MoveStruct({ + name: `${$moduleName}::PCREntry`, + fields: { + index: bcs.u8(), + value: bcs.vector(bcs.u8()), + }, +}); +export const NitroAttestationDocument = new MoveStruct({ + name: `${$moduleName}::NitroAttestationDocument`, + fields: { + /** Issuing Nitro hypervisor module ID. */ + module_id: bcs.vector(bcs.u8()), + /** UTC time when document was created, in milliseconds since UNIX epoch. */ + timestamp: bcs.u64(), + /** The digest function used for calculating the register values. */ + digest: bcs.vector(bcs.u8()), + /** + * A list of PCREntry containing the index and the PCR bytes. + * . + */ + pcrs: bcs.vector(PCREntry), + /** + * An optional DER-encoded key the attestation, consumer can use to encrypt data + * with. + */ + public_key: bcs.option(bcs.vector(bcs.u8())), + /** Additional signed user data, defined by protocol. */ + user_data: bcs.option(bcs.vector(bcs.u8())), + /** + * An optional cryptographic nonce provided by the attestation consumer as a proof + * of authenticity. + */ + nonce: bcs.option(bcs.vector(bcs.u8())), + }, +}); +export interface LoadNitroAttestationArguments { + attestation: RawTransactionArgument; +} +export interface LoadNitroAttestationOptions { + package: string; + arguments: LoadNitroAttestationArguments | [attestation: RawTransactionArgument]; +} +/** + * @param attestation: attesttaion documents bytes data. @param clock: the clock + * object. + * + * Returns the parsed NitroAttestationDocument after verifying the attestation, may + * abort with errors described above. + */ +export function loadNitroAttestation(options: LoadNitroAttestationOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'load_nitro_attestation', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ModuleIdArguments { + attestation: RawTransactionArgument; +} +export interface ModuleIdOptions { + package: string; + arguments: ModuleIdArguments | [attestation: RawTransactionArgument]; +} +export function moduleId(options: ModuleIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'module_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TimestampArguments { + attestation: RawTransactionArgument; +} +export interface TimestampOptions { + package: string; + arguments: TimestampArguments | [attestation: RawTransactionArgument]; +} +export function timestamp(options: TimestampOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'timestamp', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DigestArguments { + attestation: RawTransactionArgument; +} +export interface DigestOptions { + package: string; + arguments: DigestArguments | [attestation: RawTransactionArgument]; +} +export function digest(options: DigestOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'digest', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PcrsArguments { + attestation: RawTransactionArgument; +} +export interface PcrsOptions { + package: string; + arguments: PcrsArguments | [attestation: RawTransactionArgument]; +} +/** + * Returns a list of mapping PCREntry containg the index and the PCR bytes. AWS + * supports PCR0-31. All-zero PCR values are excluded. + */ +export function pcrs(options: PcrsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'pcrs', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PublicKeyArguments { + attestation: RawTransactionArgument; +} +export interface PublicKeyOptions { + package: string; + arguments: PublicKeyArguments | [attestation: RawTransactionArgument]; +} +export function publicKey(options: PublicKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'public_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UserDataArguments { + attestation: RawTransactionArgument; +} +export interface UserDataOptions { + package: string; + arguments: UserDataArguments | [attestation: RawTransactionArgument]; +} +export function userData(options: UserDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'user_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NonceArguments { + attestation: RawTransactionArgument; +} +export interface NonceOptions { + package: string; + arguments: NonceArguments | [attestation: RawTransactionArgument]; +} +export function nonce(options: NonceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['attestation']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'nonce', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IndexArguments { + entry: RawTransactionArgument; +} +export interface IndexOptions { + package: string; + arguments: IndexArguments | [entry: RawTransactionArgument]; +} +export function index(options: IndexOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['entry']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'index', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValueArguments { + entry: RawTransactionArgument; +} +export interface ValueOptions { + package: string; + arguments: ValueArguments | [entry: RawTransactionArgument]; +} +export function value(options: ValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['entry']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'nitro_attestation', + function: 'value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object.ts new file mode 100644 index 000000000..afdf8f2c6 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/object.ts @@ -0,0 +1,317 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Sui object identifiers */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::object'; +export const ID = new MoveStruct({ + name: `${$moduleName}::ID`, + fields: { + bytes: bcs.Address, + }, +}); +export const UID = new MoveStruct({ + name: `${$moduleName}::UID`, + fields: { + id: bcs.Address, + }, +}); +export interface IdToBytesArguments { + id: RawTransactionArgument; +} +export interface IdToBytesOptions { + package: string; + arguments: IdToBytesArguments | [id: RawTransactionArgument]; +} +/** Get the raw bytes of a `ID` */ +export function idToBytes(options: IdToBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdToAddressArguments { + id: RawTransactionArgument; +} +export interface IdToAddressOptions { + package: string; + arguments: IdToAddressArguments | [id: RawTransactionArgument]; +} +/** Get the inner bytes of `id` as an address. */ +export function idToAddress(options: IdToAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_to_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdFromBytesArguments { + bytes: RawTransactionArgument; +} +export interface IdFromBytesOptions { + package: string; + arguments: IdFromBytesArguments | [bytes: RawTransactionArgument]; +} +/** Make an `ID` from raw bytes. */ +export function idFromBytes(options: IdFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdFromAddressArguments { + bytes: RawTransactionArgument; +} +export interface IdFromAddressOptions { + package: string; + arguments: IdFromAddressArguments | [bytes: RawTransactionArgument]; +} +/** Make an `ID` from an address. */ +export function idFromAddress(options: IdFromAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_from_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidAsInnerArguments { + uid: RawTransactionArgument; +} +export interface UidAsInnerOptions { + package: string; + arguments: UidAsInnerArguments | [uid: RawTransactionArgument]; +} +/** Get the inner `ID` of `uid` */ +export function uidAsInner(options: UidAsInnerOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['uid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'uid_as_inner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidToInnerArguments { + uid: RawTransactionArgument; +} +export interface UidToInnerOptions { + package: string; + arguments: UidToInnerArguments | [uid: RawTransactionArgument]; +} +/** Get the raw bytes of a `uid`'s inner `ID` */ +export function uidToInner(options: UidToInnerOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['uid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'uid_to_inner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidToBytesArguments { + uid: RawTransactionArgument; +} +export interface UidToBytesOptions { + package: string; + arguments: UidToBytesArguments | [uid: RawTransactionArgument]; +} +/** Get the raw bytes of a `UID` */ +export function uidToBytes(options: UidToBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['uid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'uid_to_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidToAddressArguments { + uid: RawTransactionArgument; +} +export interface UidToAddressOptions { + package: string; + arguments: UidToAddressArguments | [uid: RawTransactionArgument]; +} +/** Get the inner bytes of `id` as an address. */ +export function uidToAddress(options: UidToAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['uid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'uid_to_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewOptions { + package: string; + arguments?: []; +} +/** + * Create a new object. Returns the `UID` that must be stored in a Sui object. This + * is the only way to create `UID`s. + */ +export function _new(options: NewOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'new', + }); +} +export interface DeleteArguments { + id: RawTransactionArgument; +} +export interface DeleteOptions { + package: string; + arguments: DeleteArguments | [id: RawTransactionArgument]; +} +/** + * Delete the object and its `UID`. This is the only way to eliminate a `UID`. This + * exists to inform Sui of object deletions. When an object gets unpacked, the + * programmer will have to do something with its `UID`. The implementation of this + * function emits a deleted system event so Sui knows to process the object + * deletion + */ +export function _delete(options: DeleteOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['id']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'delete', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IdArguments> { + obj: RawTransactionArgument; +} +export interface IdOptions> { + package: string; + arguments: IdArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the underlying `ID` of `obj` */ +export function id>(options: IdOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowIdArguments> { + obj: RawTransactionArgument; +} +export interface BorrowIdOptions> { + package: string; + arguments: BorrowIdArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** Borrow the underlying `ID` of `obj` */ +export function borrowId>(options: BorrowIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'borrow_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IdBytesArguments> { + obj: RawTransactionArgument; +} +export interface IdBytesOptions> { + package: string; + arguments: IdBytesArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the raw bytes for the underlying `ID` of `obj` */ +export function idBytes>(options: IdBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IdAddressArguments> { + obj: RawTransactionArgument; +} +export interface IdAddressOptions> { + package: string; + arguments: IdAddressArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the inner bytes for the underlying `ID` of `obj` */ +export function idAddress>(options: IdAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object', + function: 'id_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts new file mode 100644 index 000000000..8615c84bb --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts @@ -0,0 +1,321 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Similar to `sui::bag`, an `ObjectBag` is a heterogeneous map-like collection. + * But unlike `sui::bag`, the values bound to these dynamic fields _must_ be + * objects themselves. This allows for the objects to still exist in storage, which + * may be important for external tools. The difference is otherwise not observable + * from within Move. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::object_bag'; +export const ObjectBag = new MoveStruct({ + name: `${$moduleName}::ObjectBag`, + fields: { + /** the ID of this bag */ + id: bcs.Address, + /** the number of key-value pairs in the bag */ + size: bcs.u64(), + }, +}); +export interface NewOptions { + package: string; + arguments?: []; +} +/** Creates a new, empty bag */ +export function _new(options: NewOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'new', + }); +} +export interface AddArguments, V extends BcsType> { + bag: RawTransactionArgument; + k: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface AddOptions, V extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + bag: RawTransactionArgument, + k: RawTransactionArgument, + v: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a key-value pair to the bag `bag: &mut ObjectBag` Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with + * that key `k: K`. + */ +export function add, V extends BcsType>(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['bag', 'k', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutably borrows the value associated with the key in the bag + * `bag: &ObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the + * bag does not have an entry with that key `k: K`. Aborts with + * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, + * but the value does not have the specified type. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the value associated with the key in the bag + * `bag: &mut ObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if + * the bag does not have an entry with that key `k: K`. Aborts with + * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, + * but the value does not have the specified type. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the key-value pair in the bag `bag: &mut ObjectBag` and returns + * the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does + * not have an entry with that key `k: K`. Aborts with + * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, + * but the value does not have the specified type. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns true iff there is an value associated with the key `k: K` in the bag + * `bag: &ObjectBag` + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsWithTypeArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsWithTypeOptions> { + package: string; + arguments: + | ContainsWithTypeArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true iff there is an value associated with the key `k: K` in the bag + * `bag: &ObjectBag` with an assigned value of type `V` + */ +export function containsWithType>(options: ContainsWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'contains_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + bag: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [bag: RawTransactionArgument]; +} +/** Returns the size of the bag, the number of key-value pairs */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsEmptyArguments { + bag: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [bag: RawTransactionArgument]; +} +/** Returns true iff the bag is empty (if `length` returns `0`) */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DestroyEmptyArguments { + bag: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [bag: RawTransactionArgument]; +} +/** + * Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains + * values + */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['bag']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValueIdArguments> { + bag: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ValueIdOptions> { + package: string; + arguments: + | ValueIdArguments + | [bag: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Returns the ID of the object associated with the key if the bag has an entry + * with key `k: K` Returns none otherwise + */ +export function valueId>(options: ValueIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['bag', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_bag', + function: 'value_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts new file mode 100644 index 000000000..a427e804e --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts @@ -0,0 +1,297 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Similar to `sui::table`, an `ObjectTable` is a map-like collection. But + * unlike `sui::table`, the values bound to these dynamic fields _must_ be objects + * themselves. This allows for the objects to still exist within in storage, which + * may be important for external tools. The difference is otherwise not observable + * from within Move. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::object_table'; +export const ObjectTable = new MoveStruct({ + name: `${$moduleName}::ObjectTable`, + fields: { + /** the ID of this table */ + id: bcs.Address, + /** the number of key-value pairs in the table */ + size: bcs.u64(), + }, +}); +export interface NewOptions { + package: string; + arguments?: []; + typeArguments: [string, string]; +} +/** Creates a new, empty table */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'new', + typeArguments: options.typeArguments, + }); +} +export interface AddArguments, V extends BcsType> { + table: RawTransactionArgument; + k: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface AddOptions, V extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + table: RawTransactionArgument, + k: RawTransactionArgument, + v: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a key-value pair to the table `table: &mut ObjectTable` Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with + * that key `k: K`. + */ +export function add, V extends BcsType>(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['table', 'k', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutable borrows the value associated with the key in the table + * `table: &ObjectTable`. Aborts with + * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry + * with that key `k: K`. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the value associated with the key in the table + * `table: &mut ObjectTable`. Aborts with + * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry + * with that key `k: K`. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the key-value pair in the table `table: &mut ObjectTable` and + * returns the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the + * table does not have an entry with that key `k: K`. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true if there is a value associated with the key `k: K` in table + * `table: &ObjectTable` + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + table: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns the size of the table, the number of key-value pairs */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + table: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns true if the table is empty (if `length` returns `0`) */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments { + table: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains + * values + */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ValueIdArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ValueIdOptions> { + package: string; + arguments: + | ValueIdArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns the ID of the object associated with the key if the table has an entry + * with key `k: K` Returns none otherwise + */ +export function valueId>(options: ValueIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'object_table', + function: 'value_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/package.ts b/packages/suins/src/contracts/suins_auction/deps/sui/package.ts new file mode 100644 index 000000000..24a37c8c2 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/package.ts @@ -0,0 +1,572 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Functions for operating on Move packages from within Move: + * + * - Creating proof-of-publish objects from one-time witnesses + * - Administering package upgrades through upgrade policies. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::package'; +export const UpgradeCap = new MoveStruct({ + name: `${$moduleName}::UpgradeCap`, + fields: { + id: bcs.Address, + /** (Mutable) ID of the package that can be upgraded. */ + package: bcs.Address, + /** + * (Mutable) The number of upgrades that have been applied successively to the + * original package. Initially 0. + */ + version: bcs.u64(), + /** What kind of upgrades are allowed. */ + policy: bcs.u8(), + }, +}); +export const Publisher = new MoveStruct({ + name: `${$moduleName}::Publisher`, + fields: { + id: bcs.Address, + package: bcs.string(), + module_name: bcs.string(), + }, +}); +export const UpgradeTicket = new MoveStruct({ + name: `${$moduleName}::UpgradeTicket`, + fields: { + /** (Immutable) ID of the `UpgradeCap` this originated from. */ + cap: bcs.Address, + /** (Immutable) ID of the package that can be upgraded. */ + package: bcs.Address, + /** (Immutable) The policy regarding what kind of upgrade this ticket permits. */ + policy: bcs.u8(), + /** + * (Immutable) SHA256 digest of the bytecode and transitive dependencies that will + * be used in the upgrade. + */ + digest: bcs.vector(bcs.u8()), + }, +}); +export const UpgradeReceipt = new MoveStruct({ + name: `${$moduleName}::UpgradeReceipt`, + fields: { + /** (Immutable) ID of the `UpgradeCap` this originated from. */ + cap: bcs.Address, + /** (Immutable) ID of the package after it was upgraded. */ + package: bcs.Address, + }, +}); +export interface ClaimArguments> { + otw: RawTransactionArgument; +} +export interface ClaimOptions> { + package: string; + arguments: ClaimArguments | [otw: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Claim a Publisher object. Requires a One-Time-Witness to prove ownership. Due to + * this constraint there can be only one Publisher object per module but multiple + * per package (!). + */ +export function claim>(options: ClaimOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['otw']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'claim', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ClaimAndKeepArguments> { + otw: RawTransactionArgument; +} +export interface ClaimAndKeepOptions> { + package: string; + arguments: ClaimAndKeepArguments | [otw: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Claim a Publisher object and send it to transaction sender. Since this function + * can only be called in the module initializer, the sender is the publisher. + */ +export function claimAndKeep>(options: ClaimAndKeepOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['otw']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'claim_and_keep', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BurnPublisherArguments { + self: RawTransactionArgument; +} +export interface BurnPublisherOptions { + package: string; + arguments: BurnPublisherArguments | [self: RawTransactionArgument]; +} +/** + * Destroy a Publisher object effectively removing all privileges associated with + * it. + */ +export function burnPublisher(options: BurnPublisherOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'burn_publisher', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromPackageArguments { + self: RawTransactionArgument; +} +export interface FromPackageOptions { + package: string; + arguments: FromPackageArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether type belongs to the same package as the publisher object. */ +export function fromPackage(options: FromPackageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'from_package', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromModuleArguments { + self: RawTransactionArgument; +} +export interface FromModuleOptions { + package: string; + arguments: FromModuleArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether a type belongs to the same module as the publisher object. */ +export function fromModule(options: FromModuleOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'from_module', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublishedModuleArguments { + self: RawTransactionArgument; +} +export interface PublishedModuleOptions { + package: string; + arguments: PublishedModuleArguments | [self: RawTransactionArgument]; +} +/** Read the name of the module. */ +export function publishedModule(options: PublishedModuleOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'published_module', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PublishedPackageArguments { + self: RawTransactionArgument; +} +export interface PublishedPackageOptions { + package: string; + arguments: PublishedPackageArguments | [self: RawTransactionArgument]; +} +/** Read the package address string. */ +export function publishedPackage(options: PublishedPackageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'published_package', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpgradePackageArguments { + cap: RawTransactionArgument; +} +export interface UpgradePackageOptions { + package: string; + arguments: UpgradePackageArguments | [cap: RawTransactionArgument]; +} +/** + * The ID of the package that this cap authorizes upgrades for. Can be `0x0` if the + * cap cannot currently authorize an upgrade because there is already a pending + * upgrade in the transaction. Otherwise guaranteed to be the latest version of any + * given package. + */ +export function upgradePackage(options: UpgradePackageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'upgrade_package', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VersionArguments { + cap: RawTransactionArgument; +} +export interface VersionOptions { + package: string; + arguments: VersionArguments | [cap: RawTransactionArgument]; +} +/** + * The most recent version of the package, increments by one for each successfully + * applied upgrade. + */ +export function version(options: VersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpgradePolicyArguments { + cap: RawTransactionArgument; +} +export interface UpgradePolicyOptions { + package: string; + arguments: UpgradePolicyArguments | [cap: RawTransactionArgument]; +} +/** The most permissive kind of upgrade currently supported by this `cap`. */ +export function upgradePolicy(options: UpgradePolicyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'upgrade_policy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TicketPackageArguments { + ticket: RawTransactionArgument; +} +export interface TicketPackageOptions { + package: string; + arguments: TicketPackageArguments | [ticket: RawTransactionArgument]; +} +/** The package that this ticket is authorized to upgrade */ +export function ticketPackage(options: TicketPackageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['ticket']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'ticket_package', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TicketPolicyArguments { + ticket: RawTransactionArgument; +} +export interface TicketPolicyOptions { + package: string; + arguments: TicketPolicyArguments | [ticket: RawTransactionArgument]; +} +/** The kind of upgrade that this ticket authorizes. */ +export function ticketPolicy(options: TicketPolicyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['ticket']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'ticket_policy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReceiptCapArguments { + receipt: RawTransactionArgument; +} +export interface ReceiptCapOptions { + package: string; + arguments: ReceiptCapArguments | [receipt: RawTransactionArgument]; +} +/** ID of the `UpgradeCap` that this `receipt` should be used to update. */ +export function receiptCap(options: ReceiptCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['receipt']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'receipt_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReceiptPackageArguments { + receipt: RawTransactionArgument; +} +export interface ReceiptPackageOptions { + package: string; + arguments: ReceiptPackageArguments | [receipt: RawTransactionArgument]; +} +/** + * ID of the package that was upgraded to: the latest version of the package, as of + * the upgrade represented by this `receipt`. + */ +export function receiptPackage(options: ReceiptPackageOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['receipt']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'receipt_package', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TicketDigestArguments { + ticket: RawTransactionArgument; +} +export interface TicketDigestOptions { + package: string; + arguments: TicketDigestArguments | [ticket: RawTransactionArgument]; +} +/** + * A hash of the package contents for the new version of the package. This ticket + * only authorizes an upgrade to a package that matches this digest. A package's + * contents are identified by two things: + * + * - modules: [[u8]] a list of the package's module contents + * - deps: [[u8; 32]] a list of 32 byte ObjectIDs of the package's transitive + * dependencies + * + * A package's digest is calculated as: + * + * sha3_256(sort(modules ++ deps)) + */ +export function ticketDigest(options: TicketDigestOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['ticket']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'ticket_digest', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CompatiblePolicyOptions { + package: string; + arguments?: []; +} +/** Expose the constants representing various upgrade policies */ +export function compatiblePolicy(options: CompatiblePolicyOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'compatible_policy', + }); +} +export interface AdditivePolicyOptions { + package: string; + arguments?: []; +} +export function additivePolicy(options: AdditivePolicyOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'additive_policy', + }); +} +export interface DepOnlyPolicyOptions { + package: string; + arguments?: []; +} +export function depOnlyPolicy(options: DepOnlyPolicyOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'dep_only_policy', + }); +} +export interface OnlyAdditiveUpgradesArguments { + cap: RawTransactionArgument; +} +export interface OnlyAdditiveUpgradesOptions { + package: string; + arguments: OnlyAdditiveUpgradesArguments | [cap: RawTransactionArgument]; +} +/** + * Restrict upgrades through this upgrade `cap` to just add code, or change + * dependencies. + */ +export function onlyAdditiveUpgrades(options: OnlyAdditiveUpgradesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'only_additive_upgrades', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface OnlyDepUpgradesArguments { + cap: RawTransactionArgument; +} +export interface OnlyDepUpgradesOptions { + package: string; + arguments: OnlyDepUpgradesArguments | [cap: RawTransactionArgument]; +} +/** Restrict upgrades through this upgrade `cap` to just change dependencies. */ +export function onlyDepUpgrades(options: OnlyDepUpgradesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'only_dep_upgrades', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MakeImmutableArguments { + cap: RawTransactionArgument; +} +export interface MakeImmutableOptions { + package: string; + arguments: MakeImmutableArguments | [cap: RawTransactionArgument]; +} +/** Discard the `UpgradeCap` to make a package immutable. */ +export function makeImmutable(options: MakeImmutableOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'make_immutable', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AuthorizeUpgradeArguments { + cap: RawTransactionArgument; + policy: RawTransactionArgument; + digest: RawTransactionArgument; +} +export interface AuthorizeUpgradeOptions { + package: string; + arguments: + | AuthorizeUpgradeArguments + | [ + cap: RawTransactionArgument, + policy: RawTransactionArgument, + digest: RawTransactionArgument, + ]; +} +/** + * Issue a ticket authorizing an upgrade to a particular new bytecode (identified + * by its digest). A ticket will only be issued if one has not already been issued, + * and if the `policy` requested is at least as restrictive as the policy set out + * by the `cap`. + * + * The `digest` supplied and the `policy` will both be checked by validators when + * running the upgrade. I.e. the bytecode supplied in the upgrade must have a + * matching digest, and the changes relative to the parent package must be + * compatible with the policy in the ticket for the upgrade to succeed. + */ +export function authorizeUpgrade(options: AuthorizeUpgradeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8', 'vector'] satisfies (string | null)[]; + const parameterNames = ['cap', 'policy', 'digest']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'authorize_upgrade', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CommitUpgradeArguments { + cap: RawTransactionArgument; + receipt: RawTransactionArgument; +} +export interface CommitUpgradeOptions { + package: string; + arguments: + | CommitUpgradeArguments + | [cap: RawTransactionArgument, receipt: RawTransactionArgument]; +} +/** Consume an `UpgradeReceipt` to update its `UpgradeCap`, finalizing the upgrade. */ +export function commitUpgrade(options: CommitUpgradeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['cap', 'receipt']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'package', + function: 'commit_upgrade', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/party.ts b/packages/suins/src/contracts/suins_auction/deps/sui/party.ts new file mode 100644 index 000000000..d843c915b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/party.ts @@ -0,0 +1,52 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveTuple, + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from './vec_map.js'; +const $moduleName = '0x2::party'; +export const Permissions = new MoveTuple({ + name: `${$moduleName}::Permissions`, + fields: [bcs.u64()], +}); +export const Party = new MoveStruct({ + name: `${$moduleName}::Party`, + fields: { + /** + * The permissions that apply if no specific permissions are set in the `members` + * map. + */ + default: Permissions, + /** The permissions per transaction sender. */ + members: vec_map.VecMap(bcs.Address, Permissions), + }, +}); +export interface SingleOwnerArguments { + owner: RawTransactionArgument; +} +export interface SingleOwnerOptions { + package: string; + arguments: SingleOwnerArguments | [owner: RawTransactionArgument]; +} +/** + * Creates a `Party` value with a single "owner" that has all permissions. No other + * party has any permissions. And there are no default permissions. + */ +export function singleOwner(options: SingleOwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address'] satisfies (string | null)[]; + const parameterNames = ['owner']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'party', + function: 'single_owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts b/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts new file mode 100644 index 000000000..56dd478dc --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts @@ -0,0 +1,228 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** This module provides handy functionality for wallets and `sui::Coin` management. */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface KeepArguments { + c: RawTransactionArgument; +} +export interface KeepOptions { + package: string; + arguments: KeepArguments | [c: RawTransactionArgument]; + typeArguments: [string]; +} +/** Transfer `c` to the sender of the current transaction */ +export function keep(options: KeepOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['c']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'keep', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitArguments { + coin: RawTransactionArgument; + splitAmount: RawTransactionArgument; +} +export interface SplitOptions { + package: string; + arguments: + | SplitArguments + | [coin: RawTransactionArgument, splitAmount: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Split `coin` to two coins, one with balance `split_amount`, and the remaining + * balance is left in `coin`. + */ +export function split(options: SplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['coin', 'splitAmount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitVecArguments { + self: RawTransactionArgument; + splitAmounts: RawTransactionArgument; +} +export interface SplitVecOptions { + package: string; + arguments: + | SplitVecArguments + | [ + self: RawTransactionArgument, + splitAmounts: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Split coin `self` into multiple coins, each with balance specified in + * `split_amounts`. Remaining balance is left in `self`. + */ +export function splitVec(options: SplitVecOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; + const parameterNames = ['self', 'splitAmounts']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'split_vec', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitAndTransferArguments { + c: RawTransactionArgument; + amount: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface SplitAndTransferOptions { + package: string; + arguments: + | SplitAndTransferArguments + | [ + c: RawTransactionArgument, + amount: RawTransactionArgument, + recipient: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Send `amount` units of `c` to `recipient` Aborts with `sui::balance::ENotEnough` + * if `amount` is greater than the balance in `c` + */ +export function splitAndTransfer(options: SplitAndTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', 'address'] satisfies (string | null)[]; + const parameterNames = ['c', 'amount', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'split_and_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DivideAndKeepArguments { + self: RawTransactionArgument; + n: RawTransactionArgument; +} +export interface DivideAndKeepOptions { + package: string; + arguments: + | DivideAndKeepArguments + | [self: RawTransactionArgument, n: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Divide coin `self` into `n - 1` coins with equal balances. If the balance is not + * evenly divisible by `n`, the remainder is left in `self`. + */ +export function divideAndKeep(options: DivideAndKeepOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'n']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'divide_and_keep', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface JoinArguments { + self: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface JoinOptions { + package: string; + arguments: + | JoinArguments + | [self: RawTransactionArgument, coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Join `coin` into `self`. Re-exports `coin::join` function. Deprecated: you + * should call `coin.join(other)` directly. + */ +export function join(options: JoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'join', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface JoinVecArguments { + self: RawTransactionArgument; + coins: RawTransactionArgument; +} +export interface JoinVecOptions { + package: string; + arguments: + | JoinVecArguments + | [self: RawTransactionArgument, coins: RawTransactionArgument]; + typeArguments: [string]; +} +/** Join everything in `coins` with `self` */ +export function joinVec(options: JoinVecOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; + const parameterNames = ['self', 'coins']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'join_vec', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface JoinVecAndTransferArguments { + coins: RawTransactionArgument; + receiver: RawTransactionArgument; +} +export interface JoinVecAndTransferOptions { + package: string; + arguments: + | JoinVecAndTransferArguments + | [coins: RawTransactionArgument, receiver: RawTransactionArgument]; + typeArguments: [string]; +} +/** Join a vector of `Coin` into a single object and transfer it to `receiver`. */ +export function joinVecAndTransfer(options: JoinVecAndTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'address'] satisfies (string | null)[]; + const parameterNames = ['coins', 'receiver']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pay', + function: 'join_vec_and_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts b/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts new file mode 100644 index 000000000..19acdc208 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts @@ -0,0 +1,47 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Module which defines instances of the poseidon hash functions. Available in + * Devnet and Testnet. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface PoseidonBn254Arguments { + data: RawTransactionArgument; +} +export interface PoseidonBn254Options { + package: string; + arguments: PoseidonBn254Arguments | [data: RawTransactionArgument]; +} +/** + * @param data: Vector of BN254 field elements to hash. + * + * Hash the inputs using poseidon_bn254 and returns a BN254 field element. + * + * Each element has to be a BN254 field element in canonical representation so it + * must be smaller than the BN254 scalar field size which + * is 21888242871839275222246405745257275088548364400416034343698204186575808495617. + * + * This function supports between 1 and 16 inputs. If you need to hash more than 16 + * inputs, some implementations instead returns the root of a k-ary Merkle tree + * with the inputs as leafs, but since this is not standardized, we leave that to + * the caller to implement if needed. + * + * If the input is empty, the function will abort with EEmptyInput. If more than 16 + * inputs are provided, the function will abort with ETooManyInputs. + */ +export function poseidonBn254(options: PoseidonBn254Options) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'poseidon', + function: 'poseidon_bn254', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts b/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts new file mode 100644 index 000000000..ffd4d21eb --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts @@ -0,0 +1,185 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Priority queue implemented using a max heap. */ + +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::priority_queue'; +export function Entry>(...typeParameters: [T]) { + return new MoveStruct({ + name: `${$moduleName}::Entry<${typeParameters[0].name as T['name']}>`, + fields: { + priority: bcs.u64(), + value: typeParameters[0], + }, + }); +} +/** + * Struct representing a priority queue. The `entries` vector represents a max heap + * structure, where entries[0] is the root, entries[1] and entries[2] are the left + * child and right child of the root, etc. More generally, the children of + * entries[i] are at i _ 2 + 1 and i _ 2 + 2. The max heap should have the + * invariant that the parent node's priority is always higher than its child nodes' + * priorities. + */ +export function PriorityQueue>(...typeParameters: [T]) { + return new MoveStruct({ + name: `${$moduleName}::PriorityQueue<${typeParameters[0].name as T['name']}>`, + fields: { + entries: bcs.vector(Entry(typeParameters[0])), + }, + }); +} +export interface NewArguments { + entries: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [entries: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a new priority queue from the input entry vectors. */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['entries']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopMaxArguments { + pq: RawTransactionArgument; +} +export interface PopMaxOptions { + package: string; + arguments: PopMaxArguments | [pq: RawTransactionArgument]; + typeArguments: [string]; +} +/** Pop the entry with the highest priority value. */ +export function popMax(options: PopMaxOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pq']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'pop_max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface InsertArguments> { + pq: RawTransactionArgument; + priority: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface InsertOptions> { + package: string; + arguments: + | InsertArguments + | [ + pq: RawTransactionArgument, + priority: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Insert a new entry into the queue. */ +export function insert>(options: InsertOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['pq', 'priority', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewEntryArguments> { + priority: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface NewEntryOptions> { + package: string; + arguments: + | NewEntryArguments + | [priority: RawTransactionArgument, value: RawTransactionArgument]; + typeArguments: [string]; +} +export function newEntry>(options: NewEntryOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['priority', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'new_entry', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateEntriesArguments> { + p: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface CreateEntriesOptions> { + package: string; + arguments: + | CreateEntriesArguments + | [p: RawTransactionArgument, v: RawTransactionArgument]; + typeArguments: [string]; +} +export function createEntries>(options: CreateEntriesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', `vector<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['p', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'create_entries', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PrioritiesArguments { + pq: RawTransactionArgument; +} +export interface PrioritiesOptions { + package: string; + arguments: PrioritiesArguments | [pq: RawTransactionArgument]; + typeArguments: [string]; +} +export function priorities(options: PrioritiesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pq']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'priority_queue', + function: 'priorities', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/random.ts b/packages/suins/src/contracts/suins_auction/deps/sui/random.ts new file mode 100644 index 000000000..94b3b9ffc --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/random.ts @@ -0,0 +1,392 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** This module provides functionality for generating secure randomness. */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as versioned from './versioned.js'; +const $moduleName = '0x2::random'; +export const Random = new MoveStruct({ + name: `${$moduleName}::Random`, + fields: { + id: bcs.Address, + inner: versioned.Versioned, + }, +}); +export const RandomInner = new MoveStruct({ + name: `${$moduleName}::RandomInner`, + fields: { + version: bcs.u64(), + epoch: bcs.u64(), + randomness_round: bcs.u64(), + random_bytes: bcs.vector(bcs.u8()), + }, +}); +export const RandomGenerator = new MoveStruct({ + name: `${$moduleName}::RandomGenerator`, + fields: { + seed: bcs.vector(bcs.u8()), + counter: bcs.u16(), + buffer: bcs.vector(bcs.u8()), + }, +}); +export interface NewGeneratorArguments {} +export interface NewGeneratorOptions { + package: string; + arguments?: NewGeneratorArguments | []; +} +/** + * Create a generator. Can be used to derive up to MAX_U16 \* 32 random bytes. + * + * Using randomness can be error-prone if you don't observe the subtleties in its + * correct use, for example, randomness dependent code might be exploitable to + * attacks that carefully set the gas budget in a way that breaks security. For + * more information, see: + * https://docs.sui.io/guides/developer/advanced/randomness-onchain + */ +export function newGenerator(options: NewGeneratorOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::random::Random'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'new_generator', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface GenerateBytesArguments { + g: RawTransactionArgument; + numOfBytes: RawTransactionArgument; +} +export interface GenerateBytesOptions { + package: string; + arguments: + | GenerateBytesArguments + | [g: RawTransactionArgument, numOfBytes: RawTransactionArgument]; +} +/** Generate n random bytes. */ +export function generateBytes(options: GenerateBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u16'] satisfies (string | null)[]; + const parameterNames = ['g', 'numOfBytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU256Arguments { + g: RawTransactionArgument; +} +export interface GenerateU256Options { + package: string; + arguments: GenerateU256Arguments | [g: RawTransactionArgument]; +} +/** Generate a u256. */ +export function generateU256(options: GenerateU256Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU128Arguments { + g: RawTransactionArgument; +} +export interface GenerateU128Options { + package: string; + arguments: GenerateU128Arguments | [g: RawTransactionArgument]; +} +/** Generate a u128. */ +export function generateU128(options: GenerateU128Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU64Arguments { + g: RawTransactionArgument; +} +export interface GenerateU64Options { + package: string; + arguments: GenerateU64Arguments | [g: RawTransactionArgument]; +} +/** Generate a u64. */ +export function generateU64(options: GenerateU64Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU32Arguments { + g: RawTransactionArgument; +} +export interface GenerateU32Options { + package: string; + arguments: GenerateU32Arguments | [g: RawTransactionArgument]; +} +/** Generate a u32. */ +export function generateU32(options: GenerateU32Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU16Arguments { + g: RawTransactionArgument; +} +export interface GenerateU16Options { + package: string; + arguments: GenerateU16Arguments | [g: RawTransactionArgument]; +} +/** Generate a u16. */ +export function generateU16(options: GenerateU16Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU8Arguments { + g: RawTransactionArgument; +} +export interface GenerateU8Options { + package: string; + arguments: GenerateU8Arguments | [g: RawTransactionArgument]; +} +/** Generate a u8. */ +export function generateU8(options: GenerateU8Options) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateBoolArguments { + g: RawTransactionArgument; +} +export interface GenerateBoolOptions { + package: string; + arguments: GenerateBoolArguments | [g: RawTransactionArgument]; +} +/** Generate a boolean. */ +export function generateBool(options: GenerateBoolOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['g']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_bool', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU128InRangeArguments { + g: RawTransactionArgument; + min: RawTransactionArgument; + max: RawTransactionArgument; +} +export interface GenerateU128InRangeOptions { + package: string; + arguments: + | GenerateU128InRangeArguments + | [ + g: RawTransactionArgument, + min: RawTransactionArgument, + max: RawTransactionArgument, + ]; +} +/** Generate a random u128 in [min, max] (with a bias of 2^{-64}). */ +export function generateU128InRange(options: GenerateU128InRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['g', 'min', 'max']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u128_in_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU64InRangeArguments { + g: RawTransactionArgument; + min: RawTransactionArgument; + max: RawTransactionArgument; +} +export interface GenerateU64InRangeOptions { + package: string; + arguments: + | GenerateU64InRangeArguments + | [ + g: RawTransactionArgument, + min: RawTransactionArgument, + max: RawTransactionArgument, + ]; +} +export function generateU64InRange(options: GenerateU64InRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['g', 'min', 'max']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u64_in_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU32InRangeArguments { + g: RawTransactionArgument; + min: RawTransactionArgument; + max: RawTransactionArgument; +} +export interface GenerateU32InRangeOptions { + package: string; + arguments: + | GenerateU32InRangeArguments + | [ + g: RawTransactionArgument, + min: RawTransactionArgument, + max: RawTransactionArgument, + ]; +} +/** Generate a random u32 in [min, max] (with a bias of 2^{-64}). */ +export function generateU32InRange(options: GenerateU32InRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u32', 'u32'] satisfies (string | null)[]; + const parameterNames = ['g', 'min', 'max']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u32_in_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU16InRangeArguments { + g: RawTransactionArgument; + min: RawTransactionArgument; + max: RawTransactionArgument; +} +export interface GenerateU16InRangeOptions { + package: string; + arguments: + | GenerateU16InRangeArguments + | [ + g: RawTransactionArgument, + min: RawTransactionArgument, + max: RawTransactionArgument, + ]; +} +/** Generate a random u16 in [min, max] (with a bias of 2^{-64}). */ +export function generateU16InRange(options: GenerateU16InRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u16', 'u16'] satisfies (string | null)[]; + const parameterNames = ['g', 'min', 'max']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u16_in_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GenerateU8InRangeArguments { + g: RawTransactionArgument; + min: RawTransactionArgument; + max: RawTransactionArgument; +} +export interface GenerateU8InRangeOptions { + package: string; + arguments: + | GenerateU8InRangeArguments + | [ + g: RawTransactionArgument, + min: RawTransactionArgument, + max: RawTransactionArgument, + ]; +} +/** Generate a random u8 in [min, max] (with a bias of 2^{-64}). */ +export function generateU8InRange(options: GenerateU8InRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['g', 'min', 'max']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'generate_u8_in_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ShuffleArguments> { + g: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface ShuffleOptions> { + package: string; + arguments: + | ShuffleArguments + | [g: RawTransactionArgument, v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Shuffle a vector using the random generator (Fisher–Yates/Knuth shuffle). */ +export function shuffle>(options: ShuffleOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['g', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'random', + function: 'shuffle', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts b/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts new file mode 100644 index 000000000..f56f00136 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts @@ -0,0 +1,45 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Coin is the token used to pay for gas in Sui. It has 9 decimals, and the + * smallest unit (10^-9) is called "mist". + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::sui'; +export const SUI = new MoveStruct({ + name: `${$moduleName}::SUI`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface TransferArguments { + c: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface TransferOptions { + package: string; + arguments: + | TransferArguments + | [c: RawTransactionArgument, recipient: RawTransactionArgument]; +} +export function transfer(options: TransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['c', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui', + function: 'transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/table.ts new file mode 100644 index 000000000..41d9fc4db --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/table.ts @@ -0,0 +1,304 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A table is a map-like collection. But unlike a traditional collection, it's keys + * and values are not stored within the `Table` value, but instead are stored using + * Sui's object system. The `Table` struct acts only as a handle into the object + * system to retrieve those keys and values. Note that this means that `Table` + * values with exactly the same key-value mapping will not be equal, with `==`, at + * runtime. For example + * + * ``` + * let table1 = table::new(); + * let table2 = table::new(); + * table::add(&mut table1, 0, false); + * table::add(&mut table1, 1, true); + * table::add(&mut table2, 0, false); + * table::add(&mut table2, 1, true); + * // table1 does not equal table2, despite having the same entries + * assert!(&table1 != &table2); + * ``` + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::table'; +export const Table = new MoveStruct({ + name: `${$moduleName}::Table`, + fields: { + /** the ID of this table */ + id: bcs.Address, + /** the number of key-value pairs in the table */ + size: bcs.u64(), + }, +}); +export interface NewOptions { + package: string; + arguments?: []; + typeArguments: [string, string]; +} +/** Creates a new, empty table */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'new', + typeArguments: options.typeArguments, + }); +} +export interface AddArguments, V extends BcsType> { + table: RawTransactionArgument; + k: RawTransactionArgument; + v: RawTransactionArgument; +} +export interface AddOptions, V extends BcsType> { + package: string; + arguments: + | AddArguments + | [ + table: RawTransactionArgument, + k: RawTransactionArgument, + v: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a key-value pair to the table `table: &mut Table` Aborts with + * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with + * that key `k: K`. + */ +export function add, V extends BcsType>(options: AddOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['table', 'k', 'v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowOptions> { + package: string; + arguments: + | BorrowArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Immutable borrows the value associated with the key in the table + * `table: &Table`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if + * the table does not have an entry with that key `k: K`. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package: string; + arguments: + | BorrowMutArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Mutably borrows the value associated with the key in the table + * `table: &mut Table`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` + * if the table does not have an entry with that key `k: K`. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Removes the key-value pair in the table `table: &mut Table` and returns + * the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table + * does not have an entry with that key `k: K`. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + table: RawTransactionArgument; + k: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [table: RawTransactionArgument, k: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Returns true if there is a value associated with the key `k: K` in table + * `table: &Table` + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['table', 'k']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + table: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns the size of the table, the number of key-value pairs */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + table: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns true if the table is empty (if `length` returns `0`) */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments { + table: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains + * values + */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DropArguments { + table: RawTransactionArgument; +} +export interface DropOptions { + package: string; + arguments: DropArguments | [table: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Drop a possibly non-empty table. Usable only if the value type `V` has the + * `drop` ability + */ +export function drop(options: DropOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['table']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table', + function: 'drop', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts b/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts new file mode 100644 index 000000000..7456af234 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts @@ -0,0 +1,316 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** A basic scalable vector library implemented using `Table`. */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +import { type BcsType } from '@mysten/sui/bcs'; +import * as table from './table.js'; +const $moduleName = '0x2::table_vec'; +export const TableVec = new MoveStruct({ + name: `${$moduleName}::TableVec`, + fields: { + /** The contents of the table vector. */ + contents: table.Table, + }, +}); +export interface EmptyOptions { + package: string; + arguments?: []; + typeArguments: [string]; +} +/** Create an empty TableVec. */ +export function empty(options: EmptyOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'empty', + typeArguments: options.typeArguments, + }); +} +export interface SingletonArguments> { + e: RawTransactionArgument; +} +export interface SingletonOptions> { + package: string; + arguments: SingletonArguments | [e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return a TableVec of size one containing element `e`. */ +export function singleton>(options: SingletonOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'singleton', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + t: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the length of the TableVec. */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + t: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return if the TableVec is empty or not. */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments { + t: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface BorrowOptions { + package: string; + arguments: + | BorrowArguments + | [t: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Acquire an immutable reference to the `i`th element of the TableVec `t`. Aborts + * if `i` is out of bounds. + */ +export function borrow(options: BorrowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['t', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PushBackArguments> { + t: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface PushBackOptions> { + package: string; + arguments: + | PushBackArguments + | [t: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Add element `e` to the end of the TableVec `t`. */ +export function pushBack>(options: PushBackOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['t', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'push_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments { + t: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface BorrowMutOptions { + package: string; + arguments: + | BorrowMutArguments + | [t: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return a mutable reference to the `i`th element in the TableVec `t`. Aborts if + * `i` is out of bounds. + */ +export function borrowMut(options: BorrowMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['t', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopBackArguments { + t: RawTransactionArgument; +} +export interface PopBackOptions { + package: string; + arguments: PopBackArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Pop an element from the end of TableVec `t`. Aborts if `t` is empty. */ +export function popBack(options: PopBackOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'pop_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments { + t: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy the TableVec `t`. Aborts if `t` is not empty. */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DropArguments { + t: RawTransactionArgument; +} +export interface DropOptions { + package: string; + arguments: DropArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Drop a possibly non-empty TableVec `t`. Usable only if the value type `Element` + * has the `drop` ability + */ +export function drop(options: DropOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'drop', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapArguments { + t: RawTransactionArgument; + i: RawTransactionArgument; + j: RawTransactionArgument; +} +export interface SwapOptions { + package: string; + arguments: + | SwapArguments + | [ + t: RawTransactionArgument, + i: RawTransactionArgument, + j: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Swaps the elements at the `i`th and `j`th indices in the TableVec `t`. Aborts if + * `i` or `j` is out of bounds. + */ +export function swap(options: SwapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['t', 'i', 'j']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'swap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapRemoveArguments { + t: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface SwapRemoveOptions { + package: string; + arguments: + | SwapRemoveArguments + | [t: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Swap the `i`th element of the TableVec `t` with the last element and then pop + * the TableVec. This is O(1), but does not preserve ordering of elements in the + * TableVec. Aborts if `i` is out of bounds. + */ +export function swapRemove(options: SwapRemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['t', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'table_vec', + function: 'swap_remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/token.ts b/packages/suins/src/contracts/suins_auction/deps/sui/token.ts new file mode 100644 index 000000000..643820e32 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/token.ts @@ -0,0 +1,1302 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * The Token module which implements a Closed Loop Token with a configurable + * policy. The policy is defined by a set of rules that must be satisfied for an + * action to be performed on the token. + * + * The module is designed to be used with a `TreasuryCap` to allow for minting and + * burning of the `Token`s. And can act as a replacement / extension or a companion + * to existing open-loop (`Coin`) systems. + * + * ``` + * Module: sui::balance sui::coin sui::token + * Main type: Balance Coin Token + * Capability: Supply <----> TreasuryCap <----> TreasuryCap + * Abilities: store key + store key + * ``` + * + * The Token system allows for fine-grained control over the actions performed on + * the token. And hence it is highly suitable for applications that require control + * over the currency which a simple open-loop system can't provide. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from './balance.js'; +import * as vec_map from './vec_map.js'; +import * as vec_set from './vec_set.js'; +import * as type_name from '../suins_auction/type_name.js'; +const $moduleName = '0x2::token'; +export const Token = new MoveStruct({ + name: `${$moduleName}::Token`, + fields: { + id: bcs.Address, + /** The Balance of the `Token`. */ + balance: balance.Balance, + }, +}); +export const TokenPolicyCap = new MoveStruct({ + name: `${$moduleName}::TokenPolicyCap`, + fields: { + id: bcs.Address, + for: bcs.Address, + }, +}); +export const TokenPolicy = new MoveStruct({ + name: `${$moduleName}::TokenPolicy`, + fields: { + id: bcs.Address, + /** + * The balance that is effectively spent by the user on the "spend" action. + * However, actual decrease of the supply can only be done by the `TreasuryCap` + * owner when `flush` is called. + * + * This balance is effectively spent and cannot be accessed by anyone but the + * `TreasuryCap` owner. + */ + spent_balance: balance.Balance, + /** + * The set of rules that define what actions can be performed on the token. For + * each "action" there's a set of Rules that must be satisfied for the + * `ActionRequest` to be confirmed. + */ + rules: vec_map.VecMap(bcs.string(), vec_set.VecSet(type_name.TypeName)), + }, +}); +export const ActionRequest = new MoveStruct({ + name: `${$moduleName}::ActionRequest`, + fields: { + /** + * Name of the Action to look up in the Policy. Name can be one of the default + * actions: `transfer`, `spend`, `to_coin`, `from_coin` or a custom action. + */ + name: bcs.string(), + /** Amount is present in all of the txs */ + amount: bcs.u64(), + /** Sender is a permanent field always */ + sender: bcs.Address, + /** Recipient is only available in `transfer` action. */ + recipient: bcs.option(bcs.Address), + /** + * The balance to be "spent" in the `TokenPolicy`, only available in the `spend` + * action. + */ + spent_balance: bcs.option(balance.Balance), + /** + * Collected approvals (stamps) from completed `Rules`. They're matched against + * `TokenPolicy.rules` to determine if the request can be confirmed. + */ + approvals: vec_set.VecSet(type_name.TypeName), + }, +}); +export const RuleKey = new MoveStruct({ + name: `${$moduleName}::RuleKey`, + fields: { + is_protected: bcs.bool(), + }, +}); +export const TokenPolicyCreated = new MoveStruct({ + name: `${$moduleName}::TokenPolicyCreated`, + fields: { + /** ID of the `TokenPolicy` that was created. */ + id: bcs.Address, + /** Whether the `TokenPolicy` is "shared" (mutable) or "frozen" (immutable) - TBD. */ + is_mutable: bcs.bool(), + }, +}); +export interface NewPolicyArguments { + TreasuryCap: RawTransactionArgument; +} +export interface NewPolicyOptions { + package: string; + arguments: NewPolicyArguments | [TreasuryCap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Create a new `TokenPolicy` and a matching `TokenPolicyCap`. The `TokenPolicy` + * must then be shared using the `share_policy` method. + * + * `TreasuryCap` guarantees full ownership over the currency, and is unique, hence + * it is safe to use it for authorization. + */ +export function newPolicy(options: NewPolicyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['TreasuryCap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'new_policy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SharePolicyArguments { + policy: RawTransactionArgument; +} +export interface SharePolicyOptions { + package: string; + arguments: SharePolicyArguments | [policy: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Share the `TokenPolicy`. Due to `key`-only restriction, it must be shared after + * initialization. + */ +export function sharePolicy(options: SharePolicyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['policy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'share_policy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TransferArguments { + t: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface TransferOptions { + package: string; + arguments: + | TransferArguments + | [t: RawTransactionArgument, recipient: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Transfer a `Token` to a `recipient`. Creates an `ActionRequest` for the + * "transfer" action. The `ActionRequest` contains the `recipient` field to be used + * in verification. + */ +export function transfer(options: TransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['t', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SpendArguments { + t: RawTransactionArgument; +} +export interface SpendOptions { + package: string; + arguments: SpendArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Spend a `Token` by unwrapping it and storing the `Balance` in the + * `ActionRequest` for the "spend" action. The `ActionRequest` contains the + * `spent_balance` field to be used in verification. + * + * Spend action requires `confirm_request_mut` to be called to confirm the request + * and join the spent balance with the `TokenPolicy.spent_balance`. + */ +export function spend(options: SpendOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'spend', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ToCoinArguments { + t: RawTransactionArgument; +} +export interface ToCoinOptions { + package: string; + arguments: ToCoinArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Convert `Token` into an open `Coin`. Creates an `ActionRequest` for the + * "to_coin" action. + */ +export function toCoin(options: ToCoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'to_coin', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromCoinArguments { + coin: RawTransactionArgument; +} +export interface FromCoinOptions { + package: string; + arguments: FromCoinArguments | [coin: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Convert an open `Coin` into a `Token`. Creates an `ActionRequest` for the + * "from_coin" action. + */ +export function fromCoin(options: FromCoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'from_coin', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface JoinArguments { + token: RawTransactionArgument; + another: RawTransactionArgument; +} +export interface JoinOptions { + package: string; + arguments: + | JoinArguments + | [token: RawTransactionArgument, another: RawTransactionArgument]; + typeArguments: [string]; +} +/** Join two `Token`s into one, always available. */ +export function join(options: JoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['token', 'another']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'join', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SplitArguments { + token: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface SplitOptions { + package: string; + arguments: + | SplitArguments + | [token: RawTransactionArgument, amount: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Split a `Token` with `amount`. Aborts if the `Token.balance` is lower than + * `amount`. + */ +export function split(options: SplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['token', 'amount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ZeroOptions { + package: string; + arguments?: []; + typeArguments: [string]; +} +/** Create a zero `Token`. */ +export function zero(options: ZeroOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'zero', + typeArguments: options.typeArguments, + }); +} +export interface DestroyZeroArguments { + token: RawTransactionArgument; +} +export interface DestroyZeroOptions { + package: string; + arguments: DestroyZeroArguments | [token: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Destroy an empty `Token`, fails if the balance is non-zero. Aborts if the + * `Token.balance` is not zero. + */ +export function destroyZero(options: DestroyZeroOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['token']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'destroy_zero', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface KeepArguments { + token: RawTransactionArgument; +} +export interface KeepOptions { + package: string; + arguments: KeepArguments | [token: RawTransactionArgument]; + typeArguments: [string]; +} +/** Transfer the `Token` to the transaction sender. */ +export function keep(options: KeepOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['token']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'keep', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewRequestArguments { + name: RawTransactionArgument; + amount: RawTransactionArgument; + recipient: RawTransactionArgument; + spentBalance: RawTransactionArgument; +} +export interface NewRequestOptions { + package: string; + arguments: + | NewRequestArguments + | [ + name: RawTransactionArgument, + amount: RawTransactionArgument, + recipient: RawTransactionArgument, + spentBalance: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Create a new `ActionRequest`. Publicly available method to allow for custom + * actions. + */ +export function newRequest(options: NewRequestOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x1::string::String', + 'u64', + '0x1::option::Option
', + '0x1::option::Option', + ] satisfies (string | null)[]; + const parameterNames = ['name', 'amount', 'recipient', 'spentBalance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'new_request', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ConfirmRequestArguments { + policy: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface ConfirmRequestOptions { + package: string; + arguments: + | ConfirmRequestArguments + | [policy: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Confirm the request against the `TokenPolicy` and return the parameters of the + * request: (Name, Amount, Sender, Recipient). + * + * Cannot be used for `spend` and similar actions that deliver `spent_balance` to + * the `TokenPolicy`. For those actions use `confirm_request_mut`. + * + * Aborts if: + * + * - the action is not allowed (missing record in `rules`) + * - action contains `spent_balance` (use `confirm_request_mut`) + * - the `ActionRequest` does not meet the `TokenPolicy` rules for the action + */ +export function confirmRequest(options: ConfirmRequestOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['policy', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'confirm_request', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ConfirmRequestMutArguments { + policy: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface ConfirmRequestMutOptions { + package: string; + arguments: + | ConfirmRequestMutArguments + | [policy: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Confirm the request against the `TokenPolicy` and return the parameters of the + * request: (Name, Amount, Sender, Recipient). + * + * Unlike `confirm_request` this function requires mutable access to the + * `TokenPolicy` and must be used on `spend` action. After dealing with the spent + * balance it calls `confirm_request` internally. + * + * See `confirm_request` for the list of abort conditions. + */ +export function confirmRequestMut(options: ConfirmRequestMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['policy', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'confirm_request_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ConfirmWithPolicyCapArguments { + PolicyCap: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface ConfirmWithPolicyCapOptions { + package: string; + arguments: + | ConfirmWithPolicyCapArguments + | [PolicyCap: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Confirm an `ActionRequest` as the `TokenPolicyCap` owner. This function allows + * `TokenPolicy` owner to perform Capability-gated actions ignoring the ruleset + * specified in the `TokenPolicy`. + * + * Aborts if request contains `spent_balance` due to inability of the + * `TokenPolicyCap` to decrease supply. For scenarios like this a `TreasuryCap` is + * required (see `confirm_with_treasury_cap`). + */ +export function confirmWithPolicyCap(options: ConfirmWithPolicyCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['PolicyCap', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'confirm_with_policy_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ConfirmWithTreasuryCapArguments { + treasuryCap: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface ConfirmWithTreasuryCapOptions { + package: string; + arguments: + | ConfirmWithTreasuryCapArguments + | [treasuryCap: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Confirm an `ActionRequest` as the `TreasuryCap` owner. This function allows + * `TreasuryCap` owner to perform Capability-gated actions ignoring the ruleset + * specified in the `TokenPolicy`. + * + * Unlike `confirm_with_policy_cap` this function allows `spent_balance` to be + * consumed, decreasing the `total_supply` of the `Token`. + */ +export function confirmWithTreasuryCap(options: ConfirmWithTreasuryCapOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['treasuryCap', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'confirm_with_treasury_cap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddApprovalArguments> { + T: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface AddApprovalOptions> { + package: string; + arguments: + | AddApprovalArguments + | [T: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Add an "approval" to the `ActionRequest` by providing a Witness. Intended to be + * used by Rules to add their own approvals, however, can be used to add arbitrary + * approvals to the request (not only the ones required by the `TokenPolicy`). + */ +export function addApproval>(options: AddApprovalOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; + const parameterNames = ['T', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'add_approval', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddRuleConfigArguments, Config extends BcsType> { + Rule: RawTransactionArgument; + self: RawTransactionArgument; + cap: RawTransactionArgument; + config: RawTransactionArgument; +} +export interface AddRuleConfigOptions, Config extends BcsType> { + package: string; + arguments: + | AddRuleConfigArguments + | [ + Rule: RawTransactionArgument, + self: RawTransactionArgument, + cap: RawTransactionArgument, + config: RawTransactionArgument, + ]; + typeArguments: [string, string, string]; +} +/** + * Add a `Config` for a `Rule` in the `TokenPolicy`. Rule configuration is + * independent from the `TokenPolicy.rules` and needs to be managed by the Rule + * itself. Configuration is stored per `Rule` and not per `Rule` per `Action` to + * allow reuse in different actions. + * + * - Rule witness guarantees that the `Config` is approved by the Rule. + * - `TokenPolicyCap` guarantees that the `Config` setup is initiated by the + * `TokenPolicy` owner. + */ +export function addRuleConfig, Config extends BcsType>( + options: AddRuleConfigOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[1]}`, + null, + null, + `${options.typeArguments[2]}`, + ] satisfies (string | null)[]; + const parameterNames = ['Rule', 'self', 'cap', 'config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'add_rule_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RuleConfigArguments> { + Rule: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface RuleConfigOptions> { + package: string; + arguments: + | RuleConfigArguments + | [Rule: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string, string, string]; +} +/** + * Get a `Config` for a `Rule` in the `TokenPolicy`. Requires `Rule` witness, hence + * can only be read by the `Rule` itself. This requirement guarantees safety of the + * stored `Config` and allows for simpler dynamic field management inside the Rule + * Config (custom type keys are not needed for access gating). + * + * Aborts if the Config is not present. + */ +export function ruleConfig>(options: RuleConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; + const parameterNames = ['Rule', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'rule_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RuleConfigMutArguments> { + Rule: RawTransactionArgument; + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface RuleConfigMutOptions> { + package: string; + arguments: + | RuleConfigMutArguments + | [ + Rule: RawTransactionArgument, + self: RawTransactionArgument, + cap: RawTransactionArgument, + ]; + typeArguments: [string, string, string]; +} +/** + * Get mutable access to the `Config` for a `Rule` in the `TokenPolicy`. Requires + * `Rule` witness, hence can only be read by the `Rule` itself, as well as + * `TokenPolicyCap` to guarantee that the `TokenPolicy` owner is the one who + * initiated the `Config` modification. + * + * Aborts if: + * + * - the Config is not present + * - `TokenPolicyCap` is not matching the `TokenPolicy` + */ +export function ruleConfigMut>(options: RuleConfigMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null, null] satisfies (string | null)[]; + const parameterNames = ['Rule', 'self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'rule_config_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveRuleConfigArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface RemoveRuleConfigOptions { + package: string; + arguments: + | RemoveRuleConfigArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string, string, string]; +} +/** + * Remove a `Config` for a `Rule` in the `TokenPolicy`. Unlike the + * `add_rule_config`, this function does not require a `Rule` witness, hence can be + * performed by the `TokenPolicy` owner on their own. + * + * Rules need to make sure that the `Config` is present when performing + * verification of the `ActionRequest`. + * + * Aborts if: + * + * - the Config is not present + * - `TokenPolicyCap` is not matching the `TokenPolicy` + */ +export function removeRuleConfig(options: RemoveRuleConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'remove_rule_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface HasRuleConfigArguments { + self: RawTransactionArgument; +} +export interface HasRuleConfigOptions { + package: string; + arguments: HasRuleConfigArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Check if a config for a `Rule` is set in the `TokenPolicy` without checking the + * type of the `Config`. + */ +export function hasRuleConfig(options: HasRuleConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'has_rule_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface HasRuleConfigWithTypeArguments { + self: RawTransactionArgument; +} +export interface HasRuleConfigWithTypeOptions { + package: string; + arguments: HasRuleConfigWithTypeArguments | [self: RawTransactionArgument]; + typeArguments: [string, string, string]; +} +/** + * Check if a `Config` for a `Rule` is set in the `TokenPolicy` and that it matches + * the type provided. + */ +export function hasRuleConfigWithType(options: HasRuleConfigWithTypeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'has_rule_config_with_type', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AllowArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface AllowOptions { + package: string; + arguments: + | AllowArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + action: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Allows an `action` to be performed on the `Token` freely by adding an empty set + * of `Rules` for the `action`. + * + * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. + */ +export function allow(options: AllowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'allow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DisallowArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface DisallowOptions { + package: string; + arguments: + | DisallowArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + action: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Completely disallows an `action` on the `Token` by removing the record from the + * `TokenPolicy.rules`. + * + * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. + */ +export function disallow(options: DisallowOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'disallow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddRuleForActionArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface AddRuleForActionOptions { + package: string; + arguments: + | AddRuleForActionArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + action: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Adds a Rule for an action with `name` in the `TokenPolicy`. + * + * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. + */ +export function addRuleForAction(options: AddRuleForActionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'add_rule_for_action', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveRuleForActionArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface RemoveRuleForActionOptions { + package: string; + arguments: + | RemoveRuleForActionArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + action: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Removes a rule for an action with `name` in the `TokenPolicy`. Returns the + * config object to be handled by the sender (or a Rule itself). + * + * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. + */ +export function removeRuleForAction(options: RemoveRuleForActionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'remove_rule_for_action', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MintArguments { + cap: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface MintOptions { + package: string; + arguments: + | MintArguments + | [cap: RawTransactionArgument, amount: RawTransactionArgument]; + typeArguments: [string]; +} +/** Mint a `Token` with a given `amount` using the `TreasuryCap`. */ +export function mint(options: MintOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['cap', 'amount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'mint', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BurnArguments { + cap: RawTransactionArgument; + token: RawTransactionArgument; +} +export interface BurnOptions { + package: string; + arguments: + | BurnArguments + | [cap: RawTransactionArgument, token: RawTransactionArgument]; + typeArguments: [string]; +} +/** Burn a `Token` using the `TreasuryCap`. */ +export function burn(options: BurnOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['cap', 'token']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'burn', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FlushArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface FlushOptions { + package: string; + arguments: + | FlushArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Flush the `TokenPolicy.spent_balance` into the `TreasuryCap`. This action is + * only available to the `TreasuryCap` owner. + */ +export function flush(options: FlushOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'flush', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsAllowedArguments { + self: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface IsAllowedOptions { + package: string; + arguments: + | IsAllowedArguments + | [self: RawTransactionArgument, action: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check whether an action is present in the rules VecMap. */ +export function isAllowed(options: IsAllowedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'is_allowed', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RulesArguments { + self: RawTransactionArgument; + action: RawTransactionArgument; +} +export interface RulesOptions { + package: string; + arguments: + | RulesArguments + | [self: RawTransactionArgument, action: RawTransactionArgument]; + typeArguments: [string]; +} +/** Returns the rules required for a specific action. */ +export function rules(options: RulesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'action']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'rules', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SpentBalanceArguments { + self: RawTransactionArgument; +} +export interface SpentBalanceOptions { + package: string; + arguments: SpentBalanceArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Returns the `spent_balance` of the `TokenPolicy`. */ +export function spentBalance(options: SpentBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'spent_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ValueArguments { + t: RawTransactionArgument; +} +export interface ValueOptions { + package: string; + arguments: ValueArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Returns the `balance` of the `Token`. */ +export function value(options: ValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TransferActionOptions { + package: string; + arguments?: []; +} +/** Name of the Transfer action. */ +export function transferAction(options: TransferActionOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'transfer_action', + }); +} +export interface SpendActionOptions { + package: string; + arguments?: []; +} +/** Name of the `Spend` action. */ +export function spendAction(options: SpendActionOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'spend_action', + }); +} +export interface ToCoinActionOptions { + package: string; + arguments?: []; +} +/** Name of the `ToCoin` action. */ +export function toCoinAction(options: ToCoinActionOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'to_coin_action', + }); +} +export interface FromCoinActionOptions { + package: string; + arguments?: []; +} +/** Name of the `FromCoin` action. */ +export function fromCoinAction(options: FromCoinActionOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'from_coin_action', + }); +} +export interface ActionArguments { + self: RawTransactionArgument; +} +export interface ActionOptions { + package: string; + arguments: ActionArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** The Action in the `ActionRequest`. */ +export function action(options: ActionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'action', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AmountArguments { + self: RawTransactionArgument; +} +export interface AmountOptions { + package: string; + arguments: AmountArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Amount of the `ActionRequest`. */ +export function amount(options: AmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SenderArguments { + self: RawTransactionArgument; +} +export interface SenderOptions { + package: string; + arguments: SenderArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Sender of the `ActionRequest`. */ +export function sender(options: SenderOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'sender', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RecipientArguments { + self: RawTransactionArgument; +} +export interface RecipientOptions { + package: string; + arguments: RecipientArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Recipient of the `ActionRequest`. */ +export function recipient(options: RecipientOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'recipient', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ApprovalsArguments { + self: RawTransactionArgument; +} +export interface ApprovalsOptions { + package: string; + arguments: ApprovalsArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Approvals of the `ActionRequest`. */ +export function approvals(options: ApprovalsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'approvals', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SpentArguments { + self: RawTransactionArgument; +} +export interface SpentOptions { + package: string; + arguments: SpentArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Burned balance of the `ActionRequest`. */ +export function spent(options: SpentOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'token', + function: 'spent', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts b/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts new file mode 100644 index 000000000..3c9fcf515 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts @@ -0,0 +1,358 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::transfer'; +export const Receiving = new MoveStruct({ + name: `${$moduleName}::Receiving`, + fields: { + id: bcs.Address, + version: bcs.u64(), + }, +}); +export interface TransferArguments> { + obj: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface TransferOptions> { + package: string; + arguments: + | TransferArguments + | [obj: RawTransactionArgument, recipient: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Transfer ownership of `obj` to `recipient`. `obj` must have the `key` attribute, + * which (in turn) ensures that `obj` has a globally unique ID. Note that if the + * recipient address represents an object ID, the `obj` sent will be inaccessible + * after the transfer (though they will be retrievable at a future date once new + * features are added). This function has custom rules performed by the Sui Move + * bytecode verifier that ensures that `T` is an object defined in the module where + * `transfer` is invoked. Use `public_transfer` to transfer an object with `store` + * outside of its module. + */ +export function transfer>(options: TransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, 'address'] satisfies (string | null)[]; + const parameterNames = ['obj', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublicTransferArguments> { + obj: RawTransactionArgument; + recipient: RawTransactionArgument; +} +export interface PublicTransferOptions> { + package: string; + arguments: + | PublicTransferArguments + | [obj: RawTransactionArgument, recipient: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Transfer ownership of `obj` to `recipient`. `obj` must have the `key` attribute, + * which (in turn) ensures that `obj` has a globally unique ID. Note that if the + * recipient address represents an object ID, the `obj` sent will be inaccessible + * after the transfer (though they will be retrievable at a future date once new + * features are added). The object must have `store` to be transferred outside of + * its module. + */ +export function publicTransfer>(options: PublicTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, 'address'] satisfies (string | null)[]; + const parameterNames = ['obj', 'recipient']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'public_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PartyTransferArguments> { + obj: RawTransactionArgument; + party: RawTransactionArgument; +} +export interface PartyTransferOptions> { + package: string; + arguments: + | PartyTransferArguments + | [obj: RawTransactionArgument, party: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * NOT YET SUPPORTED ON MAINNET. The function will abort with `ENotSupported` if + * used on a network where party objects are not yet supported. Transfer ownership + * of `obj` to the `party`. This transfer behaves similar to both `transfer` and + * `share_object`. It is similar to `transfer` in that the object is authorized for + * use only by the recipient(s), in this case the `party`. This means that only the + * members can use the object as an input to a transaction. It is similar to + * `share_object` two ways. One in that the object can potentially be used by + * anyone, as defined by the `default` permissions of the `Party` value. The other + * in that the object must be used in consensus and cannot be used in the fast + * path. This function has custom rules performed by the Sui Move bytecode verifier + * that ensures that `T` is an object defined in the module where `transfer` is + * invoked. Use `public_party_transfer` to transfer an object with `store` outside + * of its module. + */ +export function partyTransfer>(options: PartyTransferOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['obj', 'party']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'party_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublicPartyTransferArguments> { + obj: RawTransactionArgument; + party: RawTransactionArgument; +} +export interface PublicPartyTransferOptions> { + package: string; + arguments: + | PublicPartyTransferArguments + | [obj: RawTransactionArgument, party: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * NOT YET SUPPORTED ON MAINNET. The function will abort with `ENotSupported` if + * used on a network where party objects are not yet supported. Transfer ownership + * of `obj` to the `party`. This transfer behaves similar to both `transfer` and + * `share_object`. It is similar to `transfer` in that the object is authorized for + * use only by the recipient(s), in this case the `party`. This means that only the + * members can use the object as an input to a transaction. It is similar to + * `share_object` two ways. One in that the object can potentially be used by + * anyone, as defined by the `default` permissions of the `Party` value. The other + * in that the object must be used in consensus and cannot be used in the fast + * path. The object must have `store` to be transferred outside of its module. + */ +export function publicPartyTransfer>( + options: PublicPartyTransferOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['obj', 'party']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'public_party_transfer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FreezeObjectArguments> { + obj: RawTransactionArgument; +} +export interface FreezeObjectOptions> { + package: string; + arguments: FreezeObjectArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Freeze `obj`. After freezing `obj` becomes immutable and can no longer be + * transferred or mutated. This function has custom rules performed by the Sui Move + * bytecode verifier that ensures that `T` is an object defined in the module where + * `freeze_object` is invoked. Use `public_freeze_object` to freeze an object with + * `store` outside of its module. + */ +export function freezeObject>(options: FreezeObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'freeze_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublicFreezeObjectArguments> { + obj: RawTransactionArgument; +} +export interface PublicFreezeObjectOptions> { + package: string; + arguments: PublicFreezeObjectArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Freeze `obj`. After freezing `obj` becomes immutable and can no longer be + * transferred or mutated. The object must have `store` to be frozen outside of its + * module. + */ +export function publicFreezeObject>(options: PublicFreezeObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'public_freeze_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ShareObjectArguments> { + obj: RawTransactionArgument; +} +export interface ShareObjectOptions> { + package: string; + arguments: ShareObjectArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Turn the given object into a mutable shared object that everyone can access and + * mutate. This is irreversible, i.e. once an object is shared, it will stay shared + * forever. Aborts with `ESharedNonNewObject` of the object being shared was not + * created in this transaction. This restriction may be relaxed in the future. This + * function has custom rules performed by the Sui Move bytecode verifier that + * ensures that `T` is an object defined in the module where `share_object` is + * invoked. Use `public_share_object` to share an object with `store` outside of + * its module. + */ +export function shareObject>(options: ShareObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'share_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublicShareObjectArguments> { + obj: RawTransactionArgument; +} +export interface PublicShareObjectOptions> { + package: string; + arguments: PublicShareObjectArguments | [obj: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Turn the given object into a mutable shared object that everyone can access and + * mutate. This is irreversible, i.e. once an object is shared, it will stay shared + * forever. Aborts with `ESharedNonNewObject` of the object being shared was not + * created in this transaction. This restriction may be relaxed in the future. The + * object must have `store` to be shared outside of its module. + */ +export function publicShareObject>(options: PublicShareObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'public_share_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReceiveArguments { + parent: RawTransactionArgument; + toReceive: RawTransactionArgument; +} +export interface ReceiveOptions { + package: string; + arguments: + | ReceiveArguments + | [parent: RawTransactionArgument, toReceive: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Given mutable (i.e., locked) access to the `parent` and a `Receiving` argument + * referencing an object of type `T` owned by `parent` use the `to_receive` + * argument to receive and return the referenced owned object of type `T`. This + * function has custom rules performed by the Sui Move bytecode verifier that + * ensures that `T` is an object defined in the module where `receive` is invoked. + * Use `public_receive` to receivne an object with `store` outside of its module. + */ +export function receive(options: ReceiveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', null] satisfies (string | null)[]; + const parameterNames = ['parent', 'toReceive']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'receive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PublicReceiveArguments { + parent: RawTransactionArgument; + toReceive: RawTransactionArgument; +} +export interface PublicReceiveOptions { + package: string; + arguments: + | PublicReceiveArguments + | [parent: RawTransactionArgument, toReceive: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Given mutable (i.e., locked) access to the `parent` and a `Receiving` argument + * referencing an object of type `T` owned by `parent` use the `to_receive` + * argument to receive and return the referenced owned object of type `T`. The + * object must have `store` to be received outside of its defining module. + */ +export function publicReceive(options: PublicReceiveOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', null] satisfies (string | null)[]; + const parameterNames = ['parent', 'toReceive']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'public_receive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReceivingObjectIdArguments { + receiving: RawTransactionArgument; +} +export interface ReceivingObjectIdOptions { + package: string; + arguments: ReceivingObjectIdArguments | [receiving: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the object ID that the given `Receiving` argument references. */ +export function receivingObjectId(options: ReceivingObjectIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['receiving']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer', + function: 'receiving_object_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts b/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts new file mode 100644 index 000000000..42da5d702 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts @@ -0,0 +1,602 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the `TransferPolicy` type and the logic to approve `TransferRequest`s. + * + * - TransferPolicy - is a highly customizable primitive, which provides an + * interface for the type owner to set custom transfer rules for every deal + * performed in the `Kiosk` or a similar system that integrates with TP. + * + * - Once a `TransferPolicy` is created for and shared (or frozen), the type `T` + * becomes tradable in `Kiosk`s. On every purchase operation, a `TransferRequest` + * is created and needs to be confirmed by the `TransferPolicy` hot potato or + * transaction will fail. + * + * - Type owner (creator) can set any Rules as long as the ecosystem supports them. + * All of the Rules need to be resolved within a single transaction (eg pay + * royalty and pay fixed commission). Once required actions are performed, the + * `TransferRequest` can be "confirmed" via `confirm_request` call. + * + * - `TransferPolicy` aims to be the main interface for creators to control trades + * of their types and collect profits if a fee is required on sales. Custom + * policies can be removed at any moment, and the change will affect all + * instances of the type at once. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_set from './vec_set.js'; +import * as type_name from '../suins_auction/type_name.js'; +import * as balance from './balance.js'; +const $moduleName = '0x2::transfer_policy'; +export const TransferRequest = new MoveStruct({ + name: `${$moduleName}::TransferRequest`, + fields: { + /** + * The ID of the transferred item. Although the `T` has no constraints, the main + * use case for this module is to work with Objects. + */ + item: bcs.Address, + /** + * Amount of SUI paid for the item. Can be used to calculate the fee / transfer + * policy enforcement. + */ + paid: bcs.u64(), + /** + * The ID of the Kiosk / Safe the object is being sold from. Can be used by the + * TransferPolicy implementors. + */ + from: bcs.Address, + /** + * Collected Receipts. Used to verify that all of the rules were followed and + * `TransferRequest` can be confirmed. + */ + receipts: vec_set.VecSet(type_name.TypeName), + }, +}); +export const TransferPolicy = new MoveStruct({ + name: `${$moduleName}::TransferPolicy`, + fields: { + id: bcs.Address, + /** + * The Balance of the `TransferPolicy` which collects `SUI`. By default, transfer + * policy does not collect anything , and it's a matter of an implementation of a + * specific rule - whether to add to balance and how much. + */ + balance: balance.Balance, + /** + * Set of types of attached rules - used to verify `receipts` when a + * `TransferRequest` is received in `confirm_request` function. + * + * Additionally provides a way to look up currently attached Rules. + */ + rules: vec_set.VecSet(type_name.TypeName), + }, +}); +export const TransferPolicyCap = new MoveStruct({ + name: `${$moduleName}::TransferPolicyCap`, + fields: { + id: bcs.Address, + policy_id: bcs.Address, + }, +}); +export const TransferPolicyCreated = new MoveStruct({ + name: `${$moduleName}::TransferPolicyCreated`, + fields: { + id: bcs.Address, + }, +}); +export const TransferPolicyDestroyed = new MoveStruct({ + name: `${$moduleName}::TransferPolicyDestroyed`, + fields: { + id: bcs.Address, + }, +}); +export const RuleKey = new MoveStruct({ + name: `${$moduleName}::RuleKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface NewRequestArguments { + item: RawTransactionArgument; + paid: RawTransactionArgument; + from: RawTransactionArgument; +} +export interface NewRequestOptions { + package: string; + arguments: + | NewRequestArguments + | [ + item: RawTransactionArgument, + paid: RawTransactionArgument, + from: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Construct a new `TransferRequest` hot potato which requires an approving action + * from the creator to be destroyed / resolved. Once created, it must be confirmed + * in the `confirm_request` call otherwise the transaction will fail. + */ +export function newRequest(options: NewRequestOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', 'u64', '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['item', 'paid', 'from']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'new_request', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface NewArguments { + pub: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [pub: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Register a type in the Kiosk system and receive a `TransferPolicy` and a + * `TransferPolicyCap` for the type. The `TransferPolicy` is required to confirm + * kiosk deals for the `T`. If there's no `TransferPolicy` available for use, the + * type can not be traded in kiosks. + */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pub']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DefaultArguments { + pub: RawTransactionArgument; +} +export interface DefaultOptions { + package: string; + arguments: DefaultArguments | [pub: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Initialize the Transfer Policy in the default scenario: Create and share the + * `TransferPolicy`, transfer `TransferPolicyCap` to the transaction sender. + */ +export function _default(options: DefaultOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pub']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'default', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface WithdrawArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; + amount: RawTransactionArgument; +} +export interface WithdrawOptions { + package: string; + arguments: + | WithdrawArguments + | [ + self: RawTransactionArgument, + cap: RawTransactionArgument, + amount: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Withdraw some amount of profits from the `TransferPolicy`. If amount is not + * specified, all profits are withdrawn. + */ +export function withdraw(options: WithdrawOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::option::Option'] satisfies (string | null)[]; + const parameterNames = ['self', 'cap', 'amount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'withdraw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyAndWithdrawArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface DestroyAndWithdrawOptions { + package: string; + arguments: + | DestroyAndWithdrawArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Destroy a TransferPolicyCap. Can be performed by any party as long as they own + * it. + */ +export function destroyAndWithdraw(options: DestroyAndWithdrawOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'destroy_and_withdraw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ConfirmRequestArguments { + self: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface ConfirmRequestOptions { + package: string; + arguments: + | ConfirmRequestArguments + | [self: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Allow a `TransferRequest` for the type `T`. The call is protected by the type + * constraint, as only the publisher of the `T` can get `TransferPolicy`. + * + * Note: unless there's a policy for `T` to allow transfers, Kiosk trades will not + * be possible. + */ +export function confirmRequest(options: ConfirmRequestOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'confirm_request', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddRuleArguments, Config extends BcsType> { + _: RawTransactionArgument; + policy: RawTransactionArgument; + cap: RawTransactionArgument; + cfg: RawTransactionArgument; +} +export interface AddRuleOptions, Config extends BcsType> { + package: string; + arguments: + | AddRuleArguments + | [ + _: RawTransactionArgument, + policy: RawTransactionArgument, + cap: RawTransactionArgument, + cfg: RawTransactionArgument, + ]; + typeArguments: [string, string, string]; +} +/** + * Add a custom Rule to the `TransferPolicy`. Once set, `TransferRequest` must + * receive a confirmation of the rule executed so the hot potato can be unpacked. + * + * - T: the type to which TransferPolicy is applied. + * - Rule: the witness type for the Custom rule + * - Config: a custom configuration for the rule + * + * Config requires `drop` to allow creators to remove any policy at any moment, + * even if graceful unpacking has not been implemented in a "rule module". + */ +export function addRule, Config extends BcsType>( + options: AddRuleOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `${options.typeArguments[1]}`, + null, + null, + `${options.typeArguments[2]}`, + ] satisfies (string | null)[]; + const parameterNames = ['_', 'policy', 'cap', 'cfg']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'add_rule', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetRuleArguments> { + _: RawTransactionArgument; + policy: RawTransactionArgument; +} +export interface GetRuleOptions> { + package: string; + arguments: + | GetRuleArguments + | [_: RawTransactionArgument, policy: RawTransactionArgument]; + typeArguments: [string, string, string]; +} +/** Get the custom Config for the Rule (can be only one per "Rule" type). */ +export function getRule>(options: GetRuleOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; + const parameterNames = ['_', 'policy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'get_rule', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddToBalanceArguments> { + _: RawTransactionArgument; + policy: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface AddToBalanceOptions> { + package: string; + arguments: + | AddToBalanceArguments + | [ + _: RawTransactionArgument, + policy: RawTransactionArgument, + coin: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** Add some `SUI` to the balance of a `TransferPolicy`. */ +export function addToBalance>(options: AddToBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'policy', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'add_to_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddReceiptArguments> { + _: RawTransactionArgument; + request: RawTransactionArgument; +} +export interface AddReceiptOptions> { + package: string; + arguments: + | AddReceiptArguments + | [_: RawTransactionArgument, request: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Adds a `Receipt` to the `TransferRequest`, unblocking the request and confirming + * that the policy requirements are satisfied. + */ +export function addReceipt>(options: AddReceiptOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; + const parameterNames = ['_', 'request']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'add_receipt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface HasRuleArguments { + policy: RawTransactionArgument; +} +export interface HasRuleOptions { + package: string; + arguments: HasRuleArguments | [policy: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Check whether a custom rule has been added to the `TransferPolicy`. */ +export function hasRule(options: HasRuleOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['policy']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'has_rule', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveRuleArguments { + policy: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface RemoveRuleOptions { + package: string; + arguments: + | RemoveRuleArguments + | [policy: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string, string, string]; +} +/** Remove the Rule from the `TransferPolicy`. */ +export function removeRule(options: RemoveRuleOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['policy', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'remove_rule', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UidArguments { + self: RawTransactionArgument; +} +export interface UidOptions { + package: string; + arguments: UidArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Allows reading custom attachments to the `TransferPolicy` if there are any. */ +export function uid(options: UidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'uid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UidMutAsOwnerArguments { + self: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface UidMutAsOwnerOptions { + package: string; + arguments: + | UidMutAsOwnerArguments + | [self: RawTransactionArgument, cap: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get a mutable reference to the `self.id` to enable custom attachments to the + * `TransferPolicy`. + */ +export function uidMutAsOwner(options: UidMutAsOwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'uid_mut_as_owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RulesArguments { + self: RawTransactionArgument; +} +export interface RulesOptions { + package: string; + arguments: RulesArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Read the `rules` field from the `TransferPolicy`. */ +export function rules(options: RulesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'rules', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ItemArguments { + self: RawTransactionArgument; +} +export interface ItemOptions { + package: string; + arguments: ItemArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `item` field of the `TransferRequest`. */ +export function item(options: ItemOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'item', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PaidArguments { + self: RawTransactionArgument; +} +export interface PaidOptions { + package: string; + arguments: PaidArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `paid` field of the `TransferRequest`. */ +export function paid(options: PaidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'paid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromArguments { + self: RawTransactionArgument; +} +export interface FromOptions { + package: string; + arguments: FromArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get the `from` field of the `TransferRequest`. */ +export function _from(options: FromOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'transfer_policy', + function: 'from', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts b/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts new file mode 100644 index 000000000..f77dd4b1d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts @@ -0,0 +1,150 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::tx_context'; +export const TxContext = new MoveStruct({ + name: `${$moduleName}::TxContext`, + fields: { + /** The address of the user that signed the current transaction */ + sender: bcs.Address, + /** Hash of the current transaction */ + tx_hash: bcs.vector(bcs.u8()), + /** The current epoch number */ + epoch: bcs.u64(), + /** Timestamp that the epoch started at */ + epoch_timestamp_ms: bcs.u64(), + /** + * Counter recording the number of fresh id's created while executing this + * transaction. Always 0 at the start of a transaction + */ + ids_created: bcs.u64(), + }, +}); +export interface SenderOptions { + package: string; + arguments?: []; +} +/** Return the address of the user that signed the current transaction */ +export function sender(options: SenderOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'sender', + }); +} +export interface DigestOptions { + package: string; + arguments?: []; +} +/** + * Return the transaction digest (hash of transaction inputs). Please do not use as + * a source of randomness. + */ +export function digest(options: DigestOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'digest', + }); +} +export interface EpochOptions { + package: string; + arguments?: []; +} +/** Return the current epoch */ +export function epoch(options: EpochOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'epoch', + }); +} +export interface EpochTimestampMsOptions { + package: string; + arguments?: []; +} +/** Return the epoch start time as a unix timestamp in milliseconds. */ +export function epochTimestampMs(options: EpochTimestampMsOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'epoch_timestamp_ms', + }); +} +export interface SponsorOptions { + package: string; + arguments?: []; +} +/** Return the adress of the transaction sponsor or `None` if there was no sponsor. */ +export function sponsor(options: SponsorOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'sponsor', + }); +} +export interface FreshObjectAddressOptions { + package: string; + arguments?: []; +} +/** + * Create an `address` that has not been used. As it is an object address, it will + * never occur as the address for a user. In other words, the generated address is + * a globally unique object ID. + */ +export function freshObjectAddress(options: FreshObjectAddressOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'fresh_object_address', + }); +} +export interface ReferenceGasPriceOptions { + package: string; + arguments?: []; +} +/** + * Return the reference gas price in effect for the epoch the transaction is being + * executed in. + */ +export function referenceGasPrice(options: ReferenceGasPriceOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'reference_gas_price', + }); +} +export interface GasPriceOptions { + package: string; + arguments?: []; +} +/** + * Return the gas price submitted for the current transaction. That is the value + * the user submitted with the transaction data. + */ +export function gasPrice(options: GasPriceOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'tx_context', + function: 'gas_price', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/types.ts b/packages/suins/src/contracts/suins_auction/deps/sui/types.ts new file mode 100644 index 000000000..ee85b81a9 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/types.ts @@ -0,0 +1,34 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Sui types helpers and utilities */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +import { type BcsType } from '@mysten/sui/bcs'; +export interface IsOneTimeWitnessArguments> { + _: RawTransactionArgument; +} +export interface IsOneTimeWitnessOptions> { + package: string; + arguments: IsOneTimeWitnessArguments | [_: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Tests if the argument type is a one-time witness, that is a type with only one + * instantiation across the entire code base. + */ +export function isOneTimeWitness>(options: IsOneTimeWitnessOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'types', + function: 'is_one_time_witness', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/url.ts b/packages/suins/src/contracts/suins_auction/deps/sui/url.ts new file mode 100644 index 000000000..e41774d90 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/url.ts @@ -0,0 +1,106 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** URL: standard Uniform Resource Locator string */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::url'; +export const Url = new MoveStruct({ + name: `${$moduleName}::Url`, + fields: { + url: bcs.string(), + }, +}); +export interface NewUnsafeArguments { + url: RawTransactionArgument; +} +export interface NewUnsafeOptions { + package: string; + arguments: NewUnsafeArguments | [url: RawTransactionArgument]; +} +/** Create a `Url`, with no validation */ +export function newUnsafe(options: NewUnsafeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['url']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'url', + function: 'new_unsafe', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewUnsafeFromBytesArguments { + bytes: RawTransactionArgument; +} +export interface NewUnsafeFromBytesOptions { + package: string; + arguments: NewUnsafeFromBytesArguments | [bytes: RawTransactionArgument]; +} +/** + * Create a `Url` with no validation from bytes Note: this will abort if `bytes` is + * not valid ASCII + */ +export function newUnsafeFromBytes(options: NewUnsafeFromBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'url', + function: 'new_unsafe_from_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface InnerUrlArguments { + self: RawTransactionArgument; +} +export interface InnerUrlOptions { + package: string; + arguments: InnerUrlArguments | [self: RawTransactionArgument]; +} +/** Get inner URL */ +export function innerUrl(options: InnerUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'url', + function: 'inner_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateArguments { + self: RawTransactionArgument; + url: RawTransactionArgument; +} +export interface UpdateOptions { + package: string; + arguments: + | UpdateArguments + | [self: RawTransactionArgument, url: RawTransactionArgument]; +} +/** Update the inner URL */ +export function update(options: UpdateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'url']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'url', + function: 'update', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts new file mode 100644 index 000000000..5589dbfdf --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts @@ -0,0 +1,79 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; +export interface HashToInputArguments { + message: RawTransactionArgument; +} +export interface HashToInputOptions { + package: string; + arguments: HashToInputArguments | [message: RawTransactionArgument]; +} +/** + * Hash an arbitrary binary `message` to a class group element to be used as input + * for `vdf_verify`. + * + * This function is currently only enabled on Devnet. + */ +export function hashToInput(options: HashToInputOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['message']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vdf', + function: 'hash_to_input', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VdfVerifyArguments { + input: RawTransactionArgument; + output: RawTransactionArgument; + proof: RawTransactionArgument; + iterations: RawTransactionArgument; +} +export interface VdfVerifyOptions { + package: string; + arguments: + | VdfVerifyArguments + | [ + input: RawTransactionArgument, + output: RawTransactionArgument, + proof: RawTransactionArgument, + iterations: RawTransactionArgument, + ]; +} +/** + * Verify the output and proof of a VDF with the given number of iterations. The + * `input`, `output` and `proof` are all class group elements represented by + * triples `(a,b,c)` such that `b^2 - 4ac = discriminant`. The are expected to be + * encoded as a BCS encoding of a triple of byte arrays, each being the big-endian + * twos-complement encoding of a, b and c in that order. + * + * This uses Wesolowski's VDF construction over imaginary class groups as described + * in Wesolowski (2020), 'Efficient Verifiable Delay Functions.', J. Cryptol. 33, + * and is compatible with the VDF implementation in fastcrypto. + * + * The discriminant for the class group is pre-computed and fixed. See how this was + * generated in the fastcrypto-vdf crate. The final selection of the discriminant + * for Mainnet will be computed and announced under a nothing-up-my-sleeve process. + * + * This function is currently only enabled on Devnet. + */ +export function vdfVerify(options: VdfVerifyOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector', 'vector', 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = ['input', 'output', 'proof', 'iterations']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vdf', + function: 'vdf_verify', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts new file mode 100644 index 000000000..2708c145f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts @@ -0,0 +1,568 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::vec_map'; +/** An entry in the map */ +export function Entry, V extends BcsType>(...typeParameters: [K, V]) { + return new MoveStruct({ + name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, + fields: { + key: typeParameters[0], + value: typeParameters[1], + }, + }); +} +/** + * A map data structure backed by a vector. The map is guaranteed not to contain + * duplicate keys, but entries are _not_ sorted by key--entries are included in + * insertion order. All operations are O(N) in the size of the map--the intention + * of this data structure is only to provide the convenience of programming against + * a map API. Large maps should use handwritten parent/child relationships instead. + * Maps that need sorted iteration rather than insertion order iteration should + * also be handwritten. + */ +export function VecMap, V extends BcsType>(...typeParameters: [K, V]) { + return new MoveStruct({ + name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, + fields: { + contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])), + }, + }); +} +export interface EmptyOptions { + package: string; + arguments?: []; + typeArguments: [string, string]; +} +/** Create an empty `VecMap` */ +export function empty(options: EmptyOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'empty', + typeArguments: options.typeArguments, + }); +} +export interface InsertArguments, V extends BcsType> { + self: RawTransactionArgument; + key: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface InsertOptions, V extends BcsType> { + package: string; + arguments: + | InsertArguments + | [ + self: RawTransactionArgument, + key: RawTransactionArgument, + value: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Insert the entry `key` |-> `value` into `self`. Aborts if `key` is already bound + * in `self`. + */ +export function insert, V extends BcsType>( + options: InsertOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + `${options.typeArguments[0]}`, + `${options.typeArguments[1]}`, + ] satisfies (string | null)[]; + const parameterNames = ['self', 'key', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in + * `self`. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopArguments { + self: RawTransactionArgument; +} +export interface PopOptions { + package: string; + arguments: PopArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Pop the most recently inserted entry from the map. Aborts if the map is empty. */ +export function pop(options: PopOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'pop', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetMutArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface GetMutOptions> { + package: string; + arguments: + | GetMutArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Get a mutable reference to the value bound to `key` in `self`. Aborts if `key` + * is not bound in `self`. + */ +export function getMut>(options: GetMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface GetOptions> { + package: string; + arguments: + | GetArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Get a reference to the value bound to `key` in `self`. Aborts if `key` is not + * bound in `self`. + */ +export function get>(options: GetOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TryGetArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface TryGetOptions> { + package: string; + arguments: + | TryGetArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Safely try borrow a value bound to `key` in `self`. Return Some(V) if the value + * exists, None otherwise. Only works for a "copyable" value as references cannot + * be stored in `vector`. + */ +export function tryGet>(options: TryGetOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'try_get', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Return true if `self` contains an entry for `key`, false otherwise */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + self: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Return the number of entries in `self` */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + self: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Return true if `self` has 0 elements, false otherwise */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments { + self: RawTransactionArgument; +} +export interface DestroyEmptyOptions { + package: string; + arguments: DestroyEmptyArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Destroy an empty map. Aborts if `self` is not empty */ +export function destroyEmpty(options: DestroyEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IntoKeysValuesArguments { + self: RawTransactionArgument; +} +export interface IntoKeysValuesOptions { + package: string; + arguments: IntoKeysValuesArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Unpack `self` into vectors of its keys and values. The output keys and values + * are stored in insertion order, _not_ sorted by key. + */ +export function intoKeysValues(options: IntoKeysValuesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'into_keys_values', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromKeysValuesArguments, V extends BcsType> { + keys: RawTransactionArgument; + values: RawTransactionArgument; +} +export interface FromKeysValuesOptions, V extends BcsType> { + package: string; + arguments: + | FromKeysValuesArguments + | [keys: RawTransactionArgument, values: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Construct a new `VecMap` from two vectors, one for keys and one for values. The + * key value pairs are associated via their indices in the vectors, e.g. the key at + * index i in `keys` is associated with the value at index i in `values`. The key + * value pairs are stored in insertion order (the original vectors ordering) and + * are _not_ sorted. + */ +export function fromKeysValues, V extends BcsType>( + options: FromKeysValuesOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `vector<${options.typeArguments[1]}>`, + ] satisfies (string | null)[]; + const parameterNames = ['keys', 'values']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'from_keys_values', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface KeysArguments { + self: RawTransactionArgument; +} +export interface KeysOptions { + package: string; + arguments: KeysArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Returns a list of keys in the map. Do not assume any particular ordering. */ +export function keys(options: KeysOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'keys', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetIdxOptArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface GetIdxOptOptions> { + package: string; + arguments: + | GetIdxOptArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Find the index of `key` in `self`. Return `None` if `key` is not in `self`. Note + * that map entries are stored in insertion order, _not_ sorted by key. + */ +export function getIdxOpt>(options: GetIdxOptOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get_idx_opt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetIdxArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface GetIdxOptions> { + package: string; + arguments: + | GetIdxArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Find the index of `key` in `self`. Aborts if `key` is not in `self`. Note that + * map entries are stored in insertion order, _not_ sorted by key. + */ +export function getIdx>(options: GetIdxOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get_idx', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetEntryByIdxArguments { + self: RawTransactionArgument; + idx: RawTransactionArgument; +} +export interface GetEntryByIdxOptions { + package: string; + arguments: + | GetEntryByIdxArguments + | [self: RawTransactionArgument, idx: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Return a reference to the `idx`th entry of `self`. This gives direct access into + * the backing array of the map--use with caution. Note that map entries are stored + * in insertion order, _not_ sorted by key. Aborts if `idx` is greater than or + * equal to `self.length()` + */ +export function getEntryByIdx(options: GetEntryByIdxOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'idx']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get_entry_by_idx', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetEntryByIdxMutArguments { + self: RawTransactionArgument; + idx: RawTransactionArgument; +} +export interface GetEntryByIdxMutOptions { + package: string; + arguments: + | GetEntryByIdxMutArguments + | [self: RawTransactionArgument, idx: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Return a mutable reference to the `idx`th entry of `self`. This gives direct + * access into the backing array of the map--use with caution. Note that map + * entries are stored in insertion order, _not_ sorted by key. Aborts if `idx` is + * greater than or equal to `self.length()` + */ +export function getEntryByIdxMut(options: GetEntryByIdxMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'idx']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'get_entry_by_idx_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveEntryByIdxArguments { + self: RawTransactionArgument; + idx: RawTransactionArgument; +} +export interface RemoveEntryByIdxOptions { + package: string; + arguments: + | RemoveEntryByIdxArguments + | [self: RawTransactionArgument, idx: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Remove the entry at index `idx` from self. Aborts if `idx` is greater than or + * equal to `self.length()` + */ +export function removeEntryByIdx(options: RemoveEntryByIdxOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'idx']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'remove_entry_by_idx', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SizeArguments { + self: RawTransactionArgument; +} +export interface SizeOptions { + package: string; + arguments: SizeArguments | [self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** Return the number of entries in `self` */ +export function size(options: SizeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_map', + function: 'size', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts new file mode 100644 index 000000000..22a4bf8e2 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts @@ -0,0 +1,281 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::vec_set'; +/** + * A set data structure backed by a vector. The set is guaranteed not to contain + * duplicate keys. All operations are O(N) in the size of the set + * + * - the intention of this data structure is only to provide the convenience of + * programming against a set API. Sets that need sorted iteration rather than + * insertion order iteration should be handwritten. + */ +export function VecSet>(...typeParameters: [K]) { + return new MoveStruct({ + name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, + fields: { + contents: bcs.vector(typeParameters[0]), + }, + }); +} +export interface EmptyOptions { + package: string; + arguments?: []; + typeArguments: [string]; +} +/** Create an empty `VecSet` */ +export function empty(options: EmptyOptions) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'empty', + typeArguments: options.typeArguments, + }); +} +export interface SingletonArguments> { + key: RawTransactionArgument; +} +export interface SingletonOptions> { + package: string; + arguments: SingletonArguments | [key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Create a singleton `VecSet` that only contains one element. */ +export function singleton>(options: SingletonOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'singleton', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface InsertArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface InsertOptions> { + package: string; + arguments: + | InsertArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Insert a `key` into self. Aborts if `key` is already present in `self`. */ +export function insert>(options: InsertOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface RemoveOptions> { + package: string; + arguments: + | RemoveArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Remove the entry `key` from self. Aborts if `key` is not present in `self`. */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + self: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface ContainsOptions> { + package: string; + arguments: + | ContainsArguments + | [self: RawTransactionArgument, key: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return true if `self` contains an entry for `key`, false otherwise */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['self', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments { + self: RawTransactionArgument; +} +export interface LengthOptions { + package: string; + arguments: LengthArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the number of entries in `self` */ +export function length(options: LengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments { + self: RawTransactionArgument; +} +export interface IsEmptyOptions { + package: string; + arguments: IsEmptyArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return true if `self` has 0 elements, false otherwise */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IntoKeysArguments { + self: RawTransactionArgument; +} +export interface IntoKeysOptions { + package: string; + arguments: IntoKeysArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Unpack `self` into vectors of keys. The output keys are stored in insertion + * order, _not_ sorted. + */ +export function intoKeys(options: IntoKeysOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'into_keys', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FromKeysArguments> { + keys: RawTransactionArgument; +} +export interface FromKeysOptions> { + package: string; + arguments: FromKeysArguments | [keys: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Construct a new `VecSet` from a vector of keys. The keys are stored in insertion + * order (the original `keys` ordering) and are _not_ sorted. + */ +export function fromKeys>(options: FromKeysOptions) { + const packageAddress = options.package; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['keys']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'from_keys', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface KeysArguments { + self: RawTransactionArgument; +} +export interface KeysOptions { + package: string; + arguments: KeysArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Borrow the `contents` of the `VecSet` to access content by index without + * unpacking. The contents are stored in insertion order, _not_ sorted. + */ +export function keys(options: KeysOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'keys', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SizeArguments { + self: RawTransactionArgument; +} +export interface SizeOptions { + package: string; + arguments: SizeArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the number of entries in `self` */ +export function size(options: SizeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vec_set', + function: 'size', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts b/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts new file mode 100644 index 000000000..9e520c16c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts @@ -0,0 +1,205 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::versioned'; +export const Versioned = new MoveStruct({ + name: `${$moduleName}::Versioned`, + fields: { + id: bcs.Address, + version: bcs.u64(), + }, +}); +export const VersionChangeCap = new MoveStruct({ + name: `${$moduleName}::VersionChangeCap`, + fields: { + versioned_id: bcs.Address, + old_version: bcs.u64(), + }, +}); +export interface CreateArguments> { + initVersion: RawTransactionArgument; + initValue: RawTransactionArgument; +} +export interface CreateOptions> { + package: string; + arguments: + | CreateArguments + | [initVersion: RawTransactionArgument, initValue: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Create a new Versioned object that contains a initial value of type `T` with an + * initial version. + */ +export function create>(options: CreateOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['initVersion', 'initValue']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'create', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface VersionArguments { + self: RawTransactionArgument; +} +export interface VersionOptions { + package: string; + arguments: VersionArguments | [self: RawTransactionArgument]; +} +/** Get the current version of the inner type. */ +export function version(options: VersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LoadValueArguments { + self: RawTransactionArgument; +} +export interface LoadValueOptions { + package: string; + arguments: LoadValueArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Load the inner value based on the current version. Caller specifies an expected + * type T. If the type mismatch, the load will fail. + */ +export function loadValue(options: LoadValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'load_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface LoadValueMutArguments { + self: RawTransactionArgument; +} +export interface LoadValueMutOptions { + package: string; + arguments: LoadValueMutArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Similar to load_value, but return a mutable reference. */ +export function loadValueMut(options: LoadValueMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'load_value_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveValueForUpgradeArguments { + self: RawTransactionArgument; +} +export interface RemoveValueForUpgradeOptions { + package: string; + arguments: RemoveValueForUpgradeArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Take the inner object out for upgrade. To ensure we always upgrade properly, a + * capability object is returned and must be used when we upgrade. + */ +export function removeValueForUpgrade(options: RemoveValueForUpgradeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'remove_value_for_upgrade', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface UpgradeArguments> { + self: RawTransactionArgument; + newVersion: RawTransactionArgument; + newValue: RawTransactionArgument; + cap: RawTransactionArgument; +} +export interface UpgradeOptions> { + package: string; + arguments: + | UpgradeArguments + | [ + self: RawTransactionArgument, + newVersion: RawTransactionArgument, + newValue: RawTransactionArgument, + cap: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Upgrade the inner object with a new version and new value. Must use the + * capability returned by calling remove_value_for_upgrade. + */ +export function upgrade>(options: UpgradeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64', `${options.typeArguments[0]}`, null] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'newVersion', 'newValue', 'cap']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'upgrade', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyArguments { + self: RawTransactionArgument; +} +export interface DestroyOptions { + package: string; + arguments: DestroyArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy this Versioned container, and return the inner object. */ +export function destroy(options: DestroyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'versioned', + function: 'destroy', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts new file mode 100644 index 000000000..ed625bde0 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts @@ -0,0 +1,234 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::zklogin_verified_id'; +export const VerifiedID = new MoveStruct({ + name: `${$moduleName}::VerifiedID`, + fields: { + /** The ID of this VerifiedID */ + id: bcs.Address, + /** The address this VerifiedID is associated with */ + owner: bcs.Address, + /** The name of the key claim */ + key_claim_name: bcs.string(), + /** The value of the key claim */ + key_claim_value: bcs.string(), + /** The issuer */ + issuer: bcs.string(), + /** The audience (wallet) */ + audience: bcs.string(), + }, +}); +export interface OwnerArguments { + verifiedId: RawTransactionArgument; +} +export interface OwnerOptions { + package: string; + arguments: OwnerArguments | [verifiedId: RawTransactionArgument]; +} +/** Returns the address associated with the given VerifiedID */ +export function owner(options: OwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface KeyClaimNameArguments { + verifiedId: RawTransactionArgument; +} +export interface KeyClaimNameOptions { + package: string; + arguments: KeyClaimNameArguments | [verifiedId: RawTransactionArgument]; +} +/** Returns the name of the key claim associated with the given VerifiedID */ +export function keyClaimName(options: KeyClaimNameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'key_claim_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface KeyClaimValueArguments { + verifiedId: RawTransactionArgument; +} +export interface KeyClaimValueOptions { + package: string; + arguments: KeyClaimValueArguments | [verifiedId: RawTransactionArgument]; +} +/** Returns the value of the key claim associated with the given VerifiedID */ +export function keyClaimValue(options: KeyClaimValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'key_claim_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IssuerArguments { + verifiedId: RawTransactionArgument; +} +export interface IssuerOptions { + package: string; + arguments: IssuerArguments | [verifiedId: RawTransactionArgument]; +} +/** Returns the issuer associated with the given VerifiedID */ +export function issuer(options: IssuerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'issuer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AudienceArguments { + verifiedId: RawTransactionArgument; +} +export interface AudienceOptions { + package: string; + arguments: AudienceArguments | [verifiedId: RawTransactionArgument]; +} +/** Returns the audience (wallet) associated with the given VerifiedID */ +export function audience(options: AudienceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'audience', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DeleteArguments { + verifiedId: RawTransactionArgument; +} +export interface DeleteOptions { + package: string; + arguments: DeleteArguments | [verifiedId: RawTransactionArgument]; +} +/** Delete a VerifiedID */ +export function _delete(options: DeleteOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'delete', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VerifyZkloginIdArguments { + KeyClaimName: RawTransactionArgument; + KeyClaimValue: RawTransactionArgument; + Issuer: RawTransactionArgument; + Audience: RawTransactionArgument; + PinHash: RawTransactionArgument; +} +export interface VerifyZkloginIdOptions { + package: string; + arguments: + | VerifyZkloginIdArguments + | [ + KeyClaimName: RawTransactionArgument, + KeyClaimValue: RawTransactionArgument, + Issuer: RawTransactionArgument, + Audience: RawTransactionArgument, + PinHash: RawTransactionArgument, + ]; +} +/** This function has been disabled. */ +export function verifyZkloginId(options: VerifyZkloginIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + 'u256', + ] satisfies (string | null)[]; + const parameterNames = ['KeyClaimName', 'KeyClaimValue', 'Issuer', 'Audience', 'PinHash']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'verify_zklogin_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CheckZkloginIdArguments { + Address: RawTransactionArgument; + KeyClaimName: RawTransactionArgument; + KeyClaimValue: RawTransactionArgument; + Issuer: RawTransactionArgument; + Audience: RawTransactionArgument; + PinHash: RawTransactionArgument; +} +export interface CheckZkloginIdOptions { + package: string; + arguments: + | CheckZkloginIdArguments + | [ + Address: RawTransactionArgument, + KeyClaimName: RawTransactionArgument, + KeyClaimValue: RawTransactionArgument, + Issuer: RawTransactionArgument, + Audience: RawTransactionArgument, + PinHash: RawTransactionArgument, + ]; +} +/** This function has been disabled. */ +export function checkZkloginId(options: CheckZkloginIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + 'address', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + '0x1::string::String', + 'u256', + ] satisfies (string | null)[]; + const parameterNames = [ + 'Address', + 'KeyClaimName', + 'KeyClaimValue', + 'Issuer', + 'Audience', + 'PinHash', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_id', + function: 'check_zklogin_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts new file mode 100644 index 000000000..12b8bd4de --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts @@ -0,0 +1,145 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x2::zklogin_verified_issuer'; +export const VerifiedIssuer = new MoveStruct({ + name: `${$moduleName}::VerifiedIssuer`, + fields: { + /** The ID of this VerifiedIssuer */ + id: bcs.Address, + /** The address this VerifiedID is associated with */ + owner: bcs.Address, + /** The issuer */ + issuer: bcs.string(), + }, +}); +export interface OwnerArguments { + verifiedIssuer: RawTransactionArgument; +} +export interface OwnerOptions { + package: string; + arguments: OwnerArguments | [verifiedIssuer: RawTransactionArgument]; +} +/** Returns the address associated with the given VerifiedIssuer */ +export function owner(options: OwnerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedIssuer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_issuer', + function: 'owner', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IssuerArguments { + verifiedIssuer: RawTransactionArgument; +} +export interface IssuerOptions { + package: string; + arguments: IssuerArguments | [verifiedIssuer: RawTransactionArgument]; +} +/** Returns the issuer associated with the given VerifiedIssuer */ +export function issuer(options: IssuerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedIssuer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_issuer', + function: 'issuer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DeleteArguments { + verifiedIssuer: RawTransactionArgument; +} +export interface DeleteOptions { + package: string; + arguments: DeleteArguments | [verifiedIssuer: RawTransactionArgument]; +} +/** Delete a VerifiedIssuer */ +export function _delete(options: DeleteOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['verifiedIssuer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_issuer', + function: 'delete', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VerifyZkloginIssuerArguments { + addressSeed: RawTransactionArgument; + issuer: RawTransactionArgument; +} +export interface VerifyZkloginIssuerOptions { + package: string; + arguments: + | VerifyZkloginIssuerArguments + | [ + addressSeed: RawTransactionArgument, + issuer: RawTransactionArgument, + ]; +} +/** + * Verify that the caller's address was created using zklogin with the given + * issuer. If so, a VerifiedIssuer object with the issuers id transferred to the + * caller. + * + * Aborts with `EInvalidProof` if the verification fails. + */ +export function verifyZkloginIssuer(options: VerifyZkloginIssuerOptions) { + const packageAddress = options.package; + const argumentsTypes = ['u256', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['addressSeed', 'issuer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_issuer', + function: 'verify_zklogin_issuer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CheckZkloginIssuerArguments { + address: RawTransactionArgument; + addressSeed: RawTransactionArgument; + issuer: RawTransactionArgument; +} +export interface CheckZkloginIssuerOptions { + package: string; + arguments: + | CheckZkloginIssuerArguments + | [ + address: RawTransactionArgument, + addressSeed: RawTransactionArgument, + issuer: RawTransactionArgument, + ]; +} +/** + * Returns true if `address` was created using zklogin with the given issuer and + * address seed. + */ +export function checkZkloginIssuer(options: CheckZkloginIssuerOptions) { + const packageAddress = options.package; + const argumentsTypes = ['address', 'u256', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['address', 'addressSeed', 'issuer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'zklogin_verified_issuer', + function: 'check_zklogin_issuer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts new file mode 100644 index 000000000..ae3a6919b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts @@ -0,0 +1,64 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = '0x3::genesis'; +export const GenesisValidatorMetadata = new MoveStruct({ + name: `${$moduleName}::GenesisValidatorMetadata`, + fields: { + name: bcs.vector(bcs.u8()), + description: bcs.vector(bcs.u8()), + image_url: bcs.vector(bcs.u8()), + project_url: bcs.vector(bcs.u8()), + sui_address: bcs.Address, + gas_price: bcs.u64(), + commission_rate: bcs.u64(), + protocol_public_key: bcs.vector(bcs.u8()), + proof_of_possession: bcs.vector(bcs.u8()), + network_public_key: bcs.vector(bcs.u8()), + worker_public_key: bcs.vector(bcs.u8()), + network_address: bcs.vector(bcs.u8()), + p2p_address: bcs.vector(bcs.u8()), + primary_address: bcs.vector(bcs.u8()), + worker_address: bcs.vector(bcs.u8()), + }, +}); +export const GenesisChainParameters = new MoveStruct({ + name: `${$moduleName}::GenesisChainParameters`, + fields: { + protocol_version: bcs.u64(), + chain_start_timestamp_ms: bcs.u64(), + epoch_duration_ms: bcs.u64(), + /** Stake Subsidy parameters */ + stake_subsidy_start_epoch: bcs.u64(), + stake_subsidy_initial_distribution_amount: bcs.u64(), + stake_subsidy_period_length: bcs.u64(), + stake_subsidy_decrease_rate: bcs.u16(), + /** Validator committee parameters */ + max_validator_count: bcs.u64(), + min_validator_joining_stake: bcs.u64(), + validator_low_stake_threshold: bcs.u64(), + validator_very_low_stake_threshold: bcs.u64(), + validator_low_stake_grace_period: bcs.u64(), + }, +}); +export const TokenAllocation = new MoveStruct({ + name: `${$moduleName}::TokenAllocation`, + fields: { + recipient_address: bcs.Address, + amount_mist: bcs.u64(), + /** + * Indicates if this allocation should be staked at genesis and with which + * validator + */ + staked_with_validator: bcs.option(bcs.Address), + }, +}); +export const TokenDistributionSchedule = new MoveStruct({ + name: `${$moduleName}::TokenDistributionSchedule`, + fields: { + stake_subsidy_fund_mist: bcs.u64(), + allocations: bcs.vector(TokenAllocation), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts new file mode 100644 index 000000000..2b0607035 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts @@ -0,0 +1,56 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from '../sui/balance.js'; +import * as bag from '../sui/bag.js'; +const $moduleName = '0x3::stake_subsidy'; +export const StakeSubsidy = new MoveStruct({ + name: `${$moduleName}::StakeSubsidy`, + fields: { + /** Balance of SUI set aside for stake subsidies that will be drawn down over time. */ + balance: balance.Balance, + /** Count of the number of times stake subsidies have been distributed. */ + distribution_counter: bcs.u64(), + /** + * The amount of stake subsidy to be drawn down per distribution. This amount + * decays and decreases over time. + */ + current_distribution_amount: bcs.u64(), + /** Number of distributions to occur before the distribution amount decays. */ + stake_subsidy_period_length: bcs.u64(), + /** + * The rate at which the distribution amount decays at the end of each period. + * Expressed in basis points. + */ + stake_subsidy_decrease_rate: bcs.u16(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export interface CurrentEpochSubsidyAmountArguments { + self: RawTransactionArgument; +} +export interface CurrentEpochSubsidyAmountOptions { + package: string; + arguments: CurrentEpochSubsidyAmountArguments | [self: RawTransactionArgument]; +} +/** Returns the amount of stake subsidy to be added at the end of the current epoch. */ +export function currentEpochSubsidyAmount(options: CurrentEpochSubsidyAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'stake_subsidy', + function: 'current_epoch_subsidy_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts new file mode 100644 index 000000000..46b2061fa --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts @@ -0,0 +1,521 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from '../sui/balance.js'; +import * as table from '../sui/table.js'; +import * as bag from '../sui/bag.js'; +const $moduleName = '0x3::staking_pool'; +export const StakingPool = new MoveStruct({ + name: `${$moduleName}::StakingPool`, + fields: { + id: bcs.Address, + /** + * The epoch at which this pool became active. The value is `None` if the pool is + * pre-active and `Some()` if active or inactive. + */ + activation_epoch: bcs.option(bcs.u64()), + /** + * The epoch at which this staking pool ceased to be active. `None` = {pre-active, + * active}, `Some()` if in-active, and it was de-activated at epoch + * ``. + */ + deactivation_epoch: bcs.option(bcs.u64()), + /** + * The total number of SUI tokens in this pool, including the SUI in the + * rewards_pool, as well as in all the principal in the `StakedSui` object, updated + * at epoch boundaries. + */ + sui_balance: bcs.u64(), + /** The epoch stake rewards will be added here at the end of each epoch. */ + rewards_pool: balance.Balance, + /** Total number of pool tokens issued by the pool. */ + pool_token_balance: bcs.u64(), + /** + * Exchange rate history of previous epochs. Key is the epoch number. The entries + * start from the `activation_epoch` of this pool and contains exchange rates at + * the beginning of each epoch, i.e., right after the rewards for the previous + * epoch have been deposited into the pool. + */ + exchange_rates: table.Table, + /** Pending stake amount for this epoch, emptied at epoch boundaries. */ + pending_stake: bcs.u64(), + /** + * Pending stake withdrawn during the current epoch, emptied at epoch boundaries. + * This includes both the principal and rewards SUI withdrawn. + */ + pending_total_sui_withdraw: bcs.u64(), + /** + * Pending pool token withdrawn during the current epoch, emptied at epoch + * boundaries. + */ + pending_pool_token_withdraw: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const PoolTokenExchangeRate = new MoveStruct({ + name: `${$moduleName}::PoolTokenExchangeRate`, + fields: { + sui_amount: bcs.u64(), + pool_token_amount: bcs.u64(), + }, +}); +export const StakedSui = new MoveStruct({ + name: `${$moduleName}::StakedSui`, + fields: { + id: bcs.Address, + /** ID of the staking pool we are staking with. */ + pool_id: bcs.Address, + /** The epoch at which the stake becomes active. */ + stake_activation_epoch: bcs.u64(), + /** The staked SUI tokens. */ + principal: balance.Balance, + }, +}); +export const FungibleStakedSui = new MoveStruct({ + name: `${$moduleName}::FungibleStakedSui`, + fields: { + id: bcs.Address, + /** ID of the staking pool we are staking with. */ + pool_id: bcs.Address, + /** The pool token amount. */ + value: bcs.u64(), + }, +}); +export const FungibleStakedSuiData = new MoveStruct({ + name: `${$moduleName}::FungibleStakedSuiData`, + fields: { + id: bcs.Address, + /** fungible_staked_sui supply */ + total_supply: bcs.u64(), + /** principal balance. Rewards are withdrawn from the reward pool */ + principal: balance.Balance, + }, +}); +export const FungibleStakedSuiDataKey = new MoveStruct({ + name: `${$moduleName}::FungibleStakedSuiDataKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const UnderflowSuiBalance = new MoveStruct({ + name: `${$moduleName}::UnderflowSuiBalance`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface SuiBalanceArguments { + pool: RawTransactionArgument; +} +export interface SuiBalanceOptions { + package: string; + arguments: SuiBalanceArguments | [pool: RawTransactionArgument]; +} +export function suiBalance(options: SuiBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pool']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'sui_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PoolIdArguments { + stakedSui: RawTransactionArgument; +} +export interface PoolIdOptions { + package: string; + arguments: PoolIdArguments | [stakedSui: RawTransactionArgument]; +} +export function poolId(options: PoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FungibleStakedSuiPoolIdArguments { + fungibleStakedSui: RawTransactionArgument; +} +export interface FungibleStakedSuiPoolIdOptions { + package: string; + arguments: FungibleStakedSuiPoolIdArguments | [fungibleStakedSui: RawTransactionArgument]; +} +export function fungibleStakedSuiPoolId(options: FungibleStakedSuiPoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['fungibleStakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'fungible_staked_sui_pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StakedSuiAmountArguments { + stakedSui: RawTransactionArgument; +} +export interface StakedSuiAmountOptions { + package: string; + arguments: StakedSuiAmountArguments | [stakedSui: RawTransactionArgument]; +} +/** Returns the principal amount of `StakedSui`. */ +export function stakedSuiAmount(options: StakedSuiAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'staked_sui_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StakeActivationEpochArguments { + stakedSui: RawTransactionArgument; +} +export interface StakeActivationEpochOptions { + package: string; + arguments: StakeActivationEpochArguments | [stakedSui: RawTransactionArgument]; +} +/** Returns the activation epoch of `StakedSui`. */ +export function stakeActivationEpoch(options: StakeActivationEpochOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'stake_activation_epoch', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsPreactiveArguments { + pool: RawTransactionArgument; +} +export interface IsPreactiveOptions { + package: string; + arguments: IsPreactiveArguments | [pool: RawTransactionArgument]; +} +/** Returns true if the input staking pool is preactive. */ +export function isPreactive(options: IsPreactiveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pool']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'is_preactive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsInactiveArguments { + pool: RawTransactionArgument; +} +export interface IsInactiveOptions { + package: string; + arguments: IsInactiveArguments | [pool: RawTransactionArgument]; +} +/** Returns true if the input staking pool is inactive. */ +export function isInactive(options: IsInactiveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['pool']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'is_inactive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FungibleStakedSuiValueArguments { + fungibleStakedSui: RawTransactionArgument; +} +export interface FungibleStakedSuiValueOptions { + package: string; + arguments: FungibleStakedSuiValueArguments | [fungibleStakedSui: RawTransactionArgument]; +} +export function fungibleStakedSuiValue(options: FungibleStakedSuiValueOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['fungibleStakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'fungible_staked_sui_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SplitFungibleStakedSuiArguments { + fungibleStakedSui: RawTransactionArgument; + splitAmount: RawTransactionArgument; +} +export interface SplitFungibleStakedSuiOptions { + package: string; + arguments: + | SplitFungibleStakedSuiArguments + | [ + fungibleStakedSui: RawTransactionArgument, + splitAmount: RawTransactionArgument, + ]; +} +export function splitFungibleStakedSui(options: SplitFungibleStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['fungibleStakedSui', 'splitAmount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'split_fungible_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface JoinFungibleStakedSuiArguments { + self: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface JoinFungibleStakedSuiOptions { + package: string; + arguments: + | JoinFungibleStakedSuiArguments + | [self: RawTransactionArgument, other: RawTransactionArgument]; +} +export function joinFungibleStakedSui(options: JoinFungibleStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'join_fungible_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SplitArguments { + self: RawTransactionArgument; + splitAmount: RawTransactionArgument; +} +export interface SplitOptions { + package: string; + arguments: + | SplitArguments + | [self: RawTransactionArgument, splitAmount: RawTransactionArgument]; +} +/** + * Split StakedSui `self` to two parts, one with principal `split_amount`, and the + * remaining principal is left in `self`. All the other parameters of the StakedSui + * like `stake_activation_epoch` or `pool_id` remain the same. + */ +export function split(options: SplitOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'splitAmount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'split', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SplitStakedSuiArguments { + stake: RawTransactionArgument; + splitAmount: RawTransactionArgument; +} +export interface SplitStakedSuiOptions { + package: string; + arguments: + | SplitStakedSuiArguments + | [stake: RawTransactionArgument, splitAmount: RawTransactionArgument]; +} +/** + * Split the given StakedSui to the two parts, one with principal `split_amount`, + * transfer the newly split part to the sender address. + */ +export function splitStakedSui(options: SplitStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['stake', 'splitAmount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'split_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface JoinStakedSuiArguments { + self: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface JoinStakedSuiOptions { + package: string; + arguments: + | JoinStakedSuiArguments + | [self: RawTransactionArgument, other: RawTransactionArgument]; +} +/** + * Consume the staked sui `other` and add its value to `self`. Aborts if some of + * the staking parameters are incompatible (pool id, stake activation epoch, etc.) + */ +export function joinStakedSui(options: JoinStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'join_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsEqualStakingMetadataArguments { + self: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface IsEqualStakingMetadataOptions { + package: string; + arguments: + | IsEqualStakingMetadataArguments + | [self: RawTransactionArgument, other: RawTransactionArgument]; +} +/** + * Returns true if all the staking parameters of the staked sui except the + * principal are identical + */ +export function isEqualStakingMetadata(options: IsEqualStakingMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'is_equal_staking_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PoolTokenExchangeRateAtEpochArguments { + pool: RawTransactionArgument; + epoch: RawTransactionArgument; +} +export interface PoolTokenExchangeRateAtEpochOptions { + package: string; + arguments: + | PoolTokenExchangeRateAtEpochArguments + | [pool: RawTransactionArgument, epoch: RawTransactionArgument]; +} +export function poolTokenExchangeRateAtEpoch(options: PoolTokenExchangeRateAtEpochOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['pool', 'epoch']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'pool_token_exchange_rate_at_epoch', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PendingStakeAmountArguments { + stakingPool: RawTransactionArgument; +} +export interface PendingStakeAmountOptions { + package: string; + arguments: PendingStakeAmountArguments | [stakingPool: RawTransactionArgument]; +} +/** Returns the total value of the pending staking requests for this staking pool. */ +export function pendingStakeAmount(options: PendingStakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['stakingPool']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'pending_stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PendingStakeWithdrawAmountArguments { + stakingPool: RawTransactionArgument; +} +export interface PendingStakeWithdrawAmountOptions { + package: string; + arguments: PendingStakeWithdrawAmountArguments | [stakingPool: RawTransactionArgument]; +} +/** Returns the total withdrawal from the staking pool this epoch. */ +export function pendingStakeWithdrawAmount(options: PendingStakeWithdrawAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['stakingPool']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'pending_stake_withdraw_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SuiAmountArguments { + exchangeRate: RawTransactionArgument; +} +export interface SuiAmountOptions { + package: string; + arguments: SuiAmountArguments | [exchangeRate: RawTransactionArgument]; +} +export function suiAmount(options: SuiAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['exchangeRate']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'sui_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PoolTokenAmountArguments { + exchangeRate: RawTransactionArgument; +} +export interface PoolTokenAmountOptions { + package: string; + arguments: PoolTokenAmountArguments | [exchangeRate: RawTransactionArgument]; +} +export function poolTokenAmount(options: PoolTokenAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['exchangeRate']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'staking_pool', + function: 'pool_token_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts new file mode 100644 index 000000000..27ddf932c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts @@ -0,0 +1,56 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from '../sui/balance.js'; +const $moduleName = '0x3::storage_fund'; +export const StorageFund = new MoveStruct({ + name: `${$moduleName}::StorageFund`, + fields: { + total_object_storage_rebates: balance.Balance, + non_refundable_balance: balance.Balance, + }, +}); +export interface TotalObjectStorageRebatesArguments { + self: RawTransactionArgument; +} +export interface TotalObjectStorageRebatesOptions { + package: string; + arguments: TotalObjectStorageRebatesArguments | [self: RawTransactionArgument]; +} +export function totalObjectStorageRebates(options: TotalObjectStorageRebatesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'storage_fund', + function: 'total_object_storage_rebates', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TotalBalanceArguments { + self: RawTransactionArgument; +} +export interface TotalBalanceOptions { + package: string; + arguments: TotalBalanceArguments | [self: RawTransactionArgument]; +} +export function totalBalance(options: TotalBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'storage_fund', + function: 'total_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts new file mode 100644 index 000000000..53208b44f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts @@ -0,0 +1,1204 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Sui System State Type Upgrade Guide `SuiSystemState` is a thin wrapper around + * `SuiSystemStateInner` that provides a versioned interface. The `SuiSystemState` + * object has a fixed ID 0x5, and the `SuiSystemStateInner` object is stored as a + * dynamic field. There are a few different ways to upgrade the + * `SuiSystemStateInner` type: + * + * The simplest and one that doesn't involve a real upgrade is to just add dynamic + * fields to the `extra_fields` field of `SuiSystemStateInner` or any of its sub + * type. This is useful when we are in a rush, or making a small change, or still + * experimenting a new field. + * + * To properly upgrade the `SuiSystemStateInner` type, we need to ship a new + * framework that does the following: + * + * 1. Define a new `SuiSystemStateInner`type (e.g. `SuiSystemStateInnerV2`). + * 2. Define a data migration function that migrates the old `SuiSystemStateInner` + * to the new one (i.e. SuiSystemStateInnerV2). + * 3. Replace all uses of `SuiSystemStateInner` with `SuiSystemStateInnerV2` in + * both sui_system.move and sui_system_state_inner.move, with the exception of + * the `sui_system_state_inner::create` function, which should always return + * the genesis type. + * 4. Inside `load_inner_maybe_upgrade` function, check the current version in the + * wrapper, and if it's not the latest version, call the data migration + * function to upgrade the inner object. Make sure to also update the version + * in the wrapper. A detailed example can be found in + * sui/tests/framework_upgrades/mock_sui_systems/shallow_upgrade. Along with + * the Move change, we also need to update the Rust code to support the new + * type. This includes: + * 5. Define a new `SuiSystemStateInner` struct type that matches the new Move + * type, and implement the SuiSystemStateTrait. + * 6. Update the `SuiSystemState` struct to include the new version as a new enum + * variant. + * 7. Update the `get_sui_system_state` function to handle the new version. To + * test that the upgrade will be successful, we need to modify + * `sui_system_state_production_upgrade_test` test in protocol_version_tests + * and trigger a real upgrade using the new framework. We will need to keep + * this directory as old version, put the new framework in a new directory, and + * run the test to exercise the upgrade. + * + * To upgrade Validator type, besides everything above, we also need to: + * + * 1. Define a new Validator type (e.g. ValidatorV2). + * 2. Define a data migration function that migrates the old Validator to the new + * one (i.e. ValidatorV2). + * 3. Replace all uses of Validator with ValidatorV2 except the genesis creation + * function. + * 4. In validator_wrapper::upgrade_to_latest, check the current version in the + * wrapper, and if it's not the latest version, call the data migration + * function to upgrade it. In Rust, we also need to add a new case in + * `get_validator_from_table`. Note that it is possible to upgrade + * SuiSystemStateInner without upgrading Validator, but not the other way + * around. And when we only upgrade SuiSystemStateInner, the version of + * Validator in the wrapper will not be updated, and hence may become + * inconsistent with the version of SuiSystemStateInner. This is fine as long + * as we don't use the Validator version to determine the SuiSystemStateInner + * version, or vice versa. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x3::sui_system'; +export const SuiSystemState = new MoveStruct({ + name: `${$moduleName}::SuiSystemState`, + fields: { + id: bcs.Address, + version: bcs.u64(), + }, +}); +export interface RequestAddValidatorCandidateArguments { + pubkeyBytes: RawTransactionArgument; + networkPubkeyBytes: RawTransactionArgument; + workerPubkeyBytes: RawTransactionArgument; + proofOfPossession: RawTransactionArgument; + name: RawTransactionArgument; + description: RawTransactionArgument; + imageUrl: RawTransactionArgument; + projectUrl: RawTransactionArgument; + netAddress: RawTransactionArgument; + p2pAddress: RawTransactionArgument; + primaryAddress: RawTransactionArgument; + workerAddress: RawTransactionArgument; + gasPrice: RawTransactionArgument; + commissionRate: RawTransactionArgument; +} +export interface RequestAddValidatorCandidateOptions { + package: string; + arguments: + | RequestAddValidatorCandidateArguments + | [ + pubkeyBytes: RawTransactionArgument, + networkPubkeyBytes: RawTransactionArgument, + workerPubkeyBytes: RawTransactionArgument, + proofOfPossession: RawTransactionArgument, + name: RawTransactionArgument, + description: RawTransactionArgument, + imageUrl: RawTransactionArgument, + projectUrl: RawTransactionArgument, + netAddress: RawTransactionArgument, + p2pAddress: RawTransactionArgument, + primaryAddress: RawTransactionArgument, + workerAddress: RawTransactionArgument, + gasPrice: RawTransactionArgument, + commissionRate: RawTransactionArgument, + ]; +} +/** + * Can be called by anyone who wishes to become a validator candidate and starts + * accruing delegated stakes in their staking pool. Once they have at least + * `MIN_VALIDATOR_JOINING_STAKE` amount of stake they can call + * `request_add_validator` to officially become an active validator at the next + * epoch. Aborts if the caller is already a pending or active validator, or a + * validator candidate. Note: `proof_of_possession` MUST be a valid signature using + * sui_address and protocol_pubkey_bytes. To produce a valid PoP, run [fn + * test_proof_of_possession]. + */ +export function requestAddValidatorCandidate(options: RequestAddValidatorCandidateOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x3::sui_system::SuiSystemState', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'vector', + 'u64', + 'u64', + ] satisfies (string | null)[]; + const parameterNames = [ + 'pubkeyBytes', + 'networkPubkeyBytes', + 'workerPubkeyBytes', + 'proofOfPossession', + 'name', + 'description', + 'imageUrl', + 'projectUrl', + 'netAddress', + 'p2pAddress', + 'primaryAddress', + 'workerAddress', + 'gasPrice', + 'commissionRate', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_add_validator_candidate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestRemoveValidatorCandidateArguments {} +export interface RequestRemoveValidatorCandidateOptions { + package: string; + arguments?: RequestRemoveValidatorCandidateArguments | []; +} +/** + * Called by a validator candidate to remove themselves from the candidacy. After + * this call their staking pool becomes deactivate. + */ +export function requestRemoveValidatorCandidate( + options: RequestRemoveValidatorCandidateOptions = {}, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_remove_validator_candidate', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface RequestAddValidatorArguments {} +export interface RequestAddValidatorOptions { + package: string; + arguments?: RequestAddValidatorArguments | []; +} +/** + * Called by a validator candidate to add themselves to the active validator set + * beginning next epoch. Aborts if the validator is a duplicate with one of the + * pending or active validators, or if the amount of stake the validator has + * doesn't meet the min threshold, or if the number of new validators for the next + * epoch has already reached the maximum. + */ +export function requestAddValidator(options: RequestAddValidatorOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_add_validator', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface RequestRemoveValidatorArguments {} +export interface RequestRemoveValidatorOptions { + package: string; + arguments?: RequestRemoveValidatorArguments | []; +} +/** + * A validator can call this function to request a removal in the next epoch. We + * use the sender of `ctx` to look up the validator (i.e. sender must match the + * sui_address in the validator). At the end of the epoch, the `validator` object + * will be returned to the sui_address of the validator. + */ +export function requestRemoveValidator(options: RequestRemoveValidatorOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_remove_validator', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface RequestSetGasPriceArguments { + cap: RawTransactionArgument; + newGasPrice: RawTransactionArgument; +} +export interface RequestSetGasPriceOptions { + package: string; + arguments: + | RequestSetGasPriceArguments + | [cap: RawTransactionArgument, newGasPrice: RawTransactionArgument]; +} +/** + * A validator can call this entry function to submit a new gas price quote, to be + * used for the reference gas price calculation at the end of the epoch. + */ +export function requestSetGasPrice(options: RequestSetGasPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = ['cap', 'newGasPrice']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_set_gas_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetCandidateValidatorGasPriceArguments { + cap: RawTransactionArgument; + newGasPrice: RawTransactionArgument; +} +export interface SetCandidateValidatorGasPriceOptions { + package: string; + arguments: + | SetCandidateValidatorGasPriceArguments + | [cap: RawTransactionArgument, newGasPrice: RawTransactionArgument]; +} +/** This entry function is used to set new gas price for candidate validators */ +export function setCandidateValidatorGasPrice(options: SetCandidateValidatorGasPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = ['cap', 'newGasPrice']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'set_candidate_validator_gas_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestSetCommissionRateArguments { + newCommissionRate: RawTransactionArgument; +} +export interface RequestSetCommissionRateOptions { + package: string; + arguments: + | RequestSetCommissionRateArguments + | [newCommissionRate: RawTransactionArgument]; +} +/** + * A validator can call this entry function to set a new commission rate, updated + * at the end of the epoch. + */ +export function requestSetCommissionRate(options: RequestSetCommissionRateOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'u64'] satisfies (string | null)[]; + const parameterNames = ['newCommissionRate']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_set_commission_rate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetCandidateValidatorCommissionRateArguments { + newCommissionRate: RawTransactionArgument; +} +export interface SetCandidateValidatorCommissionRateOptions { + package: string; + arguments: + | SetCandidateValidatorCommissionRateArguments + | [newCommissionRate: RawTransactionArgument]; +} +/** This entry function is used to set new commission rate for candidate validators */ +export function setCandidateValidatorCommissionRate( + options: SetCandidateValidatorCommissionRateOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'u64'] satisfies (string | null)[]; + const parameterNames = ['newCommissionRate']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'set_candidate_validator_commission_rate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestAddStakeArguments { + stake: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface RequestAddStakeOptions { + package: string; + arguments: + | RequestAddStakeArguments + | [stake: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +/** Add stake to a validator's staking pool. */ +export function requestAddStake(options: RequestAddStakeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( + | string + | null + )[]; + const parameterNames = ['stake', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_add_stake', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestAddStakeNonEntryArguments { + stake: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface RequestAddStakeNonEntryOptions { + package: string; + arguments: + | RequestAddStakeNonEntryArguments + | [stake: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +/** + * The non-entry version of `request_add_stake`, which returns the staked SUI + * instead of transferring it to the sender. + */ +export function requestAddStakeNonEntry(options: RequestAddStakeNonEntryOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( + | string + | null + )[]; + const parameterNames = ['stake', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_add_stake_non_entry', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestAddStakeMulCoinArguments { + stakes: RawTransactionArgument; + stakeAmount: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface RequestAddStakeMulCoinOptions { + package: string; + arguments: + | RequestAddStakeMulCoinArguments + | [ + stakes: RawTransactionArgument, + stakeAmount: RawTransactionArgument, + validatorAddress: RawTransactionArgument, + ]; +} +/** Add stake to a validator's staking pool using multiple coins. */ +export function requestAddStakeMulCoin(options: RequestAddStakeMulCoinOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + '0x3::sui_system::SuiSystemState', + 'vector', + '0x1::option::Option', + 'address', + ] satisfies (string | null)[]; + const parameterNames = ['stakes', 'stakeAmount', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_add_stake_mul_coin', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestWithdrawStakeArguments { + stakedSui: RawTransactionArgument; +} +export interface RequestWithdrawStakeOptions { + package: string; + arguments: RequestWithdrawStakeArguments | [stakedSui: RawTransactionArgument]; +} +/** Withdraw stake from a validator's staking pool. */ +export function requestWithdrawStake(options: RequestWithdrawStakeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_withdraw_stake', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ConvertToFungibleStakedSuiArguments { + stakedSui: RawTransactionArgument; +} +export interface ConvertToFungibleStakedSuiOptions { + package: string; + arguments: ConvertToFungibleStakedSuiArguments | [stakedSui: RawTransactionArgument]; +} +/** Convert StakedSui into a FungibleStakedSui object. */ +export function convertToFungibleStakedSui(options: ConvertToFungibleStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'convert_to_fungible_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RedeemFungibleStakedSuiArguments { + fungibleStakedSui: RawTransactionArgument; +} +export interface RedeemFungibleStakedSuiOptions { + package: string; + arguments: RedeemFungibleStakedSuiArguments | [fungibleStakedSui: RawTransactionArgument]; +} +/** Convert FungibleStakedSui into a StakedSui object. */ +export function redeemFungibleStakedSui(options: RedeemFungibleStakedSuiOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; + const parameterNames = ['fungibleStakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'redeem_fungible_staked_sui', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestWithdrawStakeNonEntryArguments { + stakedSui: RawTransactionArgument; +} +export interface RequestWithdrawStakeNonEntryOptions { + package: string; + arguments: RequestWithdrawStakeNonEntryArguments | [stakedSui: RawTransactionArgument]; +} +/** + * Non-entry version of `request_withdraw_stake` that returns the withdrawn SUI + * instead of transferring it to the sender. + */ +export function requestWithdrawStakeNonEntry(options: RequestWithdrawStakeNonEntryOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; + const parameterNames = ['stakedSui']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'request_withdraw_stake_non_entry', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReportValidatorArguments { + cap: RawTransactionArgument; + reporteeAddr: RawTransactionArgument; +} +export interface ReportValidatorOptions { + package: string; + arguments: + | ReportValidatorArguments + | [cap: RawTransactionArgument, reporteeAddr: RawTransactionArgument]; +} +/** + * Report a validator as a bad or non-performant actor in the system. Succeeds if + * all the following are satisfied: + * + * 1. both the reporter in `cap` and the input `reportee_addr` are active + * validators. + * 2. reporter and reportee not the same address. + * 3. the cap object is still valid. This function is idempotent. + */ +export function reportValidator(options: ReportValidatorOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( + | string + | null + )[]; + const parameterNames = ['cap', 'reporteeAddr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'report_validator', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UndoReportValidatorArguments { + cap: RawTransactionArgument; + reporteeAddr: RawTransactionArgument; +} +export interface UndoReportValidatorOptions { + package: string; + arguments: + | UndoReportValidatorArguments + | [cap: RawTransactionArgument, reporteeAddr: RawTransactionArgument]; +} +/** + * Undo a `report_validator` action. Aborts if + * + * 1. the reportee is not a currently active validator or + * 2. the sender has not previously reported the `reportee_addr`, or + * 3. the cap is not valid + */ +export function undoReportValidator(options: UndoReportValidatorOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( + | string + | null + )[]; + const parameterNames = ['cap', 'reporteeAddr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'undo_report_validator', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RotateOperationCapArguments {} +export interface RotateOperationCapOptions { + package: string; + arguments?: RotateOperationCapArguments | []; +} +/** + * Create a new `UnverifiedValidatorOperationCap`, transfer it to the validator and + * registers it. The original object is thus revoked. + */ +export function rotateOperationCap(options: RotateOperationCapOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'rotate_operation_cap', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNameArguments { + name: RawTransactionArgument; +} +export interface UpdateValidatorNameOptions { + package: string; + arguments: UpdateValidatorNameArguments | [name: RawTransactionArgument]; +} +/** Update a validator's name. */ +export function updateValidatorName(options: UpdateValidatorNameOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorDescriptionArguments { + description: RawTransactionArgument; +} +export interface UpdateValidatorDescriptionOptions { + package: string; + arguments: UpdateValidatorDescriptionArguments | [description: RawTransactionArgument]; +} +/** Update a validator's description */ +export function updateValidatorDescription(options: UpdateValidatorDescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['description']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorImageUrlArguments { + imageUrl: RawTransactionArgument; +} +export interface UpdateValidatorImageUrlOptions { + package: string; + arguments: UpdateValidatorImageUrlArguments | [imageUrl: RawTransactionArgument]; +} +/** Update a validator's image url */ +export function updateValidatorImageUrl(options: UpdateValidatorImageUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['imageUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_image_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorProjectUrlArguments { + projectUrl: RawTransactionArgument; +} +export interface UpdateValidatorProjectUrlOptions { + package: string; + arguments: UpdateValidatorProjectUrlArguments | [projectUrl: RawTransactionArgument]; +} +/** Update a validator's project url */ +export function updateValidatorProjectUrl(options: UpdateValidatorProjectUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['projectUrl']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_project_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochNetworkAddressArguments { + networkAddress: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochNetworkAddressOptions { + package: string; + arguments: + | UpdateValidatorNextEpochNetworkAddressArguments + | [networkAddress: RawTransactionArgument]; +} +/** + * Update a validator's network address. The change will only take effects starting + * from the next epoch. + */ +export function updateValidatorNextEpochNetworkAddress( + options: UpdateValidatorNextEpochNetworkAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['networkAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_network_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorNetworkAddressArguments { + networkAddress: RawTransactionArgument; +} +export interface UpdateCandidateValidatorNetworkAddressOptions { + package: string; + arguments: + | UpdateCandidateValidatorNetworkAddressArguments + | [networkAddress: RawTransactionArgument]; +} +/** Update candidate validator's network address. */ +export function updateCandidateValidatorNetworkAddress( + options: UpdateCandidateValidatorNetworkAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['networkAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_network_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochP2pAddressArguments { + p2pAddress: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochP2pAddressOptions { + package: string; + arguments: + | UpdateValidatorNextEpochP2pAddressArguments + | [p2pAddress: RawTransactionArgument]; +} +/** + * Update a validator's p2p address. The change will only take effects starting + * from the next epoch. + */ +export function updateValidatorNextEpochP2pAddress( + options: UpdateValidatorNextEpochP2pAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['p2pAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_p2p_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorP2pAddressArguments { + p2pAddress: RawTransactionArgument; +} +export interface UpdateCandidateValidatorP2pAddressOptions { + package: string; + arguments: + | UpdateCandidateValidatorP2pAddressArguments + | [p2pAddress: RawTransactionArgument]; +} +/** Update candidate validator's p2p address. */ +export function updateCandidateValidatorP2pAddress( + options: UpdateCandidateValidatorP2pAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['p2pAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_p2p_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochPrimaryAddressArguments { + primaryAddress: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochPrimaryAddressOptions { + package: string; + arguments: + | UpdateValidatorNextEpochPrimaryAddressArguments + | [primaryAddress: RawTransactionArgument]; +} +/** + * Update a validator's narwhal primary address. The change will only take effects + * starting from the next epoch. + */ +export function updateValidatorNextEpochPrimaryAddress( + options: UpdateValidatorNextEpochPrimaryAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['primaryAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_primary_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorPrimaryAddressArguments { + primaryAddress: RawTransactionArgument; +} +export interface UpdateCandidateValidatorPrimaryAddressOptions { + package: string; + arguments: + | UpdateCandidateValidatorPrimaryAddressArguments + | [primaryAddress: RawTransactionArgument]; +} +/** Update candidate validator's narwhal primary address. */ +export function updateCandidateValidatorPrimaryAddress( + options: UpdateCandidateValidatorPrimaryAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['primaryAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_primary_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochWorkerAddressArguments { + workerAddress: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochWorkerAddressOptions { + package: string; + arguments: + | UpdateValidatorNextEpochWorkerAddressArguments + | [workerAddress: RawTransactionArgument]; +} +/** + * Update a validator's narwhal worker address. The change will only take effects + * starting from the next epoch. + */ +export function updateValidatorNextEpochWorkerAddress( + options: UpdateValidatorNextEpochWorkerAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['workerAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_worker_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorWorkerAddressArguments { + workerAddress: RawTransactionArgument; +} +export interface UpdateCandidateValidatorWorkerAddressOptions { + package: string; + arguments: + | UpdateCandidateValidatorWorkerAddressArguments + | [workerAddress: RawTransactionArgument]; +} +/** Update candidate validator's narwhal worker address. */ +export function updateCandidateValidatorWorkerAddress( + options: UpdateCandidateValidatorWorkerAddressOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['workerAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_worker_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochProtocolPubkeyArguments { + protocolPubkey: RawTransactionArgument; + proofOfPossession: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochProtocolPubkeyOptions { + package: string; + arguments: + | UpdateValidatorNextEpochProtocolPubkeyArguments + | [ + protocolPubkey: RawTransactionArgument, + proofOfPossession: RawTransactionArgument, + ]; +} +/** + * Update a validator's public key of protocol key and proof of possession. The + * change will only take effects starting from the next epoch. + */ +export function updateValidatorNextEpochProtocolPubkey( + options: UpdateValidatorNextEpochProtocolPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['protocolPubkey', 'proofOfPossession']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_protocol_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorProtocolPubkeyArguments { + protocolPubkey: RawTransactionArgument; + proofOfPossession: RawTransactionArgument; +} +export interface UpdateCandidateValidatorProtocolPubkeyOptions { + package: string; + arguments: + | UpdateCandidateValidatorProtocolPubkeyArguments + | [ + protocolPubkey: RawTransactionArgument, + proofOfPossession: RawTransactionArgument, + ]; +} +/** Update candidate validator's public key of protocol key and proof of possession. */ +export function updateCandidateValidatorProtocolPubkey( + options: UpdateCandidateValidatorProtocolPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['protocolPubkey', 'proofOfPossession']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_protocol_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochWorkerPubkeyArguments { + workerPubkey: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochWorkerPubkeyOptions { + package: string; + arguments: + | UpdateValidatorNextEpochWorkerPubkeyArguments + | [workerPubkey: RawTransactionArgument]; +} +/** + * Update a validator's public key of worker key. The change will only take effects + * starting from the next epoch. + */ +export function updateValidatorNextEpochWorkerPubkey( + options: UpdateValidatorNextEpochWorkerPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['workerPubkey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_worker_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorWorkerPubkeyArguments { + workerPubkey: RawTransactionArgument; +} +export interface UpdateCandidateValidatorWorkerPubkeyOptions { + package: string; + arguments: + | UpdateCandidateValidatorWorkerPubkeyArguments + | [workerPubkey: RawTransactionArgument]; +} +/** Update candidate validator's public key of worker key. */ +export function updateCandidateValidatorWorkerPubkey( + options: UpdateCandidateValidatorWorkerPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['workerPubkey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_worker_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateValidatorNextEpochNetworkPubkeyArguments { + networkPubkey: RawTransactionArgument; +} +export interface UpdateValidatorNextEpochNetworkPubkeyOptions { + package: string; + arguments: + | UpdateValidatorNextEpochNetworkPubkeyArguments + | [networkPubkey: RawTransactionArgument]; +} +/** + * Update a validator's public key of network key. The change will only take + * effects starting from the next epoch. + */ +export function updateValidatorNextEpochNetworkPubkey( + options: UpdateValidatorNextEpochNetworkPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['networkPubkey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_validator_next_epoch_network_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UpdateCandidateValidatorNetworkPubkeyArguments { + networkPubkey: RawTransactionArgument; +} +export interface UpdateCandidateValidatorNetworkPubkeyOptions { + package: string; + arguments: + | UpdateCandidateValidatorNetworkPubkeyArguments + | [networkPubkey: RawTransactionArgument]; +} +/** Update candidate validator's public key of network key. */ +export function updateCandidateValidatorNetworkPubkey( + options: UpdateCandidateValidatorNetworkPubkeyOptions, +) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( + | string + | null + )[]; + const parameterNames = ['networkPubkey']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'update_candidate_validator_network_pubkey', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorAddressByPoolIdArguments { + poolId: RawTransactionArgument; +} +export interface ValidatorAddressByPoolIdOptions { + package: string; + arguments: ValidatorAddressByPoolIdArguments | [poolId: RawTransactionArgument]; +} +export function validatorAddressByPoolId(options: ValidatorAddressByPoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', '0x2::object::ID'] satisfies ( + | string + | null + )[]; + const parameterNames = ['poolId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'validator_address_by_pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PoolExchangeRatesArguments { + poolId: RawTransactionArgument; +} +export interface PoolExchangeRatesOptions { + package: string; + arguments: PoolExchangeRatesArguments | [poolId: RawTransactionArgument]; +} +/** + * Getter of the pool token exchange rate of a staking pool. Works for both active + * and inactive pools. + */ +export function poolExchangeRates(options: PoolExchangeRatesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState', '0x2::object::ID'] satisfies ( + | string + | null + )[]; + const parameterNames = ['poolId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'pool_exchange_rates', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ActiveValidatorAddressesArguments {} +export interface ActiveValidatorAddressesOptions { + package: string; + arguments?: ActiveValidatorAddressesArguments | []; +} +/** Getter returning addresses of the currently active validators. */ +export function activeValidatorAddresses(options: ActiveValidatorAddressesOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'active_validator_addresses', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface ActiveValidatorAddressesRefArguments {} +export interface ActiveValidatorAddressesRefOptions { + package: string; + arguments?: ActiveValidatorAddressesRefArguments | []; +} +/** Getter returning addresses of the currently active validators by reference. */ +export function activeValidatorAddressesRef(options: ActiveValidatorAddressesRefOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'active_validator_addresses_ref', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} +export interface ActiveValidatorVotingPowersArguments {} +export interface ActiveValidatorVotingPowersOptions { + package: string; + arguments?: ActiveValidatorVotingPowersArguments | []; +} +/** + * Getter returns the voting power of the active validators, values are voting + * power in the scale of 10000. + */ +export function activeValidatorVotingPowers(options: ActiveValidatorVotingPowersOptions = {}) { + const packageAddress = options.package; + const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; + const parameterNames = []; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'sui_system', + function: 'active_validator_voting_powers', + arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts new file mode 100644 index 000000000..f25e42053 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts @@ -0,0 +1,212 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import * as bag from '../sui/bag.js'; +import * as validator_set from './validator_set.js'; +import * as storage_fund from './storage_fund.js'; +import * as vec_map from '../sui/vec_map.js'; +import * as vec_set from '../sui/vec_set.js'; +import * as stake_subsidy from './stake_subsidy.js'; +import * as balance from '../sui/balance.js'; +const $moduleName = '0x3::sui_system_state_inner'; +export const ExecutionTimeObservationChunkKey = new MoveStruct({ + name: `${$moduleName}::ExecutionTimeObservationChunkKey`, + fields: { + chunk_index: bcs.u64(), + }, +}); +export const SystemParameters = new MoveStruct({ + name: `${$moduleName}::SystemParameters`, + fields: { + /** The duration of an epoch, in milliseconds. */ + epoch_duration_ms: bcs.u64(), + /** The starting epoch in which stake subsidies start being paid out */ + stake_subsidy_start_epoch: bcs.u64(), + /** + * Deprecated. Maximum number of active validators at any moment. We do not allow + * the number of validators in any epoch to go above this. + */ + max_validator_count: bcs.u64(), + /** Deprecated. Lower-bound on the amount of stake required to become a validator. */ + min_validator_joining_stake: bcs.u64(), + /** + * Validators with stake amount below `validator_low_stake_threshold` are + * considered to have low stake and will be escorted out of the validator set after + * being below this threshold for more than `validator_low_stake_grace_period` + * number of epochs. + */ + validator_low_stake_threshold: bcs.u64(), + /** + * Deprecated. Validators with stake below `validator_very_low_stake_threshold` + * will be removed immediately at epoch change, no grace period. + */ + validator_very_low_stake_threshold: bcs.u64(), + /** + * A validator can have stake below `validator_low_stake_threshold` for this many + * epochs before being kicked out. + */ + validator_low_stake_grace_period: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const SystemParametersV2 = new MoveStruct({ + name: `${$moduleName}::SystemParametersV2`, + fields: { + /** The duration of an epoch, in milliseconds. */ + epoch_duration_ms: bcs.u64(), + /** The starting epoch in which stake subsidies start being paid out */ + stake_subsidy_start_epoch: bcs.u64(), + /** Minimum number of active validators at any moment. */ + min_validator_count: bcs.u64(), + /** + * Maximum number of active validators at any moment. We do not allow the number of + * validators in any epoch to go above this. + */ + max_validator_count: bcs.u64(), + /** Deprecated. Lower-bound on the amount of stake required to become a validator. */ + min_validator_joining_stake: bcs.u64(), + /** + * Deprecated. Validators with stake amount below `validator_low_stake_threshold` + * are considered to have low stake and will be escorted out of the validator set + * after being below this threshold for more than + * `validator_low_stake_grace_period` number of epochs. + */ + validator_low_stake_threshold: bcs.u64(), + /** + * Deprecated. Validators with stake below `validator_very_low_stake_threshold` + * will be removed immediately at epoch change, no grace period. + */ + validator_very_low_stake_threshold: bcs.u64(), + /** + * A validator can have stake below `validator_low_stake_threshold` for this many + * epochs before being kicked out. + */ + validator_low_stake_grace_period: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const SuiSystemStateInner = new MoveStruct({ + name: `${$moduleName}::SuiSystemStateInner`, + fields: { + /** The current epoch ID, starting from 0. */ + epoch: bcs.u64(), + /** The current protocol version, starting from 1. */ + protocol_version: bcs.u64(), + /** + * The current version of the system state data structure type. This is always the + * same as SuiSystemState.version. Keeping a copy here so that we know what version + * it is by inspecting SuiSystemStateInner as well. + */ + system_state_version: bcs.u64(), + /** Contains all information about the validators. */ + validators: validator_set.ValidatorSet, + /** The storage fund. */ + storage_fund: storage_fund.StorageFund, + /** A list of system config parameters. */ + parameters: SystemParameters, + /** The reference gas price for the current epoch. */ + reference_gas_price: bcs.u64(), + /** + * A map storing the records of validator reporting each other. There is an entry + * in the map for each validator that has been reported at least once. The entry + * VecSet contains all the validators that reported them. If a validator has never + * been reported they don't have an entry in this map. This map persists across + * epoch: a peer continues being in a reported state until the reporter doesn't + * explicitly remove their report. Note that in case we want to support validator + * address change in future, the reports should be based on validator ids + */ + validator_report_records: vec_map.VecMap(bcs.Address, vec_set.VecSet(bcs.Address)), + /** Schedule of stake subsidies given out each epoch. */ + stake_subsidy: stake_subsidy.StakeSubsidy, + /** + * Whether the system is running in a downgraded safe mode due to a non-recoverable + * bug. This is set whenever we failed to execute advance*epoch, and ended up + * executing advance_epoch_safe_mode. It can be reset once we are able to + * successfully execute advance_epoch. The rest of the fields starting with + * `safe_mode*` are accumulated during safe mode when advance_epoch_safe_mode is + * executed. They will eventually be processed once we are out of safe mode. + */ + safe_mode: bcs.bool(), + safe_mode_storage_rewards: balance.Balance, + safe_mode_computation_rewards: balance.Balance, + safe_mode_storage_rebates: bcs.u64(), + safe_mode_non_refundable_storage_fee: bcs.u64(), + /** Unix timestamp of the current epoch start */ + epoch_start_timestamp_ms: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const SuiSystemStateInnerV2 = new MoveStruct({ + name: `${$moduleName}::SuiSystemStateInnerV2`, + fields: { + /** The current epoch ID, starting from 0. */ + epoch: bcs.u64(), + /** The current protocol version, starting from 1. */ + protocol_version: bcs.u64(), + /** + * The current version of the system state data structure type. This is always the + * same as SuiSystemState.version. Keeping a copy here so that we know what version + * it is by inspecting SuiSystemStateInner as well. + */ + system_state_version: bcs.u64(), + /** Contains all information about the validators. */ + validators: validator_set.ValidatorSet, + /** The storage fund. */ + storage_fund: storage_fund.StorageFund, + /** A list of system config parameters. */ + parameters: SystemParametersV2, + /** The reference gas price for the current epoch. */ + reference_gas_price: bcs.u64(), + /** + * A map storing the records of validator reporting each other. There is an entry + * in the map for each validator that has been reported at least once. The entry + * VecSet contains all the validators that reported them. If a validator has never + * been reported they don't have an entry in this map. This map persists across + * epoch: a peer continues being in a reported state until the reporter doesn't + * explicitly remove their report. Note that in case we want to support validator + * address change in future, the reports should be based on validator ids + */ + validator_report_records: vec_map.VecMap(bcs.Address, vec_set.VecSet(bcs.Address)), + /** Schedule of stake subsidies given out each epoch. */ + stake_subsidy: stake_subsidy.StakeSubsidy, + /** + * Whether the system is running in a downgraded safe mode due to a non-recoverable + * bug. This is set whenever we failed to execute advance*epoch, and ended up + * executing advance_epoch_safe_mode. It can be reset once we are able to + * successfully execute advance_epoch. The rest of the fields starting with + * `safe_mode*` are accumulated during safe mode when advance_epoch_safe_mode is + * executed. They will eventually be processed once we are out of safe mode. + */ + safe_mode: bcs.bool(), + safe_mode_storage_rewards: balance.Balance, + safe_mode_computation_rewards: balance.Balance, + safe_mode_storage_rebates: bcs.u64(), + safe_mode_non_refundable_storage_fee: bcs.u64(), + /** Unix timestamp of the current epoch start */ + epoch_start_timestamp_ms: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const SystemEpochInfoEvent = new MoveStruct({ + name: `${$moduleName}::SystemEpochInfoEvent`, + fields: { + epoch: bcs.u64(), + protocol_version: bcs.u64(), + reference_gas_price: bcs.u64(), + total_stake: bcs.u64(), + storage_fund_reinvestment: bcs.u64(), + storage_charge: bcs.u64(), + storage_rebate: bcs.u64(), + storage_fund_balance: bcs.u64(), + stake_subsidy_amount: bcs.u64(), + total_gas_fees: bcs.u64(), + total_stake_rewards_distributed: bcs.u64(), + leftover_storage_fund_inflow: bcs.u64(), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts new file mode 100644 index 000000000..c63e99ce7 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts @@ -0,0 +1,870 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as url from '../sui/url.js'; +import * as bag from '../sui/bag.js'; +import * as staking_pool from './staking_pool.js'; +const $moduleName = '0x3::validator'; +export const ValidatorMetadata = new MoveStruct({ + name: `${$moduleName}::ValidatorMetadata`, + fields: { + /** + * The Sui Address of the validator. This is the sender that created the Validator + * object, and also the address to send validator/coins to during withdraws. + */ + sui_address: bcs.Address, + /** + * The public key bytes corresponding to the private key that the validator holds + * to sign transactions. For now, this is the same as AuthorityName. + */ + protocol_pubkey_bytes: bcs.vector(bcs.u8()), + /** + * The public key bytes corresponding to the private key that the validator uses to + * establish TLS connections + */ + network_pubkey_bytes: bcs.vector(bcs.u8()), + /** The public key bytes correstponding to the Narwhal Worker */ + worker_pubkey_bytes: bcs.vector(bcs.u8()), + /** This is a proof that the validator has ownership of the private key */ + proof_of_possession: bcs.vector(bcs.u8()), + /** A unique human-readable name of this validator. */ + name: bcs.string(), + description: bcs.string(), + image_url: url.Url, + project_url: url.Url, + /** + * The network address of the validator (could also contain extra info such as + * port, DNS and etc.). + */ + net_address: bcs.string(), + /** + * The address of the validator used for p2p activities such as state sync (could + * also contain extra info such as port, DNS and etc.). + */ + p2p_address: bcs.string(), + /** The address of the narwhal primary */ + primary_address: bcs.string(), + /** The address of the narwhal worker */ + worker_address: bcs.string(), + /** + * "next_epoch" metadata only takes effects in the next epoch. If none, current + * value will stay unchanged. + */ + next_epoch_protocol_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), + next_epoch_proof_of_possession: bcs.option(bcs.vector(bcs.u8())), + next_epoch_network_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), + next_epoch_worker_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), + next_epoch_net_address: bcs.option(bcs.string()), + next_epoch_p2p_address: bcs.option(bcs.string()), + next_epoch_primary_address: bcs.option(bcs.string()), + next_epoch_worker_address: bcs.option(bcs.string()), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const Validator = new MoveStruct({ + name: `${$moduleName}::Validator`, + fields: { + /** Summary of the validator. */ + metadata: ValidatorMetadata, + /** + * The voting power of this validator, which might be different from its stake + * amount. + */ + voting_power: bcs.u64(), + /** The ID of this validator's current valid `UnverifiedValidatorOperationCap` */ + operation_cap_id: bcs.Address, + /** Gas price quote, updated only at end of epoch. */ + gas_price: bcs.u64(), + /** Staking pool for this validator. */ + staking_pool: staking_pool.StakingPool, + /** Commission rate of the validator, in basis point. */ + commission_rate: bcs.u64(), + /** Total amount of stake that would be active in the next epoch. */ + next_epoch_stake: bcs.u64(), + /** This validator's gas price quote for the next epoch. */ + next_epoch_gas_price: bcs.u64(), + /** The commission rate of the validator starting the next epoch, in basis point. */ + next_epoch_commission_rate: bcs.u64(), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const StakingRequestEvent = new MoveStruct({ + name: `${$moduleName}::StakingRequestEvent`, + fields: { + pool_id: bcs.Address, + validator_address: bcs.Address, + staker_address: bcs.Address, + epoch: bcs.u64(), + amount: bcs.u64(), + }, +}); +export const UnstakingRequestEvent = new MoveStruct({ + name: `${$moduleName}::UnstakingRequestEvent`, + fields: { + pool_id: bcs.Address, + validator_address: bcs.Address, + staker_address: bcs.Address, + stake_activation_epoch: bcs.u64(), + unstaking_epoch: bcs.u64(), + principal_amount: bcs.u64(), + reward_amount: bcs.u64(), + }, +}); +export const ConvertingToFungibleStakedSuiEvent = new MoveStruct({ + name: `${$moduleName}::ConvertingToFungibleStakedSuiEvent`, + fields: { + pool_id: bcs.Address, + stake_activation_epoch: bcs.u64(), + staked_sui_principal_amount: bcs.u64(), + fungible_staked_sui_amount: bcs.u64(), + }, +}); +export const RedeemingFungibleStakedSuiEvent = new MoveStruct({ + name: `${$moduleName}::RedeemingFungibleStakedSuiEvent`, + fields: { + pool_id: bcs.Address, + fungible_staked_sui_amount: bcs.u64(), + sui_amount: bcs.u64(), + }, +}); +export interface IsPreactiveArguments { + self: RawTransactionArgument; +} +export interface IsPreactiveOptions { + package: string; + arguments: IsPreactiveArguments | [self: RawTransactionArgument]; +} +/** Returns true if the validator is preactive. */ +export function isPreactive(options: IsPreactiveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'is_preactive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MetadataArguments { + self: RawTransactionArgument; +} +export interface MetadataOptions { + package: string; + arguments: MetadataArguments | [self: RawTransactionArgument]; +} +export function metadata(options: MetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SuiAddressArguments { + self: RawTransactionArgument; +} +export interface SuiAddressOptions { + package: string; + arguments: SuiAddressArguments | [self: RawTransactionArgument]; +} +export function suiAddress(options: SuiAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'sui_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NameArguments { + self: RawTransactionArgument; +} +export interface NameOptions { + package: string; + arguments: NameArguments | [self: RawTransactionArgument]; +} +export function name(options: NameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DescriptionArguments { + self: RawTransactionArgument; +} +export interface DescriptionOptions { + package: string; + arguments: DescriptionArguments | [self: RawTransactionArgument]; +} +export function description(options: DescriptionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'description', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ImageUrlArguments { + self: RawTransactionArgument; +} +export interface ImageUrlOptions { + package: string; + arguments: ImageUrlArguments | [self: RawTransactionArgument]; +} +export function imageUrl(options: ImageUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'image_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProjectUrlArguments { + self: RawTransactionArgument; +} +export interface ProjectUrlOptions { + package: string; + arguments: ProjectUrlArguments | [self: RawTransactionArgument]; +} +export function projectUrl(options: ProjectUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'project_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NetworkAddressArguments { + self: RawTransactionArgument; +} +export interface NetworkAddressOptions { + package: string; + arguments: NetworkAddressArguments | [self: RawTransactionArgument]; +} +export function networkAddress(options: NetworkAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'network_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface P2pAddressArguments { + self: RawTransactionArgument; +} +export interface P2pAddressOptions { + package: string; + arguments: P2pAddressArguments | [self: RawTransactionArgument]; +} +export function p2pAddress(options: P2pAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'p2p_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PrimaryAddressArguments { + self: RawTransactionArgument; +} +export interface PrimaryAddressOptions { + package: string; + arguments: PrimaryAddressArguments | [self: RawTransactionArgument]; +} +export function primaryAddress(options: PrimaryAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'primary_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface WorkerAddressArguments { + self: RawTransactionArgument; +} +export interface WorkerAddressOptions { + package: string; + arguments: WorkerAddressArguments | [self: RawTransactionArgument]; +} +export function workerAddress(options: WorkerAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'worker_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProtocolPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface ProtocolPubkeyBytesOptions { + package: string; + arguments: ProtocolPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function protocolPubkeyBytes(options: ProtocolPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'protocol_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ProofOfPossessionArguments { + self: RawTransactionArgument; +} +export interface ProofOfPossessionOptions { + package: string; + arguments: ProofOfPossessionArguments | [self: RawTransactionArgument]; +} +export function proofOfPossession(options: ProofOfPossessionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'proof_of_possession', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NetworkPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface NetworkPubkeyBytesOptions { + package: string; + arguments: NetworkPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function networkPubkeyBytes(options: NetworkPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'network_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface WorkerPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface WorkerPubkeyBytesOptions { + package: string; + arguments: WorkerPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function workerPubkeyBytes(options: WorkerPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'worker_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochNetworkAddressArguments { + self: RawTransactionArgument; +} +export interface NextEpochNetworkAddressOptions { + package: string; + arguments: NextEpochNetworkAddressArguments | [self: RawTransactionArgument]; +} +export function nextEpochNetworkAddress(options: NextEpochNetworkAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_network_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochP2pAddressArguments { + self: RawTransactionArgument; +} +export interface NextEpochP2pAddressOptions { + package: string; + arguments: NextEpochP2pAddressArguments | [self: RawTransactionArgument]; +} +export function nextEpochP2pAddress(options: NextEpochP2pAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_p2p_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochPrimaryAddressArguments { + self: RawTransactionArgument; +} +export interface NextEpochPrimaryAddressOptions { + package: string; + arguments: NextEpochPrimaryAddressArguments | [self: RawTransactionArgument]; +} +export function nextEpochPrimaryAddress(options: NextEpochPrimaryAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_primary_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochWorkerAddressArguments { + self: RawTransactionArgument; +} +export interface NextEpochWorkerAddressOptions { + package: string; + arguments: NextEpochWorkerAddressArguments | [self: RawTransactionArgument]; +} +export function nextEpochWorkerAddress(options: NextEpochWorkerAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_worker_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochProtocolPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface NextEpochProtocolPubkeyBytesOptions { + package: string; + arguments: NextEpochProtocolPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function nextEpochProtocolPubkeyBytes(options: NextEpochProtocolPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_protocol_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochProofOfPossessionArguments { + self: RawTransactionArgument; +} +export interface NextEpochProofOfPossessionOptions { + package: string; + arguments: NextEpochProofOfPossessionArguments | [self: RawTransactionArgument]; +} +export function nextEpochProofOfPossession(options: NextEpochProofOfPossessionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_proof_of_possession', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochNetworkPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface NextEpochNetworkPubkeyBytesOptions { + package: string; + arguments: NextEpochNetworkPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function nextEpochNetworkPubkeyBytes(options: NextEpochNetworkPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_network_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochWorkerPubkeyBytesArguments { + self: RawTransactionArgument; +} +export interface NextEpochWorkerPubkeyBytesOptions { + package: string; + arguments: NextEpochWorkerPubkeyBytesArguments | [self: RawTransactionArgument]; +} +export function nextEpochWorkerPubkeyBytes(options: NextEpochWorkerPubkeyBytesOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_worker_pubkey_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface OperationCapIdArguments { + self: RawTransactionArgument; +} +export interface OperationCapIdOptions { + package: string; + arguments: OperationCapIdArguments | [self: RawTransactionArgument]; +} +export function operationCapId(options: OperationCapIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'operation_cap_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NextEpochGasPriceArguments { + self: RawTransactionArgument; +} +export interface NextEpochGasPriceOptions { + package: string; + arguments: NextEpochGasPriceArguments | [self: RawTransactionArgument]; +} +export function nextEpochGasPrice(options: NextEpochGasPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'next_epoch_gas_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TotalStakeAmountArguments { + self: RawTransactionArgument; +} +export interface TotalStakeAmountOptions { + package: string; + arguments: TotalStakeAmountArguments | [self: RawTransactionArgument]; +} +export function totalStakeAmount(options: TotalStakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'total_stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StakeAmountArguments { + self: RawTransactionArgument; +} +export interface StakeAmountOptions { + package: string; + arguments: StakeAmountArguments | [self: RawTransactionArgument]; +} +export function stakeAmount(options: StakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TotalStakeArguments { + self: RawTransactionArgument; +} +export interface TotalStakeOptions { + package: string; + arguments: TotalStakeArguments | [self: RawTransactionArgument]; +} +/** Return the total amount staked with this validator */ +export function totalStake(options: TotalStakeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'total_stake', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface VotingPowerArguments { + self: RawTransactionArgument; +} +export interface VotingPowerOptions { + package: string; + arguments: VotingPowerArguments | [self: RawTransactionArgument]; +} +/** Return the voting power of this validator. */ +export function votingPower(options: VotingPowerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'voting_power', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PendingStakeAmountArguments { + self: RawTransactionArgument; +} +export interface PendingStakeAmountOptions { + package: string; + arguments: PendingStakeAmountArguments | [self: RawTransactionArgument]; +} +export function pendingStakeAmount(options: PendingStakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'pending_stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PendingStakeWithdrawAmountArguments { + self: RawTransactionArgument; +} +export interface PendingStakeWithdrawAmountOptions { + package: string; + arguments: PendingStakeWithdrawAmountArguments | [self: RawTransactionArgument]; +} +export function pendingStakeWithdrawAmount(options: PendingStakeWithdrawAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'pending_stake_withdraw_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GasPriceArguments { + self: RawTransactionArgument; +} +export interface GasPriceOptions { + package: string; + arguments: GasPriceArguments | [self: RawTransactionArgument]; +} +export function gasPrice(options: GasPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'gas_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CommissionRateArguments { + self: RawTransactionArgument; +} +export interface CommissionRateOptions { + package: string; + arguments: CommissionRateArguments | [self: RawTransactionArgument]; +} +export function commissionRate(options: CommissionRateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'commission_rate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PoolTokenExchangeRateAtEpochArguments { + self: RawTransactionArgument; + epoch: RawTransactionArgument; +} +export interface PoolTokenExchangeRateAtEpochOptions { + package: string; + arguments: + | PoolTokenExchangeRateAtEpochArguments + | [self: RawTransactionArgument, epoch: RawTransactionArgument]; +} +export function poolTokenExchangeRateAtEpoch(options: PoolTokenExchangeRateAtEpochOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'epoch']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'pool_token_exchange_rate_at_epoch', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StakingPoolIdArguments { + self: RawTransactionArgument; +} +export interface StakingPoolIdOptions { + package: string; + arguments: StakingPoolIdArguments | [self: RawTransactionArgument]; +} +export function stakingPoolId(options: StakingPoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'staking_pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsDuplicateArguments { + self: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface IsDuplicateOptions { + package: string; + arguments: + | IsDuplicateArguments + | [self: RawTransactionArgument, other: RawTransactionArgument]; +} +export function isDuplicate(options: IsDuplicateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'is_duplicate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidateMetadataArguments { + metadata: RawTransactionArgument; +} +export interface ValidateMetadataOptions { + package: string; + arguments: ValidateMetadataArguments | [metadata: RawTransactionArgument]; +} +/** Aborts if validator metadata is valid */ +export function validateMetadata(options: ValidateMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'validate_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidateMetadataBcsArguments { + metadata: RawTransactionArgument; +} +export interface ValidateMetadataBcsOptions { + package: string; + arguments: ValidateMetadataBcsArguments | [metadata: RawTransactionArgument]; +} +export function validateMetadataBcs(options: ValidateMetadataBcsOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['metadata']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator', + function: 'validate_metadata_bcs', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts new file mode 100644 index 000000000..f6da63e52 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts @@ -0,0 +1,19 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = '0x3::validator_cap'; +export const UnverifiedValidatorOperationCap = new MoveStruct({ + name: `${$moduleName}::UnverifiedValidatorOperationCap`, + fields: { + id: bcs.Address, + authorizer_validator_address: bcs.Address, + }, +}); +export const ValidatorOperationCap = new MoveStruct({ + name: `${$moduleName}::ValidatorOperationCap`, + fields: { + authorizer_validator_address: bcs.Address, + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts new file mode 100644 index 000000000..ee38fabc1 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts @@ -0,0 +1,426 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + MoveTuple, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as validator from './validator.js'; +import * as table_vec from '../sui/table_vec.js'; +import * as table from '../sui/table.js'; +import * as vec_map from '../sui/vec_map.js'; +import * as bag from '../sui/bag.js'; +import * as staking_pool from './staking_pool.js'; +const $moduleName = '0x3::validator_set'; +export const ValidatorSet = new MoveStruct({ + name: `${$moduleName}::ValidatorSet`, + fields: { + /** + * Total amount of stake from all active validators at the beginning of the epoch. + * Written only once per epoch, in `advance_epoch` function. + */ + total_stake: bcs.u64(), + /** The current list of active validators. */ + active_validators: bcs.vector(validator.Validator), + /** + * List of new validator candidates added during the current epoch. They will be + * processed at the end of the epoch. + */ + pending_active_validators: table_vec.TableVec, + /** + * Removal requests from the validators. Each element is an index pointing to + * `active_validators`. + */ + pending_removals: bcs.vector(bcs.u64()), + /** Mappings from staking pool's ID to the sui address of a validator. */ + staking_pool_mappings: table.Table, + /** + * Mapping from a staking pool ID to the inactive validator that has that pool as + * its staking pool. When a validator is deactivated the validator is removed from + * `active_validators` it is added to this table so that stakers can continue to + * withdraw their stake from it. + */ + inactive_validators: table.Table, + /** + * Table storing preactive/candidate validators, mapping their addresses to their + * `Validator ` structs. When an address calls `request_add_validator_candidate`, + * they get added to this table and become a preactive validator. When the + * candidate has met the min stake requirement, they can call + * `request_add_validator` to officially add them to the active validator set + * `active_validators` next epoch. + */ + validator_candidates: table.Table, + /** + * Table storing the number of epochs during which a validator's stake has been + * below the low stake threshold. + */ + at_risk_validators: vec_map.VecMap(bcs.Address, bcs.u64()), + /** Any extra fields that's not defined statically. */ + extra_fields: bag.Bag, + }, +}); +export const ValidatorEpochInfoEvent = new MoveStruct({ + name: `${$moduleName}::ValidatorEpochInfoEvent`, + fields: { + epoch: bcs.u64(), + validator_address: bcs.Address, + reference_gas_survey_quote: bcs.u64(), + stake: bcs.u64(), + commission_rate: bcs.u64(), + pool_staking_reward: bcs.u64(), + storage_fund_staking_reward: bcs.u64(), + pool_token_exchange_rate: staking_pool.PoolTokenExchangeRate, + tallying_rule_reporters: bcs.vector(bcs.Address), + tallying_rule_global_score: bcs.u64(), + }, +}); +export const ValidatorEpochInfoEventV2 = new MoveStruct({ + name: `${$moduleName}::ValidatorEpochInfoEventV2`, + fields: { + epoch: bcs.u64(), + validator_address: bcs.Address, + reference_gas_survey_quote: bcs.u64(), + stake: bcs.u64(), + voting_power: bcs.u64(), + commission_rate: bcs.u64(), + pool_staking_reward: bcs.u64(), + storage_fund_staking_reward: bcs.u64(), + pool_token_exchange_rate: staking_pool.PoolTokenExchangeRate, + tallying_rule_reporters: bcs.vector(bcs.Address), + tallying_rule_global_score: bcs.u64(), + }, +}); +export const ValidatorJoinEvent = new MoveStruct({ + name: `${$moduleName}::ValidatorJoinEvent`, + fields: { + epoch: bcs.u64(), + validator_address: bcs.Address, + staking_pool_id: bcs.Address, + }, +}); +export const ValidatorLeaveEvent = new MoveStruct({ + name: `${$moduleName}::ValidatorLeaveEvent`, + fields: { + epoch: bcs.u64(), + validator_address: bcs.Address, + staking_pool_id: bcs.Address, + is_voluntary: bcs.bool(), + }, +}); +export const VotingPowerAdmissionStartEpochKey = new MoveTuple({ + name: `${$moduleName}::VotingPowerAdmissionStartEpochKey`, + fields: [bcs.bool()], +}); +export interface DeriveReferenceGasPriceArguments { + self: RawTransactionArgument; +} +export interface DeriveReferenceGasPriceOptions { + package: string; + arguments: DeriveReferenceGasPriceArguments | [self: RawTransactionArgument]; +} +/** + * Called by `sui_system` to derive reference gas price for the new epoch. Derive + * the reference gas price based on the gas price quote submitted by each + * validator. The returned gas price should be greater than or equal to 2/3 of the + * validators submitted gas price, weighted by stake. + */ +export function deriveReferenceGasPrice(options: DeriveReferenceGasPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'derive_reference_gas_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TotalStakeArguments { + self: RawTransactionArgument; +} +export interface TotalStakeOptions { + package: string; + arguments: TotalStakeArguments | [self: RawTransactionArgument]; +} +export function totalStake(options: TotalStakeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'total_stake', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorTotalStakeAmountArguments { + self: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface ValidatorTotalStakeAmountOptions { + package: string; + arguments: + | ValidatorTotalStakeAmountArguments + | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +export function validatorTotalStakeAmount(options: ValidatorTotalStakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'validator_total_stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorStakeAmountArguments { + self: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface ValidatorStakeAmountOptions { + package: string; + arguments: + | ValidatorStakeAmountArguments + | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +export function validatorStakeAmount(options: ValidatorStakeAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'validator_stake_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorVotingPowerArguments { + self: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface ValidatorVotingPowerOptions { + package: string; + arguments: + | ValidatorVotingPowerArguments + | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +export function validatorVotingPower(options: ValidatorVotingPowerOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'validator_voting_power', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorStakingPoolIdArguments { + self: RawTransactionArgument; + validatorAddress: RawTransactionArgument; +} +export interface ValidatorStakingPoolIdOptions { + package: string; + arguments: + | ValidatorStakingPoolIdArguments + | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; +} +export function validatorStakingPoolId(options: ValidatorStakingPoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'validatorAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'validator_staking_pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface StakingPoolMappingsArguments { + self: RawTransactionArgument; +} +export interface StakingPoolMappingsOptions { + package: string; + arguments: StakingPoolMappingsArguments | [self: RawTransactionArgument]; +} +export function stakingPoolMappings(options: StakingPoolMappingsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'staking_pool_mappings', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ValidatorAddressByPoolIdArguments { + self: RawTransactionArgument; + poolId: RawTransactionArgument; +} +export interface ValidatorAddressByPoolIdOptions { + package: string; + arguments: + | ValidatorAddressByPoolIdArguments + | [self: RawTransactionArgument, poolId: RawTransactionArgument]; +} +export function validatorAddressByPoolId(options: ValidatorAddressByPoolIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'poolId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'validator_address_by_pool_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetActiveValidatorRefArguments { + self: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface GetActiveValidatorRefOptions { + package: string; + arguments: + | GetActiveValidatorRefArguments + | [self: RawTransactionArgument, addr: RawTransactionArgument]; +} +export function getActiveValidatorRef(options: GetActiveValidatorRefOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'get_active_validator_ref', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetPendingValidatorRefArguments { + self: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface GetPendingValidatorRefOptions { + package: string; + arguments: + | GetPendingValidatorRefArguments + | [self: RawTransactionArgument, addr: RawTransactionArgument]; +} +export function getPendingValidatorRef(options: GetPendingValidatorRefOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'get_pending_validator_ref', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SumVotingPowerByAddressesArguments { + vs: RawTransactionArgument; + addresses: RawTransactionArgument; +} +export interface SumVotingPowerByAddressesOptions { + package: string; + arguments: + | SumVotingPowerByAddressesArguments + | [vs: RawTransactionArgument, addresses: RawTransactionArgument]; +} +/** Sum up the total stake of a given list of validator addresses. */ +export function sumVotingPowerByAddresses(options: SumVotingPowerByAddressesOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector
'] satisfies (string | null)[]; + const parameterNames = ['vs', 'addresses']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'sum_voting_power_by_addresses', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ActiveValidatorsArguments { + self: RawTransactionArgument; +} +export interface ActiveValidatorsOptions { + package: string; + arguments: ActiveValidatorsArguments | [self: RawTransactionArgument]; +} +/** Return the active validators in `self` */ +export function activeValidators(options: ActiveValidatorsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'active_validators', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsValidatorCandidateArguments { + self: RawTransactionArgument; + addr: RawTransactionArgument; +} +export interface IsValidatorCandidateOptions { + package: string; + arguments: + | IsValidatorCandidateArguments + | [self: RawTransactionArgument, addr: RawTransactionArgument]; +} +/** Returns true if the `addr` is a validator candidate. */ +export function isValidatorCandidate(options: IsValidatorCandidateOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'addr']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'is_validator_candidate', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsInactiveValidatorArguments { + self: RawTransactionArgument; + stakingPoolId: RawTransactionArgument; +} +export interface IsInactiveValidatorOptions { + package: string; + arguments: + | IsInactiveValidatorArguments + | [self: RawTransactionArgument, stakingPoolId: RawTransactionArgument]; +} +/** + * Returns true if the staking pool identified by `staking_pool_id` is of an + * inactive validator. + */ +export function isInactiveValidator(options: IsInactiveValidatorOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['self', 'stakingPoolId']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'validator_set', + function: 'is_inactive_validator', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts new file mode 100644 index 000000000..56550b349 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts @@ -0,0 +1,12 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import * as versioned from '../sui/versioned.js'; +const $moduleName = '0x3::validator_wrapper'; +export const ValidatorWrapper = new MoveStruct({ + name: `${$moduleName}::ValidatorWrapper`, + fields: { + inner: versioned.Versioned, + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts new file mode 100644 index 000000000..73d8bd4ca --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts @@ -0,0 +1,50 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '0x3::voting_power'; +export const VotingPowerInfo = new MoveStruct({ + name: `${$moduleName}::VotingPowerInfo`, + fields: { + validator_index: bcs.u64(), + voting_power: bcs.u64(), + }, +}); +export const VotingPowerInfoV2 = new MoveStruct({ + name: `${$moduleName}::VotingPowerInfoV2`, + fields: { + validator_index: bcs.u64(), + voting_power: bcs.u64(), + stake: bcs.u64(), + }, +}); +export interface TotalVotingPowerOptions { + package: string; + arguments?: []; +} +/** Return the (constant) total voting power */ +export function totalVotingPower(options: TotalVotingPowerOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'voting_power', + function: 'total_voting_power', + }); +} +export interface QuorumThresholdOptions { + package: string; + arguments?: []; +} +/** Return the (constant) quorum threshold */ +export function quorumThreshold(options: QuorumThresholdOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'voting_power', + function: 'quorum_threshold', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts b/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts new file mode 100644 index 000000000..ebc470d56 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts @@ -0,0 +1,118 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Admin features of the SuiNS application. Meant to be called directly by the + * suins admin. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'suins::admin'; +export const Admin = new MoveStruct({ + name: `${$moduleName}::Admin`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface AuthorizeArguments { + cap: RawTransactionArgument; + suins: RawTransactionArgument; +} +export interface AuthorizeOptions { + package: string; + arguments: + | AuthorizeArguments + | [cap: RawTransactionArgument, suins: RawTransactionArgument]; +} +/** + * Authorize the admin application in the SuiNS to get access to protected + * functions. Must be called in order to use the rest of the functions. + */ +export function authorize(options: AuthorizeOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['cap', 'suins']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'admin', + function: 'authorize', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReserveDomainArguments { + _: RawTransactionArgument; + suins: RawTransactionArgument; + domainName: RawTransactionArgument; + noYears: RawTransactionArgument; +} +export interface ReserveDomainOptions { + package: string; + arguments: + | ReserveDomainArguments + | [ + _: RawTransactionArgument, + suins: RawTransactionArgument, + domainName: RawTransactionArgument, + noYears: RawTransactionArgument, + ]; +} +/** Reserve a `domain` in the `SuiNS`. */ +export function reserveDomain(options: ReserveDomainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String', 'u8', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['_', 'suins', 'domainName', 'noYears']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'admin', + function: 'reserve_domain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReserveDomainsArguments { + _: RawTransactionArgument; + suins: RawTransactionArgument; + domains: RawTransactionArgument; + noYears: RawTransactionArgument; +} +export interface ReserveDomainsOptions { + package: string; + arguments: + | ReserveDomainsArguments + | [ + _: RawTransactionArgument, + suins: RawTransactionArgument, + domains: RawTransactionArgument, + noYears: RawTransactionArgument, + ]; +} +/** Reserve a list of domains. */ +export function reserveDomains(options: ReserveDomainsOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + null, + 'vector<0x1::string::String>', + 'u8', + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['_', 'suins', 'domains', 'noYears']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'admin', + function: 'reserve_domains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts b/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts new file mode 100644 index 000000000..6aae3cefd --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts @@ -0,0 +1,345 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Implementation of auction module. More information in: ../../../docs */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from '../sui/balance.js'; +import * as linked_table from '../sui/linked_table.js'; +import * as domain from './domain.js'; +import * as coin from '../sui/coin.js'; +import * as suins_registration from './suins_registration.js'; +const $moduleName = 'suins::auction'; +export const App = new MoveStruct({ + name: `${$moduleName}::App`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const AuctionHouse = new MoveStruct({ + name: `${$moduleName}::AuctionHouse`, + fields: { + id: bcs.Address, + balance: balance.Balance, + auctions: linked_table.LinkedTable(domain.Domain), + }, +}); +export const Auction = new MoveStruct({ + name: `${$moduleName}::Auction`, + fields: { + domain: domain.Domain, + start_timestamp_ms: bcs.u64(), + end_timestamp_ms: bcs.u64(), + winner: bcs.Address, + current_bid: coin.Coin, + nft: suins_registration.SuinsRegistration, + }, +}); +export const AuctionStartedEvent = new MoveStruct({ + name: `${$moduleName}::AuctionStartedEvent`, + fields: { + domain: domain.Domain, + start_timestamp_ms: bcs.u64(), + end_timestamp_ms: bcs.u64(), + starting_bid: bcs.u64(), + bidder: bcs.Address, + }, +}); +export const AuctionFinalizedEvent = new MoveStruct({ + name: `${$moduleName}::AuctionFinalizedEvent`, + fields: { + domain: domain.Domain, + start_timestamp_ms: bcs.u64(), + end_timestamp_ms: bcs.u64(), + winning_bid: bcs.u64(), + winner: bcs.Address, + }, +}); +export const BidEvent = new MoveStruct({ + name: `${$moduleName}::BidEvent`, + fields: { + domain: domain.Domain, + bid: bcs.u64(), + bidder: bcs.Address, + }, +}); +export const AuctionExtendedEvent = new MoveStruct({ + name: `${$moduleName}::AuctionExtendedEvent`, + fields: { + domain: domain.Domain, + end_timestamp_ms: bcs.u64(), + }, +}); +export interface StartAuctionAndPlaceBidArguments { + self: RawTransactionArgument; + suins: RawTransactionArgument; + domainName: RawTransactionArgument; + bid: RawTransactionArgument; +} +export interface StartAuctionAndPlaceBidOptions { + package: string; + arguments: + | StartAuctionAndPlaceBidArguments + | [ + self: RawTransactionArgument, + suins: RawTransactionArgument, + domainName: RawTransactionArgument, + bid: RawTransactionArgument, + ]; +} +/** Start an auction if it's not started yet; and make the first bid. */ +export function startAuctionAndPlaceBid(options: StartAuctionAndPlaceBidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'suins', 'domainName', 'bid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'start_auction_and_place_bid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PlaceBidArguments { + self: RawTransactionArgument; + domainName: RawTransactionArgument; + bid: RawTransactionArgument; +} +export interface PlaceBidOptions { + package: string; + arguments: + | PlaceBidArguments + | [ + self: RawTransactionArgument, + domainName: RawTransactionArgument, + bid: RawTransactionArgument, + ]; +} +/** + * #### Notice + * + * Bidders use this function to place a new bid. + * + * Panics Panics if `domain` is invalid or there isn't an auction for `domain` or + * `bid` is too low, + */ +export function placeBid(options: PlaceBidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'domainName', 'bid']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'place_bid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ClaimArguments { + self: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface ClaimOptions { + package: string; + arguments: + | ClaimArguments + | [self: RawTransactionArgument, domainName: RawTransactionArgument]; +} +/** + * #### Notice + * + * Auction winner can come and claim the NFT + * + * Panics sender is not the winner + */ +export function claim(options: ClaimOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'claim', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetAuctionMetadataArguments { + self: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface GetAuctionMetadataOptions { + package: string; + arguments: + | GetAuctionMetadataArguments + | [self: RawTransactionArgument, domainName: RawTransactionArgument]; +} +/** + * #### Notice + * + * Get metadata of an auction + * + * #### Params + * + * The domain name being auctioned. + * + * #### Return + * + * (`start_timestamp_ms`, `end_timestamp_ms`, `winner`, `highest_amount`) + */ +export function getAuctionMetadata(options: GetAuctionMetadataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['self', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'get_auction_metadata', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CollectWinningAuctionFundArguments { + self: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface CollectWinningAuctionFundOptions { + package: string; + arguments: + | CollectWinningAuctionFundArguments + | [self: RawTransactionArgument, domainName: RawTransactionArgument]; +} +export function collectWinningAuctionFund(options: CollectWinningAuctionFundOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['self', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'collect_winning_auction_fund', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AdminWithdrawFundsArguments { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface AdminWithdrawFundsOptions { + package: string; + arguments: + | AdminWithdrawFundsArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; +} +export function adminWithdrawFunds(options: AdminWithdrawFundsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'admin_withdraw_funds', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AdminFinalizeAuctionArguments { + admin: RawTransactionArgument; + self: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface AdminFinalizeAuctionOptions { + package: string; + arguments: + | AdminFinalizeAuctionArguments + | [ + admin: RawTransactionArgument, + self: RawTransactionArgument, + domain: RawTransactionArgument, + ]; +} +/** + * Admin functionality used to finalize a single auction. + * + * An `operation_limit` limit must be provided which controls how many individual + * operations to perform. This allows the admin to be able to make forward progress + * in finalizing auctions even in the presence of thousands of bids. + * + * This will attempt to do as much as possible of the following based on the + * provided `operation_limit`: + * + * - claim the winning bid and place in `AuctionHouse.balance` + * - push the `SuinsRegistration` to the winner + * - push loosing bids back to their respective account owners + * + * Once all of the above has been done the auction is destroyed, freeing on-chain + * storage. + */ +export function adminFinalizeAuction(options: AdminFinalizeAuctionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['admin', 'self', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'admin_finalize_auction', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AdminTryFinalizeAuctionsArguments { + admin: RawTransactionArgument; + self: RawTransactionArgument; + operationLimit: RawTransactionArgument; +} +export interface AdminTryFinalizeAuctionsOptions { + package: string; + arguments: + | AdminTryFinalizeAuctionsArguments + | [ + admin: RawTransactionArgument, + self: RawTransactionArgument, + operationLimit: RawTransactionArgument, + ]; +} +/** + * Admin functionality used to finalize an arbitrary number of auctions. + * + * An `operation_limit` limit must be provided which controls how many individual + * operations to perform. This allows the admin to be able to make forward progress + * in finalizing auctions even in the presence of thousands of auctions/bids. + */ +export function adminTryFinalizeAuctions(options: AdminTryFinalizeAuctionsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['admin', 'self', 'operationLimit']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'auction', + function: 'admin_try_finalize_auctions', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/config.ts new file mode 100644 index 000000000..5942f427e --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/config.ts @@ -0,0 +1,229 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'suins::config'; +export const Config = new MoveStruct({ + name: `${$moduleName}::Config`, + fields: { + public_key: bcs.vector(bcs.u8()), + three_char_price: bcs.u64(), + four_char_price: bcs.u64(), + five_plus_char_price: bcs.u64(), + }, +}); +export interface NewArguments { + PublicKey: RawTransactionArgument; + ThreeCharPrice: RawTransactionArgument; + FourCharPrice: RawTransactionArgument; + FivePlusCharPrice: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: + | NewArguments + | [ + PublicKey: RawTransactionArgument, + ThreeCharPrice: RawTransactionArgument, + FourCharPrice: RawTransactionArgument, + FivePlusCharPrice: RawTransactionArgument, + ]; +} +/** + * Create a new instance of the configuration object. Define all properties from + * the start. + */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'u64', 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['PublicKey', 'ThreeCharPrice', 'FourCharPrice', 'FivePlusCharPrice']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetPublicKeyOptions { + package: string; + arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; +} +export function setPublicKey(options: SetPublicKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'set_public_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + }); +} +export interface SetThreeCharPriceOptions { + package: string; + arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; +} +export function setThreeCharPrice(options: SetThreeCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'set_three_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + }); +} +export interface SetFourCharPriceOptions { + package: string; + arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; +} +export function setFourCharPrice(options: SetFourCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'set_four_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + }); +} +export interface SetFivePlusCharPriceOptions { + package: string; + arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; +} +export function setFivePlusCharPrice(options: SetFivePlusCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'set_five_plus_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + }); +} +export interface CalculatePriceOptions { + package: string; + arguments: [ + _: RawTransactionArgument, + _: RawTransactionArgument, + _: RawTransactionArgument, + ]; +} +export function calculatePrice(options: CalculatePriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8', 'u8'] satisfies (string | null)[]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'calculate_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes), + }); +} +export interface PublicKeyArguments { + _: RawTransactionArgument; +} +export interface PublicKeyOptions { + package: string; + arguments: PublicKeyArguments | [_: RawTransactionArgument]; +} +export function publicKey(options: PublicKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'public_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ThreeCharPriceArguments { + _: RawTransactionArgument; +} +export interface ThreeCharPriceOptions { + package: string; + arguments: ThreeCharPriceArguments | [_: RawTransactionArgument]; +} +export function threeCharPrice(options: ThreeCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'three_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FourCharPriceArguments { + _: RawTransactionArgument; +} +export interface FourCharPriceOptions { + package: string; + arguments: FourCharPriceArguments | [_: RawTransactionArgument]; +} +export function fourCharPrice(options: FourCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'four_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FivePlusCharPriceArguments { + _: RawTransactionArgument; +} +export interface FivePlusCharPriceOptions { + package: string; + arguments: FivePlusCharPriceArguments | [_: RawTransactionArgument]; +} +export function fivePlusCharPrice(options: FivePlusCharPriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'five_plus_char_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AssertValidUserRegisterableDomainArguments { + _: RawTransactionArgument; +} +export interface AssertValidUserRegisterableDomainOptions { + package: string; + arguments: AssertValidUserRegisterableDomainArguments | [_: RawTransactionArgument]; +} +export function assertValidUserRegisterableDomain( + options: AssertValidUserRegisterableDomainOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'config', + function: 'assert_valid_user_registerable_domain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts b/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts new file mode 100644 index 000000000..5fa477ca5 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts @@ -0,0 +1,167 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Module to wrap all constants used across the project. A singleton and not meant + * to be modified (only extended). + * + * This module is free from any non-framework dependencies and serves as a single + * place of storing constants and proving convenient APIs for reading. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +export interface SuiTldOptions { + package: string; + arguments?: []; +} +/** Top level domain for SUI as a String. */ +export function suiTld(options: SuiTldOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'sui_tld', + }); +} +export interface DefaultImageOptions { + package: string; + arguments?: []; +} +/** Default value for the image_url. */ +export function defaultImage(options: DefaultImageOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'default_image', + }); +} +export interface MistPerSuiOptions { + package: string; + arguments?: []; +} +/** The amount of MIST in 1 SUI. */ +export function mistPerSui(options: MistPerSuiOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'mist_per_sui', + }); +} +export interface MinDomainLengthOptions { + package: string; + arguments?: []; +} +/** The minimum length of a domain name. */ +export function minDomainLength(options: MinDomainLengthOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'min_domain_length', + }); +} +export interface MaxDomainLengthOptions { + package: string; + arguments?: []; +} +/** The maximum length of a domain name. */ +export function maxDomainLength(options: MaxDomainLengthOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'max_domain_length', + }); +} +export interface MaxBpsOptions { + package: string; + arguments?: []; +} +/** Maximum value for basis points. */ +export function maxBps(options: MaxBpsOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'max_bps', + }); +} +export interface YearMsOptions { + package: string; + arguments?: []; +} +/** The amount of milliseconds in a year. */ +export function yearMs(options: YearMsOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'year_ms', + }); +} +export interface GracePeriodMsOptions { + package: string; + arguments?: []; +} +/** Grace period in milliseconds after which the domain expires. */ +export function gracePeriodMs(options: GracePeriodMsOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'grace_period_ms', + }); +} +export interface SubdomainAllowCreationKeyOptions { + package: string; + arguments?: []; +} +/** Subdomain constants The NameRecord key that a subdomain can create child names. */ +export function subdomainAllowCreationKey(options: SubdomainAllowCreationKeyOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'subdomain_allow_creation_key', + }); +} +export interface SubdomainAllowExtensionKeyOptions { + package: string; + arguments?: []; +} +/** The NameRecord key that a subdomain can self-renew. */ +export function subdomainAllowExtensionKey(options: SubdomainAllowExtensionKeyOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'subdomain_allow_extension_key', + }); +} +export interface LeafExpirationTimestampOptions { + package: string; + arguments?: []; +} +/** A getter for a leaf name record's expiration timestamp. */ +export function leafExpirationTimestamp(options: LeafExpirationTimestampOptions = {}) { + const packageAddress = options.package; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'constants', + function: 'leaf_expiration_timestamp', + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts b/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts new file mode 100644 index 000000000..02b17da21 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts @@ -0,0 +1,269 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveTuple, + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'suins::controller'; +export const ControllerV2 = new MoveTuple({ + name: `${$moduleName}::ControllerV2`, + fields: [bcs.bool()], +}); +export const Controller = new MoveStruct({ + name: `${$moduleName}::Controller`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface SetTargetAddressArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; + newTarget: RawTransactionArgument; +} +export interface SetTargetAddressOptions { + package: string; + arguments: + | SetTargetAddressArguments + | [ + suins: RawTransactionArgument, + nft: RawTransactionArgument, + newTarget: RawTransactionArgument, + ]; +} +/** Set the target address of a domain. */ +export function setTargetAddress(options: SetTargetAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + null, + '0x1::option::Option
', + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['suins', 'nft', 'newTarget']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'set_target_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetReverseLookupArguments { + suins: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface SetReverseLookupOptions { + package: string; + arguments: + | SetReverseLookupArguments + | [suins: RawTransactionArgument, domainName: RawTransactionArgument]; +} +/** Set the reverse lookup address for the domain */ +export function setReverseLookup(options: SetReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['suins', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'set_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UnsetReverseLookupArguments { + suins: RawTransactionArgument; +} +export interface UnsetReverseLookupOptions { + package: string; + arguments: UnsetReverseLookupArguments | [suins: RawTransactionArgument]; +} +/** User-facing function - unset the reverse lookup address for the domain. */ +export function unsetReverseLookup(options: UnsetReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['suins']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'unset_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetObjectReverseLookupArguments { + suins: RawTransactionArgument; + obj: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface SetObjectReverseLookupOptions { + package: string; + arguments: + | SetObjectReverseLookupArguments + | [ + suins: RawTransactionArgument, + obj: RawTransactionArgument, + domainName: RawTransactionArgument, + ]; +} +/** + * Allows setting the reverse lookup address for an object. Expects a mutable + * reference of the object. + */ +export function setObjectReverseLookup(options: SetObjectReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID', '0x1::string::String'] satisfies ( + | string + | null + )[]; + const parameterNames = ['suins', 'obj', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'set_object_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UnsetObjectReverseLookupArguments { + suins: RawTransactionArgument; + obj: RawTransactionArgument; +} +export interface UnsetObjectReverseLookupOptions { + package: string; + arguments: + | UnsetObjectReverseLookupArguments + | [suins: RawTransactionArgument, obj: RawTransactionArgument]; +} +/** + * Allows unsetting the reverse lookup address for an object. Expects a mutable + * reference of the object. + */ +export function unsetObjectReverseLookup(options: UnsetObjectReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; + const parameterNames = ['suins', 'obj']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'unset_object_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetUserDataArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; + key: RawTransactionArgument; + value: RawTransactionArgument; +} +export interface SetUserDataOptions { + package: string; + arguments: + | SetUserDataArguments + | [ + suins: RawTransactionArgument, + nft: RawTransactionArgument, + key: RawTransactionArgument, + value: RawTransactionArgument, + ]; +} +/** User-facing function - add a new key-value pair to the name record's data. */ +export function setUserData(options: SetUserDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + null, + '0x1::string::String', + '0x1::string::String', + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['suins', 'nft', 'key', 'value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'set_user_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UnsetUserDataArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; + key: RawTransactionArgument; +} +export interface UnsetUserDataOptions { + package: string; + arguments: + | UnsetUserDataArguments + | [ + suins: RawTransactionArgument, + nft: RawTransactionArgument, + key: RawTransactionArgument, + ]; +} +/** User-facing function - remove a key from the name record's data. */ +export function unsetUserData(options: UnsetUserDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['suins', 'nft', 'key']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'unset_user_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BurnExpiredArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface BurnExpiredOptions { + package: string; + arguments: + | BurnExpiredArguments + | [suins: RawTransactionArgument, nft: RawTransactionArgument]; +} +export function burnExpired(options: BurnExpiredOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['suins', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'burn_expired', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BurnExpiredSubnameArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface BurnExpiredSubnameOptions { + package: string; + arguments: + | BurnExpiredSubnameArguments + | [suins: RawTransactionArgument, nft: RawTransactionArgument]; +} +export function burnExpiredSubname(options: BurnExpiredSubnameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['suins', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'controller', + function: 'burn_expired_subname', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts new file mode 100644 index 000000000..9e4eaa36d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts @@ -0,0 +1,212 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Core configuration of the SuiNS application. + * + * This configuration is used to validate domains for registration and renewal. It + * can only be stored as a valid config in the `SuiNS` object by an admin, hence + * why all the functions are public. Having just the config object cannot pose a + * security risk as it cannot be used. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_set from '../sui/vec_set.js'; +import * as vec_map from '../sui/vec_map.js'; +const $moduleName = 'suins::core_config'; +export const CoreConfig = new MoveStruct({ + name: `${$moduleName}::CoreConfig`, + fields: { + /** Public key of the API server. Currently only used for direct setup. */ + public_key: bcs.vector(bcs.u8()), + /** + * Minimum length of the label part of the domain. This is different from the base + * `domain` checks. This is our minimum acceptable length (for sales). + */ + min_label_length: bcs.u8(), + /** Maximum length of the label part of the domain. */ + max_label_length: bcs.u8(), + /** List of valid TLDs for registration / renewals. */ + valid_tlds: vec_set.VecSet(bcs.string()), + /** The `PaymentIntent` version that can be used for handling sales. */ + payments_version: bcs.u8(), + /** Maximum number of years available for a domain. */ + max_years: bcs.u8(), + extra: vec_map.VecMap(bcs.string(), bcs.string()), + }, +}); +export interface NewArguments { + publicKey: RawTransactionArgument; + minLabelLength: RawTransactionArgument; + maxLabelLength: RawTransactionArgument; + paymentsVersion: RawTransactionArgument; + maxYears: RawTransactionArgument; + validTlds: RawTransactionArgument; + extra: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: + | NewArguments + | [ + publicKey: RawTransactionArgument, + minLabelLength: RawTransactionArgument, + maxLabelLength: RawTransactionArgument, + paymentsVersion: RawTransactionArgument, + maxYears: RawTransactionArgument, + validTlds: RawTransactionArgument, + extra: RawTransactionArgument, + ]; +} +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = [ + 'vector', + 'u8', + 'u8', + 'u8', + 'u8', + 'vector<0x1::string::String>', + null, + ] satisfies (string | null)[]; + const parameterNames = [ + 'publicKey', + 'minLabelLength', + 'maxLabelLength', + 'paymentsVersion', + 'maxYears', + 'validTlds', + 'extra', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PublicKeyArguments { + config: RawTransactionArgument; +} +export interface PublicKeyOptions { + package: string; + arguments: PublicKeyArguments | [config: RawTransactionArgument]; +} +export function publicKey(options: PublicKeyOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'public_key', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinLabelLengthArguments { + config: RawTransactionArgument; +} +export interface MinLabelLengthOptions { + package: string; + arguments: MinLabelLengthArguments | [config: RawTransactionArgument]; +} +export function minLabelLength(options: MinLabelLengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'min_label_length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxLabelLengthArguments { + config: RawTransactionArgument; +} +export interface MaxLabelLengthOptions { + package: string; + arguments: MaxLabelLengthArguments | [config: RawTransactionArgument]; +} +export function maxLabelLength(options: MaxLabelLengthOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'max_label_length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsValidTldArguments { + config: RawTransactionArgument; + tld: RawTransactionArgument; +} +export interface IsValidTldOptions { + package: string; + arguments: + | IsValidTldArguments + | [config: RawTransactionArgument, tld: RawTransactionArgument]; +} +export function isValidTld(options: IsValidTldOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['config', 'tld']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'is_valid_tld', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PaymentsVersionArguments { + config: RawTransactionArgument; +} +export interface PaymentsVersionOptions { + package: string; + arguments: PaymentsVersionArguments | [config: RawTransactionArgument]; +} +export function paymentsVersion(options: PaymentsVersionOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'payments_version', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxYearsArguments { + config: RawTransactionArgument; +} +export interface MaxYearsOptions { + package: string; + arguments: MaxYearsArguments | [config: RawTransactionArgument]; +} +export function maxYears(options: MaxYearsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'core_config', + function: 'max_years', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts b/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts new file mode 100644 index 000000000..f2c0c3076 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts @@ -0,0 +1,234 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the `Domain` type and helper functions. + * + * Domains are structured similar to their web2 counterpart and the rules + * determining what a valid domain is can be found here: + * https://en.wikipedia.org/wiki/Domain_name#Domain_name_syntax + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = 'suins::domain'; +export const Domain = new MoveStruct({ + name: `${$moduleName}::Domain`, + fields: { + /** + * Vector of labels that make up a domain. + * + * Labels are stored in reverse order such that the TLD is always in position `0`. + * e.g. domain "pay.name.sui" will be stored in the vector as ["sui", "name", + * "pay"]. + */ + labels: bcs.vector(bcs.string()), + }, +}); +export interface NewArguments { + domain: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [domain: RawTransactionArgument]; +} +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + self: RawTransactionArgument; +} +export interface ToStringOptions { + package: string; + arguments: ToStringArguments | [self: RawTransactionArgument]; +} +/** Converts a domain into a fully-qualified string representation. */ +export function toString(options: ToStringOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LabelArguments { + self: RawTransactionArgument; + level: RawTransactionArgument; +} +export interface LabelOptions { + package: string; + arguments: + | LabelArguments + | [self: RawTransactionArgument, level: RawTransactionArgument]; +} +/** + * Returns the `label` in a domain specified by `level`. + * + * Given the domain "pay.name.sui" the individual labels have the following levels: + * + * - "pay" - `2` + * - "name" - `1` + * - "sui" - `0` + * + * This means that the TLD will always be at level `0`. + */ +export function label(options: LabelOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'level']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'label', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TldArguments { + self: RawTransactionArgument; +} +export interface TldOptions { + package: string; + arguments: TldArguments | [self: RawTransactionArgument]; +} +/** + * Returns the TLD (Top-Level Domain) of a `Domain`. + * + * "name.sui" -> "sui" + */ +export function tld(options: TldOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'tld', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SldArguments { + self: RawTransactionArgument; +} +export interface SldOptions { + package: string; + arguments: SldArguments | [self: RawTransactionArgument]; +} +/** + * Returns the SLD (Second-Level Domain) of a `Domain`. + * + * "name.sui" -> "sui" + */ +export function sld(options: SldOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'sld', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NumberOfLevelsArguments { + self: RawTransactionArgument; +} +export interface NumberOfLevelsOptions { + package: string; + arguments: NumberOfLevelsArguments | [self: RawTransactionArgument]; +} +export function numberOfLevels(options: NumberOfLevelsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'number_of_levels', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsSubdomainArguments { + domain: RawTransactionArgument; +} +export interface IsSubdomainOptions { + package: string; + arguments: IsSubdomainArguments | [domain: RawTransactionArgument]; +} +export function isSubdomain(options: IsSubdomainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'is_subdomain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ParentArguments { + domain: RawTransactionArgument; +} +export interface ParentOptions { + package: string; + arguments: ParentArguments | [domain: RawTransactionArgument]; +} +/** Derive the parent of a subdomain. e.g. `subdomain.example.sui` -> `example.sui` */ +export function parent(options: ParentOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'parent', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsParentOfArguments { + parent: RawTransactionArgument; + child: RawTransactionArgument; +} +export interface IsParentOfOptions { + package: string; + arguments: + | IsParentOfArguments + | [parent: RawTransactionArgument, child: RawTransactionArgument]; +} +/** Checks if `parent` domain is a valid parent for `child`. */ +export function isParentOf(options: IsParentOfOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['parent', 'child']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'domain', + function: 'is_parent_of', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts b/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts new file mode 100644 index 000000000..6b5220a5d --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts @@ -0,0 +1,319 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * The `NameRecord` is a struct that represents a single record in the registry. + * Can be replaced by any other data structure due to the way `NameRecord`s are + * stored and managed. SuiNS has no direct and permanent dependency on this module. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from '../sui/vec_map.js'; +const $moduleName = 'suins::name_record'; +export const NameRecord = new MoveStruct({ + name: `${$moduleName}::NameRecord`, + fields: { + /** + * The ID of the `SuinsRegistration` assigned to this record. + * + * The owner of the corresponding `SuinsRegistration` has the rights to be able to + * change and adjust the `target_address` of this domain. + * + * It is possible that the ID changes if the record expires and is purchased by + * someone else. + */ + nft_id: bcs.Address, + /** Timestamp in milliseconds when the record expires. */ + expiration_timestamp_ms: bcs.u64(), + /** The target address that this domain points to */ + target_address: bcs.option(bcs.Address), + /** Additional data which may be stored in a record */ + data: vec_map.VecMap(bcs.string(), bcs.string()), + }, +}); +export interface NewArguments { + nftId: RawTransactionArgument; + expirationTimestampMs: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: + | NewArguments + | [ + nftId: RawTransactionArgument, + expirationTimestampMs: RawTransactionArgument, + ]; +} +/** Create a new NameRecord. */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', 'u64'] satisfies (string | null)[]; + const parameterNames = ['nftId', 'expirationTimestampMs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewLeafArguments { + parentId: RawTransactionArgument; + targetAddress: RawTransactionArgument; +} +export interface NewLeafOptions { + package: string; + arguments: + | NewLeafArguments + | [ + parentId: RawTransactionArgument, + targetAddress: RawTransactionArgument, + ]; +} +/** Create a `leaf` NameRecord. */ +export function newLeaf(options: NewLeafOptions) { + const packageAddress = options.package; + const argumentsTypes = ['0x2::object::ID', '0x1::option::Option
'] satisfies ( + | string + | null + )[]; + const parameterNames = ['parentId', 'targetAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'new_leaf', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetDataArguments { + self: RawTransactionArgument; + data: RawTransactionArgument; +} +export interface SetDataOptions { + package: string; + arguments: + | SetDataArguments + | [self: RawTransactionArgument, data: RawTransactionArgument]; +} +/** + * Set data as a vec_map directly overriding the data set in the registration self. + * This simplifies the editing flow and gives the user and clients a fine-grained + * control over custom data. + * + * Here's a meta example of how a PTB would look like: + * + * ``` + * let record = moveCall('data', [domain_name]); + * moveCall('vec_map::insert', [record.data, key, value]); + * moveCall('vec_map::remove', [record.data, other_key]); + * moveCall('set_data', [domain_name, record.data]); + * ``` + */ +export function setData(options: SetDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'set_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetTargetAddressArguments { + self: RawTransactionArgument; + newAddress: RawTransactionArgument; +} +export interface SetTargetAddressOptions { + package: string; + arguments: + | SetTargetAddressArguments + | [self: RawTransactionArgument, newAddress: RawTransactionArgument]; +} +/** Set the `target_address` field of the `NameRecord`. */ +export function setTargetAddress(options: SetTargetAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::option::Option
'] satisfies (string | null)[]; + const parameterNames = ['self', 'newAddress']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'set_target_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetExpirationTimestampMsArguments { + self: RawTransactionArgument; + expirationTimestampMs: RawTransactionArgument; +} +export interface SetExpirationTimestampMsOptions { + package: string; + arguments: + | SetExpirationTimestampMsArguments + | [ + self: RawTransactionArgument, + expirationTimestampMs: RawTransactionArgument, + ]; +} +export function setExpirationTimestampMs(options: SetExpirationTimestampMsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'expirationTimestampMs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'set_expiration_timestamp_ms', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasExpiredArguments { + self: RawTransactionArgument; +} +export interface HasExpiredOptions { + package: string; + arguments: HasExpiredArguments | [self: RawTransactionArgument]; +} +/** Check if the record has expired. */ +export function hasExpired(options: HasExpiredOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'has_expired', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasExpiredPastGracePeriodArguments { + self: RawTransactionArgument; +} +export interface HasExpiredPastGracePeriodOptions { + package: string; + arguments: HasExpiredPastGracePeriodArguments | [self: RawTransactionArgument]; +} +/** Check if the record has expired, taking into account the grace period. */ +export function hasExpiredPastGracePeriod(options: HasExpiredPastGracePeriodOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'has_expired_past_grace_period', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsLeafRecordArguments { + self: RawTransactionArgument; +} +export interface IsLeafRecordOptions { + package: string; + arguments: IsLeafRecordArguments | [self: RawTransactionArgument]; +} +/** Checks whether a name_record is a `leaf` record. */ +export function isLeafRecord(options: IsLeafRecordOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'is_leaf_record', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DataArguments { + self: RawTransactionArgument; +} +export interface DataOptions { + package: string; + arguments: DataArguments | [self: RawTransactionArgument]; +} +/** Read the `data` field from the `NameRecord`. */ +export function data(options: DataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TargetAddressArguments { + self: RawTransactionArgument; +} +export interface TargetAddressOptions { + package: string; + arguments: TargetAddressArguments | [self: RawTransactionArgument]; +} +/** Read the `target_address` field from the `NameRecord`. */ +export function targetAddress(options: TargetAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'target_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NftIdArguments { + self: RawTransactionArgument; +} +export interface NftIdOptions { + package: string; + arguments: NftIdArguments | [self: RawTransactionArgument]; +} +/** Read the `nft_id` field from the `NameRecord`. */ +export function nftId(options: NftIdOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'nft_id', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExpirationTimestampMsArguments { + self: RawTransactionArgument; +} +export interface ExpirationTimestampMsOptions { + package: string; + arguments: ExpirationTimestampMsArguments | [self: RawTransactionArgument]; +} +/** Read the `expiration_timestamp_ms` field from the `NameRecord`. */ +export function expirationTimestampMs(options: ExpirationTimestampMsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'name_record', + function: 'expiration_timestamp_ms', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts b/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts new file mode 100644 index 000000000..13dfeed06 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts @@ -0,0 +1,444 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + MoveEnum, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as domain_1 from './domain.js'; +import * as vec_map from '../sui/vec_map.js'; +import * as type_name from '../suins_auction/type_name.js'; +const $moduleName = 'suins::payment'; +export const RequestData = new MoveStruct({ + name: `${$moduleName}::RequestData`, + fields: { + /** The version of the payment module. */ + version: bcs.u8(), + /** The domain for which the payment is being made. */ + domain: domain_1.Domain, + /** The years for which the payment is being made. Defaults to 1 for registration. */ + years: bcs.u8(), + /** The amount the user has to pay in base units. */ + base_amount: bcs.u64(), + /** + * The discounts (each app can add a key for its discount) to avoid multiple + * additions of the same discount. + */ + discounts_applied: vec_map.VecMap(bcs.string(), bcs.u64()), + /** + * a metadata field for future-proofness. No use-cases are enabled in the current + * release. + */ + metadata: vec_map.VecMap(bcs.string(), bcs.string()), + }, +}); +export const TransactionEvent = new MoveStruct({ + name: `${$moduleName}::TransactionEvent`, + fields: { + app: type_name.TypeName, + domain: domain_1.Domain, + years: bcs.u8(), + request_data_version: bcs.u8(), + base_amount: bcs.u64(), + discounts_applied: vec_map.VecMap(bcs.string(), bcs.u64()), + metadata: vec_map.VecMap(bcs.string(), bcs.string()), + is_renewal: bcs.bool(), + currency: type_name.TypeName, + currency_amount: bcs.u64(), + }, +}); +/** + * The payment intent for a given domain + * + * - Registration: The user is registering a new domain. + * - Renewal: The user is renewing an existing domain. + */ +export const PaymentIntent = new MoveEnum({ + name: `${$moduleName}::PaymentIntent`, + fields: { + Registration: RequestData, + Renewal: RequestData, + }, +}); +/** + * A receipt that is generated after a successful payment. Can be used to: + * + * - Prove that the payment was successful. + * - Register a new name, or renew an existing one. + */ +export const Receipt = new MoveEnum({ + name: `${$moduleName}::Receipt`, + fields: { + Registration: new MoveStruct({ + name: `Receipt.Registration`, + fields: { + domain: domain_1.Domain, + years: bcs.u8(), + version: bcs.u8(), + }, + }), + Renewal: new MoveStruct({ + name: `Receipt.Renewal`, + fields: { + domain: domain_1.Domain, + years: bcs.u8(), + version: bcs.u8(), + }, + }), + }, +}); +export interface ApplyPercentageDiscountArguments> { + intent: RawTransactionArgument; + suins: RawTransactionArgument; + _: RawTransactionArgument; + discountKey: RawTransactionArgument; + discount: RawTransactionArgument; + allowMultipleDiscounts: RawTransactionArgument; +} +export interface ApplyPercentageDiscountOptions> { + package: string; + arguments: + | ApplyPercentageDiscountArguments + | [ + intent: RawTransactionArgument, + suins: RawTransactionArgument, + _: RawTransactionArgument, + discountKey: RawTransactionArgument, + discount: RawTransactionArgument, + allowMultipleDiscounts: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Allow an authorized app to apply a percentage discount to the payment intent. + * E.g. an NS payment can apply a 10% discount on top of a user's 20% discount if + * allow_multiple_discounts is true + */ +export function applyPercentageDiscount>( + options: ApplyPercentageDiscountOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [ + null, + null, + `${options.typeArguments[0]}`, + '0x1::string::String', + 'u8', + 'bool', + ] satisfies (string | null)[]; + const parameterNames = [ + 'intent', + 'suins', + '_', + 'discountKey', + 'discount', + 'allowMultipleDiscounts', + ]; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'apply_percentage_discount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FinalizePaymentArguments> { + intent: RawTransactionArgument; + suins: RawTransactionArgument; + app: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface FinalizePaymentOptions> { + package: string; + arguments: + | FinalizePaymentArguments + | [ + intent: RawTransactionArgument, + suins: RawTransactionArgument, + app: RawTransactionArgument, + coin: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** + * Allow an authorized app to finalize a payment. Returns a receipt that can be + * used to register or renew a domain. + * + * SAFETY: Only authorized packages can call this. We do not check the amount of + * funds in this helper. This is the responsibility of the `payments` app. + */ +export function finalizePayment>(options: FinalizePaymentOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, `${options.typeArguments[0]}`, null] satisfies ( + | string + | null + )[]; + const parameterNames = ['intent', 'suins', 'app', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'finalize_payment', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface InitRegistrationArguments { + suins: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface InitRegistrationOptions { + package: string; + arguments: + | InitRegistrationArguments + | [suins: RawTransactionArgument, domain: RawTransactionArgument]; +} +/** + * Creates a `PaymentIntent` for registering a new domain. This is a hot-potato and + * can only be consumed in a single transaction. + */ +export function initRegistration(options: InitRegistrationOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['suins', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'init_registration', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface InitRenewalArguments { + suins: RawTransactionArgument; + nft: RawTransactionArgument; + years: RawTransactionArgument; +} +export interface InitRenewalOptions { + package: string; + arguments: + | InitRenewalArguments + | [ + suins: RawTransactionArgument, + nft: RawTransactionArgument, + years: RawTransactionArgument, + ]; +} +/** + * Creates a `PaymentIntent` for renewing an existing domain. This is a hot-potato + * and can only be consumed in a single transaction. + */ +export function initRenewal(options: InitRenewalOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'u8'] satisfies (string | null)[]; + const parameterNames = ['suins', 'nft', 'years']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'init_renewal', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RegisterArguments { + receipt: RawTransactionArgument; + suins: RawTransactionArgument; +} +export interface RegisterOptions { + package: string; + arguments: + | RegisterArguments + | [receipt: RawTransactionArgument, suins: RawTransactionArgument]; +} +/** + * Register a domain with the given receipt. This is a hot-potato and can only be + * consumed in a single transaction. + */ +export function register(options: RegisterOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['receipt', 'suins']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'register', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RenewArguments { + receipt: RawTransactionArgument; + suins: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface RenewOptions { + package: string; + arguments: + | RenewArguments + | [ + receipt: RawTransactionArgument, + suins: RawTransactionArgument, + nft: RawTransactionArgument, + ]; +} +/** + * Renew a domain with the given receipt. This is a hot-potato and can only be + * consumed in a single transaction. + */ +export function renew(options: RenewOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['receipt', 'suins', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'renew', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RequestDataArguments { + intent: RawTransactionArgument; +} +export interface RequestDataOptions { + package: string; + arguments: RequestDataArguments | [intent: RawTransactionArgument]; +} +/** Getters */ +export function requestData(options: RequestDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['intent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'request_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface YearsArguments { + self: RawTransactionArgument; +} +export interface YearsOptions { + package: string; + arguments: YearsArguments | [self: RawTransactionArgument]; +} +export function years(options: YearsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'years', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BaseAmountArguments { + self: RawTransactionArgument; +} +export interface BaseAmountOptions { + package: string; + arguments: BaseAmountArguments | [self: RawTransactionArgument]; +} +export function baseAmount(options: BaseAmountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'base_amount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DomainArguments { + self: RawTransactionArgument; +} +export interface DomainOptions { + package: string; + arguments: DomainArguments | [self: RawTransactionArgument]; +} +export function domain(options: DomainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'domain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiscountAppliedArguments { + self: RawTransactionArgument; +} +export interface DiscountAppliedOptions { + package: string; + arguments: DiscountAppliedArguments | [self: RawTransactionArgument]; +} +/** Returns true if at least one discount has been applied to the payment intent. */ +export function discountApplied(options: DiscountAppliedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'discount_applied', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiscountsAppliedArguments { + self: RawTransactionArgument; +} +export interface DiscountsAppliedOptions { + package: string; + arguments: DiscountsAppliedArguments | [self: RawTransactionArgument]; +} +/** A list of discounts that have been applied to the payment intent. */ +export function discountsApplied(options: DiscountsAppliedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'discounts_applied', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CalculateTotalAfterDiscountArguments { + data: RawTransactionArgument; + discount: RawTransactionArgument; +} +export interface CalculateTotalAfterDiscountOptions { + package: string; + arguments: + | CalculateTotalAfterDiscountArguments + | [data: RawTransactionArgument, discount: RawTransactionArgument]; +} +/** Public helper to calculate price after a percentage discount has been applied. */ +export function calculateTotalAfterDiscount(options: CalculateTotalAfterDiscountOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u8'] satisfies (string | null)[]; + const parameterNames = ['data', 'discount']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'payment', + function: 'calculate_total_after_discount', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts new file mode 100644 index 000000000..3c8912878 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts @@ -0,0 +1,190 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveTuple, + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as vec_map from '../sui/vec_map.js'; +const $moduleName = 'suins::pricing_config'; +export const Range = new MoveTuple({ + name: `${$moduleName}::Range`, + fields: [bcs.u64(), bcs.u64()], +}); +export const PricingConfig = new MoveStruct({ + name: `${$moduleName}::PricingConfig`, + fields: { + pricing: vec_map.VecMap(Range, bcs.u64()), + }, +}); +export const RenewalConfig = new MoveStruct({ + name: `${$moduleName}::RenewalConfig`, + fields: { + config: PricingConfig, + }, +}); +export interface CalculateBasePriceArguments { + config: RawTransactionArgument; + length: RawTransactionArgument; +} +export interface CalculateBasePriceOptions { + package: string; + arguments: + | CalculateBasePriceArguments + | [config: RawTransactionArgument, length: RawTransactionArgument]; +} +/** + * Calculates the base price for a given length. + * + * - Base price type is abstracted away. We can switch to a different base. Our + * core base will become USDC. + * - The price is calculated based on the length of the domain name and the + * available ranges. + */ +export function calculateBasePrice(options: CalculateBasePriceOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['config', 'length']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'calculate_base_price', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewArguments { + ranges: RawTransactionArgument; + prices: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: + | NewArguments + | [ranges: RawTransactionArgument, prices: RawTransactionArgument]; +} +/** + * Creates a new PricingConfig with the given ranges and prices. + * + * - The ranges should be sorted in `ascending order` and should not overlap. + * - The length of the ranges and prices should be the same. + * + * All the ranges are inclusive (e.g. [3,5]: includes 3, 4, and 5). + */ +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; + const parameterNames = ['ranges', 'prices']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsBetweenInclusiveArguments { + range: RawTransactionArgument; + length: RawTransactionArgument; +} +export interface IsBetweenInclusiveOptions { + package: string; + arguments: + | IsBetweenInclusiveArguments + | [range: RawTransactionArgument, length: RawTransactionArgument]; +} +/** Checks if the value is between the range (inclusive). */ +export function isBetweenInclusive(options: IsBetweenInclusiveOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['range', 'length']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'is_between_inclusive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PricingArguments { + config: RawTransactionArgument; +} +export interface PricingOptions { + package: string; + arguments: PricingArguments | [config: RawTransactionArgument]; +} +/** Returns the pricing config for usage in external apps. */ +export function pricing(options: PricingOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'pricing', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewRenewalConfigArguments { + config: RawTransactionArgument; +} +export interface NewRenewalConfigOptions { + package: string; + arguments: NewRenewalConfigArguments | [config: RawTransactionArgument]; +} +/** Constructor for Renewal that initializes it with a PricingConfig. */ +export function newRenewalConfig(options: NewRenewalConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'new_renewal_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NewRangeArguments { + range: RawTransactionArgument; +} +export interface NewRangeOptions { + package: string; + arguments: NewRangeArguments | [range: RawTransactionArgument]; +} +export function newRange(options: NewRangeOptions) { + const packageAddress = options.package; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['range']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'new_range', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ConfigArguments { + renewal: RawTransactionArgument; +} +export interface ConfigOptions { + package: string; + arguments: ConfigArguments | [renewal: RawTransactionArgument]; +} +export function config(options: ConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['renewal']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'pricing_config', + function: 'config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts b/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts new file mode 100644 index 000000000..0f609102b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts @@ -0,0 +1,518 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as table from '../sui/table.js'; +const $moduleName = 'suins::registry'; +export const Registry = new MoveStruct({ + name: `${$moduleName}::Registry`, + fields: { + /** + * The `registry` table maps `Domain` to `NameRecord`. Added / replaced in the + * `add_record` function. + */ + registry: table.Table, + /** + * The `reverse_registry` table maps `address` to `domain_name`. Updated in the + * `set_reverse_lookup` function. + */ + reverse_registry: table.Table, + }, +}); +export interface NewArguments { + _: RawTransactionArgument; +} +export interface NewOptions { + package: string; + arguments: NewArguments | [_: RawTransactionArgument]; +} +export function _new(options: NewOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'new', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddRecordIgnoringGracePeriodArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; + noYears: RawTransactionArgument; +} +export interface AddRecordIgnoringGracePeriodOptions { + package: string; + arguments: + | AddRecordIgnoringGracePeriodArguments + | [ + self: RawTransactionArgument, + domain: RawTransactionArgument, + noYears: RawTransactionArgument, + ]; +} +/** + * Attempts to add a new record to the registry without looking at the grace + * period. Currently used for subdomains where there's no grace period to respect. + * Returns a `SuinsRegistration` upon success. + */ +export function addRecordIgnoringGracePeriod(options: AddRecordIgnoringGracePeriodOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'u8', '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self', 'domain', 'noYears']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'add_record_ignoring_grace_period', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddRecordArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; + noYears: RawTransactionArgument; +} +export interface AddRecordOptions { + package: string; + arguments: + | AddRecordArguments + | [ + self: RawTransactionArgument, + domain: RawTransactionArgument, + noYears: RawTransactionArgument, + ]; +} +/** + * Attempts to add a new record to the registry and returns a `SuinsRegistration` + * upon success. Only use with second-level names. Enforces a `grace_period` by + * default. Not suitable for subdomains (unless a grace period is needed). + */ +export function addRecord(options: AddRecordOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, 'u8', '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self', 'domain', 'noYears']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'add_record', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BurnRegistrationObjectArguments { + self: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface BurnRegistrationObjectOptions { + package: string; + arguments: + | BurnRegistrationObjectArguments + | [self: RawTransactionArgument, nft: RawTransactionArgument]; +} +/** + * Attempts to burn an NFT and get storage rebates. Only works if the NFT has + * expired. + */ +export function burnRegistrationObject(options: BurnRegistrationObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'burn_registration_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface WrapSubdomainArguments { + _: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface WrapSubdomainOptions { + package: string; + arguments: + | WrapSubdomainArguments + | [_: RawTransactionArgument, nft: RawTransactionArgument]; +} +/** Allow creation of subdomain wrappers only to authorized modules. */ +export function wrapSubdomain(options: WrapSubdomainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['_', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'wrap_subdomain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BurnSubdomainObjectArguments { + self: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface BurnSubdomainObjectOptions { + package: string; + arguments: + | BurnSubdomainObjectArguments + | [self: RawTransactionArgument, nft: RawTransactionArgument]; +} +/** + * Attempts to burn a subdomain registration object, and also invalidates any + * records in the registry / reverse registry. + */ +export function burnSubdomainObject(options: BurnSubdomainObjectOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'burn_subdomain_object', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddLeafRecordArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; + target: RawTransactionArgument; +} +export interface AddLeafRecordOptions { + package: string; + arguments: + | AddLeafRecordArguments + | [ + self: RawTransactionArgument, + domain: RawTransactionArgument, + target: RawTransactionArgument, + ]; +} +/** + * Adds a `leaf` record to the registry. A `leaf` record is a record that is a + * subdomain and doesn't have an equivalent `SuinsRegistration` object. + * + * Instead, the parent's `SuinsRegistration` object is used to manage + * target_address & remove it / determine expiration. + * + * 1. Leaf records can't have children. They only work as a resolving mechanism. + * 2. Leaf records must always have a `target` address (can't point to `none`). + * 3. Leaf records do not expire. Their expiration date is actually what defines + * their type. + * + * Leaf record's expiration is defined by the parent's expiration. Since the parent + * can only be a `node`, we need to check that the parent's NFT_ID is valid & + * hasn't expired. + */ +export function addLeafRecord(options: AddLeafRecordOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock', 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'domain', 'target']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'add_leaf_record', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface RemoveLeafRecordArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface RemoveLeafRecordOptions { + package: string; + arguments: + | RemoveLeafRecordArguments + | [self: RawTransactionArgument, domain: RawTransactionArgument]; +} +/** + * Can be used to remove a leaf record. Leaf records do not have any symmetrical + * `SuinsRegistration` object. Authorization of who calls this is delegated to the + * authorized module that calls this. + */ +export function removeLeafRecord(options: RemoveLeafRecordOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'remove_leaf_record', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetTargetAddressArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; + newTarget: RawTransactionArgument; +} +export interface SetTargetAddressOptions { + package: string; + arguments: + | SetTargetAddressArguments + | [ + self: RawTransactionArgument, + domain: RawTransactionArgument, + newTarget: RawTransactionArgument, + ]; +} +export function setTargetAddress(options: SetTargetAddressOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x1::option::Option
'] satisfies (string | null)[]; + const parameterNames = ['self', 'domain', 'newTarget']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'set_target_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UnsetReverseLookupArguments { + self: RawTransactionArgument; + address: RawTransactionArgument; +} +export interface UnsetReverseLookupOptions { + package: string; + arguments: + | UnsetReverseLookupArguments + | [self: RawTransactionArgument, address: RawTransactionArgument]; +} +export function unsetReverseLookup(options: UnsetReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'address']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'unset_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetReverseLookupArguments { + self: RawTransactionArgument; + address: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface SetReverseLookupOptions { + package: string; + arguments: + | SetReverseLookupArguments + | [ + self: RawTransactionArgument, + address: RawTransactionArgument, + domain: RawTransactionArgument, + ]; +} +/** Reverse lookup can only be set for the record that has the target address. */ +export function setReverseLookup(options: SetReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address', null] satisfies (string | null)[]; + const parameterNames = ['self', 'address', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'set_reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetExpirationTimestampMsArguments { + self: RawTransactionArgument; + nft: RawTransactionArgument; + domain: RawTransactionArgument; + expirationTimestampMs: RawTransactionArgument; +} +export interface SetExpirationTimestampMsOptions { + package: string; + arguments: + | SetExpirationTimestampMsArguments + | [ + self: RawTransactionArgument, + nft: RawTransactionArgument, + domain: RawTransactionArgument, + expirationTimestampMs: RawTransactionArgument, + ]; +} +/** + * Update the `expiration_timestamp_ms` of the given `SuinsRegistration` and + * `NameRecord`. Requires the `SuinsRegistration` to make sure that both timestamps + * are in sync. + */ +export function setExpirationTimestampMs(options: SetExpirationTimestampMsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; + const parameterNames = ['self', 'nft', 'domain', 'expirationTimestampMs']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'set_expiration_timestamp_ms', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SetDataArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; + data: RawTransactionArgument; +} +export interface SetDataOptions { + package: string; + arguments: + | SetDataArguments + | [ + self: RawTransactionArgument, + domain: RawTransactionArgument, + data: RawTransactionArgument, + ]; +} +/** + * Update the `data` of the given `NameRecord` using a `SuinsRegistration`. Use + * with caution and validate(!!) that any system fields are not removed + * (accidentally), when building authorized packages that can write the metadata + * field. + */ +export function setData(options: SetDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'domain', 'data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'set_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasRecordArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface HasRecordOptions { + package: string; + arguments: + | HasRecordArguments + | [self: RawTransactionArgument, domain: RawTransactionArgument]; +} +/** Check whether the given `domain` is registered in the `Registry`. */ +export function hasRecord(options: HasRecordOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'has_record', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LookupArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface LookupOptions { + package: string; + arguments: + | LookupArguments + | [self: RawTransactionArgument, domain: RawTransactionArgument]; +} +/** Returns the `NameRecord` associated with the given domain or None. */ +export function lookup(options: LookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ReverseLookupArguments { + self: RawTransactionArgument; + address: RawTransactionArgument; +} +export interface ReverseLookupOptions { + package: string; + arguments: + | ReverseLookupArguments + | [self: RawTransactionArgument, address: RawTransactionArgument]; +} +/** Returns the `domain_name` associated with the given address or None. */ +export function reverseLookup(options: ReverseLookupOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, 'address'] satisfies (string | null)[]; + const parameterNames = ['self', 'address']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'reverse_lookup', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AssertNftIsAuthorizedArguments { + self: RawTransactionArgument; + nft: RawTransactionArgument; +} +export interface AssertNftIsAuthorizedOptions { + package: string; + arguments: + | AssertNftIsAuthorizedArguments + | [self: RawTransactionArgument, nft: RawTransactionArgument]; +} +/** + * Asserts that the provided NFT: + * + * 1. Matches the ID in the corresponding `Record` + * 2. Has not expired (does not take into account the grace period) + */ +export function assertNftIsAuthorized(options: AssertNftIsAuthorizedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self', 'nft']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'assert_nft_is_authorized', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetDataArguments { + self: RawTransactionArgument; + domain: RawTransactionArgument; +} +export interface GetDataOptions { + package: string; + arguments: + | GetDataArguments + | [self: RawTransactionArgument, domain: RawTransactionArgument]; +} +/** Returns the `data` associated with the given `Domain`. */ +export function getData(options: GetDataOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', 'domain']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'registry', + function: 'get_data', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts b/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts new file mode 100644 index 000000000..9f6703e99 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts @@ -0,0 +1,67 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A wrapper for `SuinsRegistration` subdomain objects. + * + * With the wrapper, we are allowing easier distinction between second level names + * & subdomains in RPC Querying | filtering. + * + * We maintain all core functionality unchanged for registry, expiration etc. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as suins_registration from './suins_registration.js'; +const $moduleName = 'suins::subdomain_registration'; +export const SubDomainRegistration = new MoveStruct({ + name: `${$moduleName}::SubDomainRegistration`, + fields: { + id: bcs.Address, + nft: suins_registration.SuinsRegistration, + }, +}); +export interface NftArguments { + name: RawTransactionArgument; +} +export interface NftOptions { + package: string; + arguments: NftArguments | [name: RawTransactionArgument]; +} +export function nft(options: NftOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'subdomain_registration', + function: 'nft', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface NftMutArguments { + name: RawTransactionArgument; +} +export interface NftMutOptions { + package: string; + arguments: NftMutArguments | [name: RawTransactionArgument]; +} +export function nftMut(options: NftMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['name']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'subdomain_registration', + function: 'nft_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts b/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts new file mode 100644 index 000000000..3b217d87c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts @@ -0,0 +1,460 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * The main module of the SuiNS application, defines the `SuiNS` object and the + * authorization mechanism for interacting with the main data storage. + * + * Authorization mechanic: The Admin can authorize applications to access protected + * features of the SuiNS, they're named with a prefix `app_*`. Once authorized, + * application can get mutable access to the `Registry` and add to the application + * `Balance`. + * + * At any moment any of the applications can be deathorized by the Admin making it + * impossible for the deauthorized module to access the registry. + * + * --- + * + * Package Upgrades in mind: + * + * - None of the public functions of the SuiNS feature any specific types - instead + * we use generics to define the actual types in arbitrary modules. + * - The `Registry` itself (the main feature of the application) is stored as a + * dynamic field so that we can change the type and the module that serves the + * registry without breaking the SuiNS compatibility. + * - Any of the old modules can be deauthorized hence disabling its access to the + * registry and the balance. + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs, type BcsType } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as balance from '../sui/balance.js'; +const $moduleName = 'suins::suins'; +export const AdminCap = new MoveStruct({ + name: `${$moduleName}::AdminCap`, + fields: { + id: bcs.Address, + }, +}); +export const SuiNS = new MoveStruct({ + name: `${$moduleName}::SuiNS`, + fields: { + id: bcs.Address, + /** + * The total balance of the SuiNS. Can be added to by authorized apps. Can be + * withdrawn only by the application Admin. + */ + balance: balance.Balance, + }, +}); +export const SUINS = new MoveStruct({ + name: `${$moduleName}::SUINS`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const ConfigKey = new MoveStruct({ + name: `${$moduleName}::ConfigKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const RegistryKey = new MoveStruct({ + name: `${$moduleName}::RegistryKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const BalanceKey = new MoveStruct({ + name: `${$moduleName}::BalanceKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export const AppKey = new MoveStruct({ + name: `${$moduleName}::AppKey`, + fields: { + dummy_field: bcs.bool(), + }, +}); +export interface WithdrawArguments { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface WithdrawOptions { + package: string; + arguments: + | WithdrawArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; +} +/** + * Withdraw from the SuiNS balance directly and access the Coins within the same + * transaction. This is useful for the admin to withdraw funds from the SuiNS and + * then send them somewhere specific or keep at the address. + */ +export function withdraw(options: WithdrawOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'withdraw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface WithdrawCustomArguments { + self: RawTransactionArgument; + _: RawTransactionArgument; +} +export interface WithdrawCustomOptions { + package: string; + arguments: + | WithdrawCustomArguments + | [self: RawTransactionArgument, _: RawTransactionArgument]; + typeArguments: [string]; +} +/** Withdraw from the SuiNS balance of a custom coin type. */ +export function withdrawCustom(options: WithdrawCustomOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['self', '_']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'withdraw_custom', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AuthorizeAppArguments { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface AuthorizeAppOptions { + package: string; + arguments: + | AuthorizeAppArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Authorize an application to access protected features of the SuiNS. */ +export function authorizeApp(options: AuthorizeAppOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'authorize_app', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DeauthorizeAppArguments { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface DeauthorizeAppOptions { + package: string; + arguments: + | DeauthorizeAppArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Deauthorize an application by removing its authorization key. */ +export function deauthorizeApp(options: DeauthorizeAppOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'deauthorize_app', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsAppAuthorizedArguments { + self: RawTransactionArgument; +} +export interface IsAppAuthorizedOptions { + package: string; + arguments: IsAppAuthorizedArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Check if an application is authorized to access protected features of the SuiNS. */ +export function isAppAuthorized(options: IsAppAuthorizedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'is_app_authorized', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AssertAppIsAuthorizedArguments { + self: RawTransactionArgument; +} +export interface AssertAppIsAuthorizedOptions { + package: string; + arguments: AssertAppIsAuthorizedArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Assert that an application is authorized to access protected features of the + * SuiNS. Aborts with `EAppNotAuthorized` if not. + */ +export function assertAppIsAuthorized(options: AssertAppIsAuthorizedOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'assert_app_is_authorized', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AppAddBalanceArguments> { + _: RawTransactionArgument; + self: RawTransactionArgument; + balance: RawTransactionArgument; +} +export interface AppAddBalanceOptions> { + package: string; + arguments: + | AppAddBalanceArguments + | [ + _: RawTransactionArgument, + self: RawTransactionArgument, + balance: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Adds balance to the SuiNS. */ +export function appAddBalance>(options: AppAddBalanceOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self', 'balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'app_add_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AppAddCustomBalanceArguments> { + self: RawTransactionArgument; + _: RawTransactionArgument; + balance: RawTransactionArgument; +} +export interface AppAddCustomBalanceOptions> { + package: string; + arguments: + | AppAddCustomBalanceArguments + | [ + self: RawTransactionArgument, + _: RawTransactionArgument, + balance: RawTransactionArgument, + ]; + typeArguments: [string, string]; +} +/** Adds a balance of type `T` to the SuiNS protocol as an authorized app. */ +export function appAddCustomBalance>( + options: AppAddCustomBalanceOptions, +) { + const packageAddress = options.package; + const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['self', '_', 'balance']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'app_add_custom_balance', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AppRegistryMutArguments> { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface AppRegistryMutOptions> { + package: string; + arguments: + | AppRegistryMutArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string, string]; +} +/** + * Get a mutable access to the `Registry` object. Can only be performed by + * authorized applications. + */ +export function appRegistryMut>(options: AppRegistryMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'app_registry_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddConfigArguments> { + _: RawTransactionArgument; + self: RawTransactionArgument; + config: RawTransactionArgument; +} +export interface AddConfigOptions> { + package: string; + arguments: + | AddConfigArguments + | [ + _: RawTransactionArgument, + self: RawTransactionArgument, + config: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Attach dynamic configuration object to the application. */ +export function addConfig>(options: AddConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['_', 'self', 'config']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'add_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetConfigArguments { + self: RawTransactionArgument; +} +export interface GetConfigOptions { + package: string; + arguments: GetConfigArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Borrow configuration object. Read-only mode for applications. */ +export function getConfig(options: GetConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'get_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveConfigArguments { + _: RawTransactionArgument; + self: RawTransactionArgument; +} +export interface RemoveConfigOptions { + package: string; + arguments: + | RemoveConfigArguments + | [_: RawTransactionArgument, self: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Get the configuration object for editing. The admin should put it back after + * editing (no extra check performed). Can be used to swap configuration since the + * `T` has `drop`. Eg nothing is stopping the admin from removing the configuration + * object and adding a new one. + * + * Fully taking the config also allows for edits within a transaction. + */ +export function removeConfig(options: RemoveConfigOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['_', 'self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'remove_config', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RegistryArguments { + self: RawTransactionArgument; +} +export interface RegistryOptions { + package: string; + arguments: RegistryArguments | [self: RawTransactionArgument]; + typeArguments: [string]; +} +/** Get a read-only access to the `Registry` object. */ +export function registry(options: RegistryOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'registry', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AddRegistryArguments> { + _: RawTransactionArgument; + self: RawTransactionArgument; + registry: RawTransactionArgument; +} +export interface AddRegistryOptions> { + package: string; + arguments: + | AddRegistryArguments + | [ + _: RawTransactionArgument, + self: RawTransactionArgument, + registry: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Add a registry to the SuiNS. Can only be performed by the admin. */ +export function addRegistry>(options: AddRegistryOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['_', 'self', 'registry']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins', + function: 'add_registry', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts b/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts new file mode 100644 index 000000000..b852c671f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts @@ -0,0 +1,204 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Handles creation of the `SuinsRegistration`s. Separates the logic of creating a + * `SuinsRegistration`. New `SuinsRegistration`s can be created only by the + * `registry` and this module is tightly coupled with it. + * + * When reviewing the module, make sure that: + * + * - mutable functions can't be called directly by the owner + * - all getters are public and take an immutable reference + */ + +import { + MoveStruct, + normalizeMoveArguments, + type RawTransactionArgument, +} from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as domain_1 from './domain.js'; +const $moduleName = 'suins::suins_registration'; +export const SuinsRegistration = new MoveStruct({ + name: `${$moduleName}::SuinsRegistration`, + fields: { + id: bcs.Address, + /** The parsed domain. */ + domain: domain_1.Domain, + /** The domain name that the NFT is for. */ + domain_name: bcs.string(), + /** Timestamp in milliseconds when this NFT expires. */ + expiration_timestamp_ms: bcs.u64(), + /** Short IPFS hash of the image to be displayed for the NFT. */ + image_url: bcs.string(), + }, +}); +export interface HasExpiredArguments { + self: RawTransactionArgument; +} +export interface HasExpiredOptions { + package: string; + arguments: HasExpiredArguments | [self: RawTransactionArgument]; +} +/** + * Check whether the `SuinsRegistration` has expired by comparing the expiration + * timeout with the current time. + */ +export function hasExpired(options: HasExpiredOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'has_expired', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface HasExpiredPastGracePeriodArguments { + self: RawTransactionArgument; +} +export interface HasExpiredPastGracePeriodOptions { + package: string; + arguments: HasExpiredPastGracePeriodArguments | [self: RawTransactionArgument]; +} +/** + * Check whether the `SuinsRegistration` has expired by comparing the expiration + * timeout with the current time. This function also takes into account the grace + * period. + */ +export function hasExpiredPastGracePeriod(options: HasExpiredPastGracePeriodOptions) { + const packageAddress = options.package; + const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'has_expired_past_grace_period', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DomainArguments { + self: RawTransactionArgument; +} +export interface DomainOptions { + package: string; + arguments: DomainArguments | [self: RawTransactionArgument]; +} +/** Get the `domain` field of the `SuinsRegistration`. */ +export function domain(options: DomainOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'domain', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DomainNameArguments { + self: RawTransactionArgument; +} +export interface DomainNameOptions { + package: string; + arguments: DomainNameArguments | [self: RawTransactionArgument]; +} +/** Get the `domain_name` field of the `SuinsRegistration`. */ +export function domainName(options: DomainNameOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'domain_name', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ExpirationTimestampMsArguments { + self: RawTransactionArgument; +} +export interface ExpirationTimestampMsOptions { + package: string; + arguments: ExpirationTimestampMsArguments | [self: RawTransactionArgument]; +} +/** Get the `expiration_timestamp_ms` field of the `SuinsRegistration`. */ +export function expirationTimestampMs(options: ExpirationTimestampMsOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'expiration_timestamp_ms', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ImageUrlArguments { + self: RawTransactionArgument; +} +export interface ImageUrlOptions { + package: string; + arguments: ImageUrlArguments | [self: RawTransactionArgument]; +} +/** Get the `image_url` field of the `SuinsRegistration`. */ +export function imageUrl(options: ImageUrlOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'image_url', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidArguments { + self: RawTransactionArgument; +} +export interface UidOptions { + package: string; + arguments: UidArguments | [self: RawTransactionArgument]; +} +export function uid(options: UidOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'uid', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface UidMutArguments { + self: RawTransactionArgument; +} +export interface UidMutOptions { + package: string; + arguments: UidMutArguments | [self: RawTransactionArgument]; +} +/** Get the mutable `id` field of the `SuinsRegistration`. */ +export function uidMut(options: UidMutOptions) { + const packageAddress = options.package; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'suins_registration', + function: 'uid_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts b/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts new file mode 100644 index 000000000..6f3ea453b --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts @@ -0,0 +1,15 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** This module is deprecated due to our different approach to display. */ + +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = 'suins::update_image'; +export const UpdateImage = new MoveStruct({ + name: `${$moduleName}::UpdateImage`, + fields: { + dummy_field: bcs.bool(), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/fixed_point32.ts b/packages/suins/src/contracts/suins_auction/fixed_point32.ts new file mode 100644 index 000000000..d0cfa51f5 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/fixed_point32.ts @@ -0,0 +1,171 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines a fixed-point numeric type with a 32-bit integer part and a 32-bit + * fractional part. + */ + +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::fixed_point32'; +export const FixedPoint32 = new MoveStruct({ + name: `${$moduleName}::FixedPoint32`, + fields: { + value: bcs.u64(), + }, +}); +export interface MultiplyU64Arguments { + val: RawTransactionArgument; + multiplier: RawTransactionArgument; +} +export interface MultiplyU64Options { + package?: string; + arguments: + | MultiplyU64Arguments + | [val: RawTransactionArgument, multiplier: RawTransactionArgument]; +} +/** + * Multiply a u64 integer by a fixed-point number, truncating any fractional part + * of the product. This will abort if the product overflows. + */ +export function multiplyU64(options: MultiplyU64Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', null] satisfies (string | null)[]; + const parameterNames = ['val', 'multiplier']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'multiply_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideU64Arguments { + val: RawTransactionArgument; + divisor: RawTransactionArgument; +} +export interface DivideU64Options { + package?: string; + arguments: + | DivideU64Arguments + | [val: RawTransactionArgument, divisor: RawTransactionArgument]; +} +/** + * Divide a u64 integer by a fixed-point number, truncating any fractional part of + * the quotient. This will abort if the divisor is zero or if the quotient + * overflows. + */ +export function divideU64(options: DivideU64Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', null] satisfies (string | null)[]; + const parameterNames = ['val', 'divisor']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'divide_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateFromRationalArguments { + numerator: RawTransactionArgument; + denominator: RawTransactionArgument; +} +export interface CreateFromRationalOptions { + package?: string; + arguments: + | CreateFromRationalArguments + | [ + numerator: RawTransactionArgument, + denominator: RawTransactionArgument, + ]; +} +/** + * Create a fixed-point value from a rational number specified by its numerator and + * denominator. Calling this function should be preferred for using + * `Self::create_from_raw_value` which is also available. This will abort if the + * denominator is zero. It will also abort if the numerator is nonzero and the + * ratio is not in the range 2^-32 .. 2^32-1. When specifying decimal fractions, be + * careful about rounding errors: if you round to display N digits after the + * decimal point, you can use a denominator of 10^N to avoid numbers where the very + * small imprecision in the binary representation could change the rounding, e.g., + * 0.0125 will round down to 0.012 instead of up to 0.013. + */ +export function createFromRational(options: CreateFromRationalOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['numerator', 'denominator']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'create_from_rational', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface CreateFromRawValueArguments { + value: RawTransactionArgument; +} +export interface CreateFromRawValueOptions { + package?: string; + arguments: CreateFromRawValueArguments | [value: RawTransactionArgument]; +} +/** Create a fixedpoint value from a raw value. */ +export function createFromRawValue(options: CreateFromRawValueOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['value']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'create_from_raw_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetRawValueArguments { + num: RawTransactionArgument; +} +export interface GetRawValueOptions { + package?: string; + arguments: GetRawValueArguments | [num: RawTransactionArgument]; +} +/** + * Accessor for the raw u64 value. Other less common operations, such as adding or + * subtracting FixedPoint32 values, can be done using the raw values directly. + */ +export function getRawValue(options: GetRawValueOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['num']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'get_raw_value', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsZeroArguments { + num: RawTransactionArgument; +} +export interface IsZeroOptions { + package?: string; + arguments: IsZeroArguments | [num: RawTransactionArgument]; +} +/** Returns true if the ratio is zero. */ +export function isZero(options: IsZeroOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['num']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'fixed_point32', + function: 'is_zero', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/hash.ts b/packages/suins/src/contracts/suins_auction/hash.ts new file mode 100644 index 000000000..114c1955c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/hash.ts @@ -0,0 +1,51 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Module which defines SHA hashes for byte vectors. + * + * The functions in this module are natively declared both in the Move runtime as + * in the Move prover's prelude. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface Sha2_256Arguments { + data: RawTransactionArgument; +} +export interface Sha2_256Options { + package?: string; + arguments: Sha2_256Arguments | [data: RawTransactionArgument]; +} +export function sha2_256(options: Sha2_256Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hash', + function: 'sha2_256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface Sha3_256Arguments { + data: RawTransactionArgument; +} +export interface Sha3_256Options { + package?: string; + arguments: Sha3_256Arguments | [data: RawTransactionArgument]; +} +export function sha3_256(options: Sha3_256Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['data']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'hash', + function: 'sha3_256', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/internal.ts b/packages/suins/src/contracts/suins_auction/internal.ts new file mode 100644 index 000000000..2f9b2af96 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/internal.ts @@ -0,0 +1,59 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines the `Permit` type, which can be used to constrain the logic of a generic + * function to be authorized only by the module that defines the type parameter. + * + * ```move + * module example::use_permit; + * + * public struct MyType { /* ... *\/ } + * + * public fun test_permit() { + * let permit = internal::permit(); + * /* external_module::call_with_permit(permit); *\/ + * } + * ``` + * + * To write a function that is guarded by a `Permit`, require it as an argument. + * + * ```move + * // Silly mockup of a type registry where a type can be registered only by + * // the module that defines the type. + * module example::type_registry; + * + * public fun register_type(_: internal::Permit /* ... *\/) { + * /* ... *\/ + * } + * ``` + */ + +import { MoveTuple } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::internal'; +export const Permit = new MoveTuple({ + name: `${$moduleName}::Permit`, + fields: [bcs.bool()], +}); +export interface PermitOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Construct a new `Permit` for the type `T`. Can only be called by the module that + * defines the type `T`. + */ +export function permit(options: PermitOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'internal', + function: 'permit', + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/offer.ts b/packages/suins/src/contracts/suins_auction/offer.ts new file mode 100644 index 000000000..6297ec93f --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/offer.ts @@ -0,0 +1,423 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +import * as table from './deps/sui/table.js'; +import * as object_bag from './deps/sui/object_bag.js'; +import * as bag from './deps/sui/bag.js'; +import * as balance from './deps/sui/balance.js'; +import * as suins_registration from './deps/suins/suins_registration.js'; +import * as type_name from './type_name.js'; +const $moduleName = '@suins/auction::offer'; +export const OfferTable = new MoveStruct({ + name: `${$moduleName}::OfferTable`, + fields: { + id: bcs.Address, + version: bcs.u64(), + table: table.Table, + listings: object_bag.ObjectBag, + allowed_tokens: table.Table, + service_fee: bcs.u64(), + /** Accumulated service fees for each token type */ + fees: bag.Bag, + }, +}); +export const Offer = new MoveStruct({ + name: `${$moduleName}::Offer`, + fields: { + balance: balance.Balance, + counter_offer: bcs.u64(), + expires_at: bcs.option(bcs.u64()), + }, +}); +export const Listing = new MoveStruct({ + name: `${$moduleName}::Listing`, + fields: { + id: bcs.Address, + owner: bcs.Address, + price: bcs.u64(), + expires_at: bcs.option(bcs.u64()), + suins_registration: suins_registration.SuinsRegistration, + }, +}); +export const OfferPlacedEvent = new MoveStruct({ + name: `${$moduleName}::OfferPlacedEvent`, + fields: { + domain_name: bcs.string(), + address: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + expires_at: bcs.option(bcs.u64()), + }, +}); +export const OfferCancelledEvent = new MoveStruct({ + name: `${$moduleName}::OfferCancelledEvent`, + fields: { + domain_name: bcs.string(), + address: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const OfferAcceptedEvent = new MoveStruct({ + name: `${$moduleName}::OfferAcceptedEvent`, + fields: { + domain_name: bcs.string(), + owner: bcs.Address, + buyer: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const OfferDeclinedEvent = new MoveStruct({ + name: `${$moduleName}::OfferDeclinedEvent`, + fields: { + domain_name: bcs.string(), + owner: bcs.Address, + buyer: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const MakeCounterOfferEvent = new MoveStruct({ + name: `${$moduleName}::MakeCounterOfferEvent`, + fields: { + domain_name: bcs.string(), + owner: bcs.Address, + buyer: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const AcceptCounterOfferEvent = new MoveStruct({ + name: `${$moduleName}::AcceptCounterOfferEvent`, + fields: { + domain_name: bcs.string(), + buyer: bcs.Address, + value: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const ListingCreatedEvent = new MoveStruct({ + name: `${$moduleName}::ListingCreatedEvent`, + fields: { + listing_id: bcs.Address, + domain_name: bcs.string(), + owner: bcs.Address, + price: bcs.u64(), + expires_at: bcs.option(bcs.u64()), + token: type_name.TypeName, + }, +}); +export const ListingBoughtEvent = new MoveStruct({ + name: `${$moduleName}::ListingBoughtEvent`, + fields: { + listing_id: bcs.Address, + domain_name: bcs.string(), + buyer: bcs.Address, + amount: bcs.u64(), + token: type_name.TypeName, + }, +}); +export const ListingCancelledEvent = new MoveStruct({ + name: `${$moduleName}::ListingCancelledEvent`, + fields: { + listing_id: bcs.Address, + domain_name: bcs.string(), + owner: bcs.Address, + token: type_name.TypeName, + }, +}); +export interface PlaceOfferArguments { + suins: RawTransactionArgument; + offerTable: RawTransactionArgument; + domainName: RawTransactionArgument; + coin: RawTransactionArgument; + expiresAt: RawTransactionArgument; +} +export interface PlaceOfferOptions { + package?: string; + arguments: + | PlaceOfferArguments + | [ + suins: RawTransactionArgument, + offerTable: RawTransactionArgument, + domainName: RawTransactionArgument, + coin: RawTransactionArgument, + expiresAt: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Place an offer on a domain */ +export function placeOffer(options: PlaceOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + null, + null, + '0x1::string::String', + null, + '0x1::option::Option', + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['suins', 'offerTable', 'domainName', 'coin', 'expiresAt']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'place_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CancelOfferArguments { + offerTable: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface CancelOfferOptions { + package?: string; + arguments: + | CancelOfferArguments + | [offerTable: RawTransactionArgument, domainName: RawTransactionArgument]; + typeArguments: [string]; +} +/** Cancel an offer on a domain */ +export function cancelOffer(options: CancelOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'cancel_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AcceptOfferArguments { + suins: RawTransactionArgument; + offerTable: RawTransactionArgument; + suinsRegistration: RawTransactionArgument; + address: RawTransactionArgument; +} +export interface AcceptOfferOptions { + package?: string; + arguments: + | AcceptOfferArguments + | [ + suins: RawTransactionArgument, + offerTable: RawTransactionArgument, + suinsRegistration: RawTransactionArgument, + address: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Accept an offer */ +export function acceptOffer(options: AcceptOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, null, 'address', '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['suins', 'offerTable', 'suinsRegistration', 'address']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'accept_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DeclineOfferArguments { + offerTable: RawTransactionArgument; + suinsRegistration: RawTransactionArgument; + address: RawTransactionArgument; +} +export interface DeclineOfferOptions { + package?: string; + arguments: + | DeclineOfferArguments + | [ + offerTable: RawTransactionArgument, + suinsRegistration: RawTransactionArgument, + address: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Decline an offer */ +export function declineOffer(options: DeclineOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, 'address'] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'suinsRegistration', 'address']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'decline_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface MakeCounterOfferArguments { + offerTable: RawTransactionArgument; + suinsRegistration: RawTransactionArgument; + address: RawTransactionArgument; + counterOfferValue: RawTransactionArgument; +} +export interface MakeCounterOfferOptions { + package?: string; + arguments: + | MakeCounterOfferArguments + | [ + offerTable: RawTransactionArgument, + suinsRegistration: RawTransactionArgument, + address: RawTransactionArgument, + counterOfferValue: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Make a counter offer */ +export function makeCounterOffer(options: MakeCounterOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, 'address', 'u64'] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'suinsRegistration', 'address', 'counterOfferValue']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'make_counter_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AcceptCounterOfferArguments { + offerTable: RawTransactionArgument; + domainName: RawTransactionArgument; + coin: RawTransactionArgument; +} +export interface AcceptCounterOfferOptions { + package?: string; + arguments: + | AcceptCounterOfferArguments + | [ + offerTable: RawTransactionArgument, + domainName: RawTransactionArgument, + coin: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Accept a counter offer */ +export function acceptCounterOffer(options: AcceptCounterOfferOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, '0x1::string::String', null] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'domainName', 'coin']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'accept_counter_offer', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CreateListingArguments { + offerTable: RawTransactionArgument; + price: RawTransactionArgument; + expiresAt: RawTransactionArgument; + suinsRegistration: RawTransactionArgument; +} +export interface CreateListingOptions { + package?: string; + arguments: + | CreateListingArguments + | [ + offerTable: RawTransactionArgument, + price: RawTransactionArgument, + expiresAt: RawTransactionArgument, + suinsRegistration: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Create a listing for a domain with a fixed price */ +export function createListing(options: CreateListingOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + null, + 'u64', + '0x1::option::Option', + null, + '0x2::clock::Clock', + ] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'price', 'expiresAt', 'suinsRegistration']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'create_listing', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BuyListingArguments { + suins: RawTransactionArgument; + offerTable: RawTransactionArgument; + domainName: RawTransactionArgument; + payment: RawTransactionArgument; +} +export interface BuyListingOptions { + package?: string; + arguments: + | BuyListingArguments + | [ + suins: RawTransactionArgument, + offerTable: RawTransactionArgument, + domainName: RawTransactionArgument, + payment: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** Buy a listing */ +export function buyListing(options: BuyListingOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( + | string + | null + )[]; + const parameterNames = ['suins', 'offerTable', 'domainName', 'payment']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'buy_listing', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface CancelListingArguments { + offerTable: RawTransactionArgument; + domainName: RawTransactionArgument; +} +export interface CancelListingOptions { + package?: string; + arguments: + | CancelListingArguments + | [offerTable: RawTransactionArgument, domainName: RawTransactionArgument]; + typeArguments: [string]; +} +/** Cancel a listing */ +export function cancelListing(options: CancelListingOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['offerTable', 'domainName']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'offer', + function: 'cancel_listing', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/option.ts b/packages/suins/src/contracts/suins_auction/option.ts new file mode 100644 index 000000000..d87305cbf --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/option.ts @@ -0,0 +1,494 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * This module defines the Option type and its methods to represent and handle an + * optional value. + */ + +import { type BcsType, bcs } from '@mysten/sui/bcs'; +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::option'; +/** + * Abstraction of a value that may or may not be present. Implemented with a vector + * of size zero or one because Move bytecode does not have ADTs. + */ +export function Option>(...typeParameters: [Element]) { + return new MoveStruct({ + name: `${$moduleName}::Option<${typeParameters[0].name as Element['name']}>`, + fields: { + vec: bcs.vector(typeParameters[0]), + }, + }); +} +export interface NoneOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** Return an empty `Option` */ +export function none(options: NoneOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'none', + typeArguments: options.typeArguments, + }); +} +export interface SomeArguments> { + e: RawTransactionArgument; +} +export interface SomeOptions> { + package?: string; + arguments: SomeArguments | [e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return an `Option` containing `e` */ +export function some>(options: SomeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'some', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsNoneArguments> { + t: RawTransactionArgument; +} +export interface IsNoneOptions> { + package?: string; + arguments: IsNoneArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return true if `t` does not hold a value */ +export function isNone>(options: IsNoneOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'is_none', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsSomeArguments> { + t: RawTransactionArgument; +} +export interface IsSomeOptions> { + package?: string; + arguments: IsSomeArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return true if `t` holds a value */ +export function isSome>(options: IsSomeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'is_some', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + t: RawTransactionArgument; + eRef: RawTransactionArgument; +} +export interface ContainsOptions> { + package?: string; + arguments: + | ContainsArguments + | [t: RawTransactionArgument, eRef: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return true if the value in `t` is equal to `e_ref` Always returns `false` if + * `t` does not hold a value + */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'eRef']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + t: RawTransactionArgument; +} +export interface BorrowOptions> { + package?: string; + arguments: BorrowArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return an immutable reference to the value inside `t` Aborts if `t` does not + * hold a value + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowWithDefaultArguments> { + t: RawTransactionArgument; + defaultRef: RawTransactionArgument; +} +export interface BorrowWithDefaultOptions> { + package?: string; + arguments: + | BorrowWithDefaultArguments + | [t: RawTransactionArgument, defaultRef: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return a reference to the value inside `t` if it holds one Return `default_ref` + * if `t` does not hold a value + */ +export function borrowWithDefault>( + options: BorrowWithDefaultOptions, +) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'defaultRef']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'borrow_with_default', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface GetWithDefaultArguments> { + t: RawTransactionArgument; + default: RawTransactionArgument; +} +export interface GetWithDefaultOptions> { + package?: string; + arguments: GetWithDefaultArguments | [t: RawTransactionArgument]; + default: RawTransactionArgument; + typeArguments: [string]; +} +/** + * Return the value inside `t` if it holds one Return `default` if `t` does not + * hold a value + */ +export function getWithDefault>( + options: GetWithDefaultOptions, +) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'default']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'get_with_default', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FillArguments> { + t: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface FillOptions> { + package?: string; + arguments: + | FillArguments + | [t: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Convert the none option `t` to a some option by adding `e`. Aborts if `t` + * already holds a value + */ +export function fill>(options: FillOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'fill', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ExtractArguments> { + t: RawTransactionArgument; +} +export interface ExtractOptions> { + package?: string; + arguments: ExtractArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Convert a `some` option to a `none` by removing and returning the value stored + * inside `t` Aborts if `t` does not hold a value + */ +export function extract>(options: ExtractOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'extract', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + t: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package?: string; + arguments: BorrowMutArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return a mutable reference to the value inside `t` Aborts if `t` does not hold a + * value + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapArguments> { + t: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface SwapOptions> { + package?: string; + arguments: + | SwapArguments + | [t: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Swap the old value inside `t` with `e` and return the old value Aborts if `t` + * does not hold a value + */ +export function swap>(options: SwapOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'swap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapOrFillArguments> { + t: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface SwapOrFillOptions> { + package?: string; + arguments: + | SwapOrFillArguments + | [t: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Swap the old value inside `t` with `e` and return the old value; or if there is + * no old value, fill it with `e`. Different from swap(), swap_or_fill() allows for + * `t` not holding a value. + */ +export function swapOrFill>(options: SwapOrFillOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'swap_or_fill', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyWithDefaultArguments> { + t: RawTransactionArgument; + default: RawTransactionArgument; +} +export interface DestroyWithDefaultOptions> { + package?: string; + arguments: DestroyWithDefaultArguments | [t: RawTransactionArgument]; + default: RawTransactionArgument; + typeArguments: [string]; +} +/** Destroys `t.` If `t` holds a value, return it. Returns `default` otherwise */ +export function destroyWithDefault>( + options: DestroyWithDefaultOptions, +) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `0x1::option::Option<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['t', 'default']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'destroy_with_default', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroySomeArguments> { + t: RawTransactionArgument; +} +export interface DestroySomeOptions> { + package?: string; + arguments: DestroySomeArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Unpack `t` and return its contents Aborts if `t` does not hold a value */ +export function destroySome>(options: DestroySomeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'destroy_some', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyNoneArguments> { + t: RawTransactionArgument; +} +export interface DestroyNoneOptions> { + package?: string; + arguments: DestroyNoneArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** Unpack `t` Aborts if `t` holds a value */ +export function destroyNone>(options: DestroyNoneOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'destroy_none', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ToVecArguments> { + t: RawTransactionArgument; +} +export interface ToVecOptions> { + package?: string; + arguments: ToVecArguments | [t: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Convert `t` into a vector of length 1 if it is `Some`, and an empty vector + * otherwise + */ +export function toVec>(options: ToVecOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['t']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'option', + function: 'to_vec', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/contracts/suins_auction/string.ts b/packages/suins/src/contracts/suins_auction/string.ts new file mode 100644 index 000000000..0cfc77d89 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/string.ts @@ -0,0 +1,367 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * The `string` module defines the `String` type which represents UTF8 encoded + * strings. + */ + +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::string'; +export const String = new MoveStruct({ + name: `${$moduleName}::String`, + fields: { + bytes: bcs.vector(bcs.u8()), + }, +}); +export interface Utf8Arguments { + bytes: RawTransactionArgument; +} +export interface Utf8Options { + package?: string; + arguments: Utf8Arguments | [bytes: RawTransactionArgument]; +} +/** + * Creates a new string from a sequence of bytes. Aborts if the bytes do not + * represent valid utf8. + */ +export function utf8(options: Utf8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'utf8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromAsciiArguments { + s: RawTransactionArgument; +} +export interface FromAsciiOptions { + package?: string; + arguments: FromAsciiArguments | [s: RawTransactionArgument]; +} +/** Convert an ASCII string to a UTF8 string */ +export function fromAscii(options: FromAsciiOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'from_ascii', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToAsciiArguments { + s: RawTransactionArgument; +} +export interface ToAsciiOptions { + package?: string; + arguments: ToAsciiArguments | [s: RawTransactionArgument]; +} +/** Convert an UTF8 string to an ASCII string. Aborts if `s` is not valid ASCII */ +export function toAscii(options: ToAsciiOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'to_ascii', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryUtf8Arguments { + bytes: RawTransactionArgument; +} +export interface TryUtf8Options { + package?: string; + arguments: TryUtf8Arguments | [bytes: RawTransactionArgument]; +} +/** Tries to create a new string from a sequence of bytes. */ +export function tryUtf8(options: TryUtf8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['vector'] satisfies (string | null)[]; + const parameterNames = ['bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'try_utf8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AsBytesArguments { + s: RawTransactionArgument; +} +export interface AsBytesOptions { + package?: string; + arguments: AsBytesArguments | [s: RawTransactionArgument]; +} +/** Returns a reference to the underlying byte vector. */ +export function asBytes(options: AsBytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'as_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntoBytesArguments { + s: RawTransactionArgument; +} +export interface IntoBytesOptions { + package?: string; + arguments: IntoBytesArguments | [s: RawTransactionArgument]; +} +/** Unpack the `string` to get its underlying bytes. */ +export function intoBytes(options: IntoBytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'into_bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IsEmptyArguments { + s: RawTransactionArgument; +} +export interface IsEmptyOptions { + package?: string; + arguments: IsEmptyArguments | [s: RawTransactionArgument]; +} +/** Checks whether this string is empty. */ +export function isEmpty(options: IsEmptyOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LengthArguments { + s: RawTransactionArgument; +} +export interface LengthOptions { + package?: string; + arguments: LengthArguments | [s: RawTransactionArgument]; +} +/** Returns the length of this string, in bytes. */ +export function length(options: LengthOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AppendArguments { + s: RawTransactionArgument; + r: RawTransactionArgument; +} +export interface AppendOptions { + package?: string; + arguments: + | AppendArguments + | [s: RawTransactionArgument, r: RawTransactionArgument]; +} +/** Appends a string. */ +export function append(options: AppendOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s', 'r']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'append', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AppendUtf8Arguments { + s: RawTransactionArgument; + bytes: RawTransactionArgument; +} +export interface AppendUtf8Options { + package?: string; + arguments: + | AppendUtf8Arguments + | [s: RawTransactionArgument, bytes: RawTransactionArgument]; +} +/** Appends bytes which must be in valid utf8 format. */ +export function appendUtf8(options: AppendUtf8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'vector'] satisfies (string | null)[]; + const parameterNames = ['s', 'bytes']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'append_utf8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface InsertArguments { + s: RawTransactionArgument; + at: RawTransactionArgument; + o: RawTransactionArgument; +} +export interface InsertOptions { + package?: string; + arguments: + | InsertArguments + | [ + s: RawTransactionArgument, + at: RawTransactionArgument, + o: RawTransactionArgument, + ]; +} +/** + * Insert the other string at the byte index in given string. The index must be at + * a valid utf8 char boundary. + */ +export function insert(options: InsertOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'u64', '0x1::string::String'] satisfies ( + | string + | null + )[]; + const parameterNames = ['s', 'at', 'o']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SubstringArguments { + s: RawTransactionArgument; + i: RawTransactionArgument; + j: RawTransactionArgument; +} +export interface SubstringOptions { + package?: string; + arguments: + | SubstringArguments + | [ + s: RawTransactionArgument, + i: RawTransactionArgument, + j: RawTransactionArgument, + ]; +} +/** + * Returns a sub-string using the given byte indices, where `i` is the first byte + * position and `j` is the start of the first byte not included (or the length of + * the string). The indices must be at valid utf8 char boundaries, guaranteeing + * that the result is valid utf8. + */ +export function substring(options: SubstringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['s', 'i', 'j']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'substring', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IndexOfArguments { + s: RawTransactionArgument; + r: RawTransactionArgument; +} +export interface IndexOfOptions { + package?: string; + arguments: + | IndexOfArguments + | [s: RawTransactionArgument, r: RawTransactionArgument]; +} +/** + * Computes the index of the first occurrence of a string. Returns `s.length()` if + * no occurrence found. + */ +export function indexOf(options: IndexOfOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s', 'r']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'index_of', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface BytesArguments { + s: RawTransactionArgument; +} +export interface BytesOptions { + package?: string; + arguments: BytesArguments | [s: RawTransactionArgument]; +} +export function bytes(options: BytesOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const parameterNames = ['s']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'bytes', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SubStringArguments { + s: RawTransactionArgument; + i: RawTransactionArgument; + j: RawTransactionArgument; +} +export interface SubStringOptions { + package?: string; + arguments: + | SubStringArguments + | [ + s: RawTransactionArgument, + i: RawTransactionArgument, + j: RawTransactionArgument, + ]; +} +export function subString(options: SubStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['s', 'i', 'j']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'string', + function: 'sub_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/type_name.ts b/packages/suins/src/contracts/suins_auction/type_name.ts new file mode 100644 index 000000000..8c4dd7751 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/type_name.ts @@ -0,0 +1,298 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Functionality for converting Move types into values. Use with care! */ + +import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::type_name'; +export const TypeName = new MoveStruct({ + name: `${$moduleName}::TypeName`, + fields: { + /** + * String representation of the type. All types are represented using their source + * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. + * Struct types are represented as fully qualified type names; e.g. + * `00000000000000000000000000000001::string::String` or + * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` + * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or + * 32 depending on the Move platform) + */ + name: bcs.string(), + }, +}); +export interface WithDefiningIdsOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Return a value representation of the type `T`. Package IDs that appear in fully + * qualified type names in the output from this function are defining IDs (the ID + * of the package in storage that first introduced the type). + */ +export function withDefiningIds(options: WithDefiningIdsOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'with_defining_ids', + typeArguments: options.typeArguments, + }); +} +export interface WithOriginalIdsOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Return a value representation of the type `T`. Package IDs that appear in fully + * qualified type names in the output from this function are original IDs (the ID + * of the first version of the package, even if the type in question was introduced + * in a later upgrade). + */ +export function withOriginalIds(options: WithOriginalIdsOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'with_original_ids', + typeArguments: options.typeArguments, + }); +} +export interface DefiningIdOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Like `with_defining_ids`, this accesses the package ID that original defined the + * type `T`. + */ +export function definingId(options: DefiningIdOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'defining_id', + typeArguments: options.typeArguments, + }); +} +export interface OriginalIdOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** + * Like `with_original_ids`, this accesses the original ID of the package that + * defines type `T`, even if the type was introduced in a later version of the + * package. + */ +export function originalId(options: OriginalIdOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'original_id', + typeArguments: options.typeArguments, + }); +} +export interface IsPrimitiveArguments { + self: RawTransactionArgument; +} +export interface IsPrimitiveOptions { + package?: string; + arguments: IsPrimitiveArguments | [self: RawTransactionArgument]; +} +/** + * Returns true iff the TypeName represents a primitive type, i.e. one of u8, u16, + * u32, u64, u128, u256, bool, address, vector. + */ +export function isPrimitive(options: IsPrimitiveOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'is_primitive', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AsStringArguments { + self: RawTransactionArgument; +} +export interface AsStringOptions { + package?: string; + arguments: AsStringArguments | [self: RawTransactionArgument]; +} +/** Get the String representation of `self` */ +export function asString(options: AsStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'as_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddressStringArguments { + self: RawTransactionArgument; +} +export interface AddressStringOptions { + package?: string; + arguments: AddressStringArguments | [self: RawTransactionArgument]; +} +/** + * Get Address string (Base16 encoded), first part of the TypeName. Aborts if given + * a primitive type. + */ +export function addressString(options: AddressStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'address_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ModuleStringArguments { + self: RawTransactionArgument; +} +export interface ModuleStringOptions { + package?: string; + arguments: ModuleStringArguments | [self: RawTransactionArgument]; +} +/** Get name of the module. Aborts if given a primitive type. */ +export function moduleString(options: ModuleStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'module_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntoStringArguments { + self: RawTransactionArgument; +} +export interface IntoStringOptions { + package?: string; + arguments: IntoStringArguments | [self: RawTransactionArgument]; +} +/** Convert `self` into its inner String */ +export function intoString(options: IntoStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'into_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +export function get(options: GetOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'get', + typeArguments: options.typeArguments, + }); +} +export interface GetWithOriginalIdsOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +export function getWithOriginalIds(options: GetWithOriginalIdsOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'get_with_original_ids', + typeArguments: options.typeArguments, + }); +} +export interface BorrowStringArguments { + self: RawTransactionArgument; +} +export interface BorrowStringOptions { + package?: string; + arguments: BorrowStringArguments | [self: RawTransactionArgument]; +} +export function borrowString(options: BorrowStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'borrow_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetAddressArguments { + self: RawTransactionArgument; +} +export interface GetAddressOptions { + package?: string; + arguments: GetAddressArguments | [self: RawTransactionArgument]; +} +export function getAddress(options: GetAddressOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'get_address', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GetModuleArguments { + self: RawTransactionArgument; +} +export interface GetModuleOptions { + package?: string; + arguments: GetModuleArguments | [self: RawTransactionArgument]; +} +export function getModule(options: GetModuleOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['self']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'type_name', + function: 'get_module', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u128.ts b/packages/suins/src/contracts/suins_auction/u128.ts new file mode 100644 index 000000000..17ecce2b7 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u128.ts @@ -0,0 +1,290 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: + | MaxArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: + | MinArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: + | DiffArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package?: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** + * Get a nearest lower integer Square Root for `x`. Given that this function can + * only operate with integers, it is impossible to get perfect (or precise) integer + * square root for some numbers. + * + * Example: + * + * ``` + * math::sqrt(9) => 3 + * math::sqrt(8) => 2 // the nearest lower square root is 4; + * ``` + * + * In integer math, one of the possible ways to get results with more precision is + * to use higher values or temporarily multiply the value by some bigger number. + * Ideally if this is a square of 10 or 100. + * + * Example: + * + * ``` + * math::sqrt(8) => 2; + * math::sqrt(8 * 10000) => 282; + * // now we can use this value as if it was 2.82; + * // but to get the actual result, this value needs + * // to be divided by 100 (because sqrt(10000)). + * + * + * math::sqrt(8 * 1000000) => 2828; // same as above, 2828 / 1000 (2.828) + * ``` + */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU8Arguments { + x: RawTransactionArgument; +} +export interface TryAsU8Options { + package?: string; + arguments: TryAsU8Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u128` to a `u8`. Returns `None` if the value is too large. */ +export function tryAsU8(options: TryAsU8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'try_as_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU16Arguments { + x: RawTransactionArgument; +} +export interface TryAsU16Options { + package?: string; + arguments: TryAsU16Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u128` to a `u16`. Returns `None` if the value is too large. */ +export function tryAsU16(options: TryAsU16Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'try_as_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU32Arguments { + x: RawTransactionArgument; +} +export interface TryAsU32Options { + package?: string; + arguments: TryAsU32Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u128` to a `u32`. Returns `None` if the value is too large. */ +export function tryAsU32(options: TryAsU32Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'try_as_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU64Arguments { + x: RawTransactionArgument; +} +export interface TryAsU64Options { + package?: string; + arguments: TryAsU64Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u128` to a `u64`. Returns `None` if the value is too large. */ +export function tryAsU64(options: TryAsU64Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'try_as_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u128', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u16.ts b/packages/suins/src/contracts/suins_auction/u16.ts new file mode 100644 index 000000000..827fc4d75 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u16.ts @@ -0,0 +1,224 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: MaxArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16', 'u16'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: MinArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16', 'u16'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: DiffArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16', 'u16'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16', 'u16'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package?: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** + * Get a nearest lower integer Square Root for `x`. Given that this function can + * only operate with integers, it is impossible to get perfect (or precise) integer + * square root for some numbers. + * + * Example: + * + * ``` + * math::sqrt(9) => 3 + * math::sqrt(8) => 2 // the nearest lower square root is 4; + * ``` + * + * In integer math, one of the possible ways to get results with more precision is + * to use higher values or temporarily multiply the value by some bigger number. + * Ideally if this is a square of 10 or 100. + * + * Example: + * + * ``` + * math::sqrt(8) => 2; + * math::sqrt(8 * 10000) => 282; + * // now we can use this value as if it was 2.82; + * // but to get the actual result, this value needs + * // to be divided by 100 (because sqrt(10000)). + * + * + * math::sqrt(8 * 1000000) => 2828; // same as above, 2828 / 1000 (2.828) + * ``` + */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU8Arguments { + x: RawTransactionArgument; +} +export interface TryAsU8Options { + package?: string; + arguments: TryAsU8Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u16` to a `u8`. Returns `None` if the value is too large. */ +export function tryAsU8(options: TryAsU8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'try_as_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u16'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u16', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u256.ts b/packages/suins/src/contracts/suins_auction/u256.ts new file mode 100644 index 000000000..497aa3de6 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u256.ts @@ -0,0 +1,262 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: + | MaxArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256', 'u256'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: + | MinArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256', 'u256'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: + | DiffArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256', 'u256'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256', 'u256'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU8Arguments { + x: RawTransactionArgument; +} +export interface TryAsU8Options { + package?: string; + arguments: TryAsU8Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u256` to a `u8`. Returns `None` if the value is too large. */ +export function tryAsU8(options: TryAsU8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'try_as_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU16Arguments { + x: RawTransactionArgument; +} +export interface TryAsU16Options { + package?: string; + arguments: TryAsU16Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u256` to a `u16`. Returns `None` if the value is too large. */ +export function tryAsU16(options: TryAsU16Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'try_as_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU32Arguments { + x: RawTransactionArgument; +} +export interface TryAsU32Options { + package?: string; + arguments: TryAsU32Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u256` to a `u32`. Returns `None` if the value is too large. */ +export function tryAsU32(options: TryAsU32Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'try_as_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU64Arguments { + x: RawTransactionArgument; +} +export interface TryAsU64Options { + package?: string; + arguments: TryAsU64Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u256` to a `u64`. Returns `None` if the value is too large. */ +export function tryAsU64(options: TryAsU64Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'try_as_u64', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU128Arguments { + x: RawTransactionArgument; +} +export interface TryAsU128Options { + package?: string; + arguments: TryAsU128Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u256` to a `u128`. Returns `None` if the value is too large. */ +export function tryAsU128(options: TryAsU128Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'try_as_u128', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u256'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u256', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u32.ts b/packages/suins/src/contracts/suins_auction/u32.ts new file mode 100644 index 000000000..ac21a9825 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u32.ts @@ -0,0 +1,244 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: MaxArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32', 'u32'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: MinArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32', 'u32'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: DiffArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32', 'u32'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32', 'u32'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package?: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** + * Get a nearest lower integer Square Root for `x`. Given that this function can + * only operate with integers, it is impossible to get perfect (or precise) integer + * square root for some numbers. + * + * Example: + * + * ``` + * math::sqrt(9) => 3 + * math::sqrt(8) => 2 // the nearest lower square root is 4; + * ``` + * + * In integer math, one of the possible ways to get results with more precision is + * to use higher values or temporarily multiply the value by some bigger number. + * Ideally if this is a square of 10 or 100. + * + * Example: + * + * ``` + * math::sqrt(8) => 2; + * math::sqrt(8 * 10000) => 282; + * // now we can use this value as if it was 2.82; + * // but to get the actual result, this value needs + * // to be divided by 100 (because sqrt(10000)). + * + * + * math::sqrt(8 * 1000000) => 2828; // same as above, 2828 / 1000 (2.828) + * ``` + */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU8Arguments { + x: RawTransactionArgument; +} +export interface TryAsU8Options { + package?: string; + arguments: TryAsU8Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u32` to a `u8`. Returns `None` if the value is too large. */ +export function tryAsU8(options: TryAsU8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'try_as_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU16Arguments { + x: RawTransactionArgument; +} +export interface TryAsU16Options { + package?: string; + arguments: TryAsU16Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u32` to a `u16`. Returns `None` if the value is too large. */ +export function tryAsU16(options: TryAsU16Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'try_as_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u32', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u64.ts b/packages/suins/src/contracts/suins_auction/u64.ts new file mode 100644 index 000000000..b5ff10cdf --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u64.ts @@ -0,0 +1,270 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: + | MaxArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: + | MinArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: + | DiffArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package?: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** + * Get a nearest lower integer Square Root for `x`. Given that this function can + * only operate with integers, it is impossible to get perfect (or precise) integer + * square root for some numbers. + * + * Example: + * + * ``` + * math::sqrt(9) => 3 + * math::sqrt(8) => 2 // the nearest lower square root is 4; + * ``` + * + * In integer math, one of the possible ways to get results with more precision is + * to use higher values or temporarily multiply the value by some bigger number. + * Ideally if this is a square of 10 or 100. + * + * Example: + * + * ``` + * math::sqrt(8) => 2; + * math::sqrt(8 * 10000) => 282; + * // now we can use this value as if it was 2.82; + * // but to get the actual result, this value needs + * // to be divided by 100 (because sqrt(10000)). + * + * + * math::sqrt(8 * 1000000) => 2828; // same as above, 2828 / 1000 (2.828) + * ``` + */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU8Arguments { + x: RawTransactionArgument; +} +export interface TryAsU8Options { + package?: string; + arguments: TryAsU8Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u64` to a `u8`. Returns `None` if the value is too large. */ +export function tryAsU8(options: TryAsU8Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'try_as_u8', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU16Arguments { + x: RawTransactionArgument; +} +export interface TryAsU16Options { + package?: string; + arguments: TryAsU16Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u64` to a `u16`. Returns `None` if the value is too large. */ +export function tryAsU16(options: TryAsU16Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'try_as_u16', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface TryAsU32Arguments { + x: RawTransactionArgument; +} +export interface TryAsU32Options { + package?: string; + arguments: TryAsU32Arguments | [x: RawTransactionArgument]; +} +/** Try to convert a `u64` to a `u32`. Returns `None` if the value is too large. */ +export function tryAsU32(options: TryAsU32Options) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'try_as_u32', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u64', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/u8.ts b/packages/suins/src/contracts/suins_auction/u8.ts new file mode 100644 index 000000000..dd40568fc --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/u8.ts @@ -0,0 +1,204 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +export interface BitwiseNotArguments { + x: RawTransactionArgument; +} +export interface BitwiseNotOptions { + package?: string; + arguments: BitwiseNotArguments | [x: RawTransactionArgument]; +} +/** + * Returns the bitwise not of the value. Each bit that is 1 becomes 0. Each bit + * that is 0 becomes 1. + */ +export function bitwiseNot(options: BitwiseNotOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'bitwise_not', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MaxArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MaxOptions { + package?: string; + arguments: MaxArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the larger of `x` and `y` */ +export function max(options: MaxOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'max', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MinArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface MinOptions { + package?: string; + arguments: MinArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the smaller of `x` and `y` */ +export function min(options: MinOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'min', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DiffArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DiffOptions { + package?: string; + arguments: DiffArguments | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Return the absolute value of x - y */ +export function diff(options: DiffOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'diff', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivideAndRoundUpArguments { + x: RawTransactionArgument; + y: RawTransactionArgument; +} +export interface DivideAndRoundUpOptions { + package?: string; + arguments: + | DivideAndRoundUpArguments + | [x: RawTransactionArgument, y: RawTransactionArgument]; +} +/** Calculate x / y, but round up the result. */ +export function divideAndRoundUp(options: DivideAndRoundUpOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['x', 'y']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'divide_and_round_up', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface PowArguments { + base: RawTransactionArgument; + exponent: RawTransactionArgument; +} +export interface PowOptions { + package?: string; + arguments: + | PowArguments + | [base: RawTransactionArgument, exponent: RawTransactionArgument]; +} +/** Return the value of a base raised to a power */ +export function pow(options: PowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; + const parameterNames = ['base', 'exponent']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'pow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SqrtArguments { + x: RawTransactionArgument; +} +export interface SqrtOptions { + package?: string; + arguments: SqrtArguments | [x: RawTransactionArgument]; +} +/** + * Get a nearest lower integer Square Root for `x`. Given that this function can + * only operate with integers, it is impossible to get perfect (or precise) integer + * square root for some numbers. + * + * Example: + * + * ``` + * math::sqrt(9) => 3 + * math::sqrt(8) => 2 // the nearest lower square root is 4; + * ``` + * + * In integer math, one of the possible ways to get results with more precision is + * to use higher values or temporarily multiply the value by some bigger number. + * Ideally if this is a square of 10 or 100. + * + * Example: + * + * ``` + * math::sqrt(8) => 2; + * math::sqrt(8 * 10000) => 282; + * // now we can use this value as if it was 2.82; + * // but to get the actual result, this value needs + * // to be divided by 100 (because sqrt(10000)). + * + * + * math::sqrt(8 * 1000000) => 2828; // same as above, 2828 / 1000 (2.828) + * ``` + */ +export function sqrt(options: SqrtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'sqrt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToStringArguments { + x: RawTransactionArgument; +} +export interface ToStringOptions { + package?: string; + arguments: ToStringArguments | [x: RawTransactionArgument]; +} +export function toString(options: ToStringOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u8'] satisfies (string | null)[]; + const parameterNames = ['x']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'u8', + function: 'to_string', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/uq32_32.ts b/packages/suins/src/contracts/suins_auction/uq32_32.ts new file mode 100644 index 000000000..6c3878e55 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/uq32_32.ts @@ -0,0 +1,369 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines an unsigned, fixed-point numeric type with a 32-bit integer part and a + * 32-bit fractional part. The notation `uq32_32` and `UQ32_32` is based on + * [Q notation](). `q` indicates + * it a fixed-point number. The `u` prefix indicates it is unsigned. The `32_32` + * suffix indicates the number of bits, where the first number indicates the number + * of bits in the integer part, and the second the number of bits in the fractional + * part--in this case 32 bits for each. + */ + +import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::uq32_32'; +export const UQ32_32 = new MoveTuple({ name: `${$moduleName}::UQ32_32`, fields: [bcs.u64()] }); +export interface FromQuotientArguments { + numerator: RawTransactionArgument; + denominator: RawTransactionArgument; +} +export interface FromQuotientOptions { + package?: string; + arguments: + | FromQuotientArguments + | [ + numerator: RawTransactionArgument, + denominator: RawTransactionArgument, + ]; +} +/** + * Create a fixed-point value from a quotient specified by its numerator and + * denominator. `from_quotient` and `from_int` should be preferred over using + * `from_raw`. Unless the denominator is a power of two, fractions can not be + * represented accurately, so be careful about rounding errors. Aborts if the + * denominator is zero. Aborts if the input is non-zero but so small that it will + * be represented as zero, e.g. smaller than 2^{-32}. Aborts if the input is too + * large, e.g. larger than or equal to 2^32. + */ +export function fromQuotient(options: FromQuotientOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; + const parameterNames = ['numerator', 'denominator']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'from_quotient', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromIntArguments { + integer: RawTransactionArgument; +} +export interface FromIntOptions { + package?: string; + arguments: FromIntArguments | [integer: RawTransactionArgument]; +} +/** + * Create a fixed-point value from an integer. `from_int` and `from_quotient` + * should be preferred over using `from_raw`. + */ +export function fromInt(options: FromIntOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u32'] satisfies (string | null)[]; + const parameterNames = ['integer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'from_int', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface AddOptions { + package?: string; + arguments: AddArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Add two fixed-point numbers, `a + b`. Aborts if the sum overflows. */ +export function add(options: AddOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SubArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface SubOptions { + package?: string; + arguments: SubArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Subtract two fixed-point numbers, `a - b`. Aborts if `a < b`. */ +export function sub(options: SubOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MulArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface MulOptions { + package?: string; + arguments: MulArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** + * Multiply two fixed-point numbers, truncating any fractional part of the product. + * Aborts if the product overflows. + */ +export function mul(options: MulOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface DivOptions { + package?: string; + arguments: DivArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** + * Divide two fixed-point numbers, truncating any fractional part of the quotient. + * Aborts if the divisor is zero. Aborts if the quotient overflows. + */ +export function div(options: DivOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToIntArguments { + a: RawTransactionArgument; +} +export interface ToIntOptions { + package?: string; + arguments: ToIntArguments | [a: RawTransactionArgument]; +} +/** Convert a fixed-point number to an integer, truncating any fractional part. */ +export function toInt(options: ToIntOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'to_int', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntMulArguments { + val: RawTransactionArgument; + multiplier: RawTransactionArgument; +} +export interface IntMulOptions { + package?: string; + arguments: + | IntMulArguments + | [val: RawTransactionArgument, multiplier: RawTransactionArgument]; +} +/** + * Multiply a `u64` integer by a fixed-point number, truncating any fractional part + * of the product. Aborts if the product overflows. + */ +export function intMul(options: IntMulOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', null] satisfies (string | null)[]; + const parameterNames = ['val', 'multiplier']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'int_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntDivArguments { + val: RawTransactionArgument; + divisor: RawTransactionArgument; +} +export interface IntDivOptions { + package?: string; + arguments: + | IntDivArguments + | [val: RawTransactionArgument, divisor: RawTransactionArgument]; +} +/** + * Divide a `u64` integer by a fixed-point number, truncating any fractional part + * of the quotient. Aborts if the divisor is zero. Aborts if the quotient + * overflows. + */ +export function intDiv(options: IntDivOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64', null] satisfies (string | null)[]; + const parameterNames = ['val', 'divisor']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'int_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LeArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface LeOptions { + package?: string; + arguments: LeArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Less than or equal to. Returns `true` if and only if `a <= a`. */ +export function le(options: LeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'le', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LtArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface LtOptions { + package?: string; + arguments: LtArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Less than. Returns `true` if and only if `a < b`. */ +export function lt(options: LtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'lt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GeArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface GeOptions { + package?: string; + arguments: GeArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Greater than or equal to. Returns `true` if and only if `a >= b`. */ +export function ge(options: GeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'ge', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface GtOptions { + package?: string; + arguments: GtArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Greater than. Returns `true` if and only if `a > b`. */ +export function gt(options: GtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'gt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToRawArguments { + a: RawTransactionArgument; +} +export interface ToRawOptions { + package?: string; + arguments: ToRawArguments | [a: RawTransactionArgument]; +} +/** + * Accessor for the raw u64 value. Can be paired with `from_raw` to perform less + * common operations on the raw values directly. + */ +export function toRaw(options: ToRawOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'to_raw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromRawArguments { + rawValue: RawTransactionArgument; +} +export interface FromRawOptions { + package?: string; + arguments: FromRawArguments | [rawValue: RawTransactionArgument]; +} +/** + * Accessor for the raw u64 value. Can be paired with `to_raw` to perform less + * common operations on the raw values directly. + */ +export function fromRaw(options: FromRawOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['rawValue']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq32_32', + function: 'from_raw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/uq64_64.ts b/packages/suins/src/contracts/suins_auction/uq64_64.ts new file mode 100644 index 000000000..a0afaef7e --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/uq64_64.ts @@ -0,0 +1,369 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * Defines an unsigned, fixed-point numeric type with a 64-bit integer part and a + * 64-bit fractional part. The notation `uq64_64` and `UQ64_64` is based on + * [Q notation](). `q` indicates + * it a fixed-point number. The `u` prefix indicates it is unsigned. The `64_64` + * suffix indicates the number of bits, where the first number indicates the number + * of bits in the integer part, and the second the number of bits in the fractional + * part--in this case 64 bits for each. + */ + +import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +import { type Transaction } from '@mysten/sui/transactions'; +const $moduleName = '@suins/auction::uq64_64'; +export const UQ64_64 = new MoveTuple({ name: `${$moduleName}::UQ64_64`, fields: [bcs.u128()] }); +export interface FromQuotientArguments { + numerator: RawTransactionArgument; + denominator: RawTransactionArgument; +} +export interface FromQuotientOptions { + package?: string; + arguments: + | FromQuotientArguments + | [ + numerator: RawTransactionArgument, + denominator: RawTransactionArgument, + ]; +} +/** + * Create a fixed-point value from a quotient specified by its numerator and + * denominator. `from_quotient` and `from_int` should be preferred over using + * `from_raw`. Unless the denominator is a power of two, fractions can not be + * represented accurately, so be careful about rounding errors. Aborts if the + * denominator is zero. Aborts if the input is non-zero but so small that it will + * be represented as zero, e.g. smaller than 2^{-64}. Aborts if the input is too + * large, e.g. larger than or equal to 2^64. + */ +export function fromQuotient(options: FromQuotientOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', 'u128'] satisfies (string | null)[]; + const parameterNames = ['numerator', 'denominator']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'from_quotient', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromIntArguments { + integer: RawTransactionArgument; +} +export interface FromIntOptions { + package?: string; + arguments: FromIntArguments | [integer: RawTransactionArgument]; +} +/** + * Create a fixed-point value from an integer. `from_int` and `from_quotient` + * should be preferred over using `from_raw`. + */ +export function fromInt(options: FromIntOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u64'] satisfies (string | null)[]; + const parameterNames = ['integer']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'from_int', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface AddArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface AddOptions { + package?: string; + arguments: AddArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Add two fixed-point numbers, `a + b`. Aborts if the sum overflows. */ +export function add(options: AddOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'add', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface SubArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface SubOptions { + package?: string; + arguments: SubArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Subtract two fixed-point numbers, `a - b`. Aborts if `a < b`. */ +export function sub(options: SubOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'sub', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface MulArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface MulOptions { + package?: string; + arguments: MulArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** + * Multiply two fixed-point numbers, truncating any fractional part of the product. + * Aborts if the product overflows. + */ +export function mul(options: MulOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface DivArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface DivOptions { + package?: string; + arguments: DivArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** + * Divide two fixed-point numbers, truncating any fractional part of the quotient. + * Aborts if the divisor is zero. Aborts if the quotient overflows. + */ +export function div(options: DivOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToIntArguments { + a: RawTransactionArgument; +} +export interface ToIntOptions { + package?: string; + arguments: ToIntArguments | [a: RawTransactionArgument]; +} +/** Convert a fixed-point number to an integer, truncating any fractional part. */ +export function toInt(options: ToIntOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'to_int', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntMulArguments { + val: RawTransactionArgument; + multiplier: RawTransactionArgument; +} +export interface IntMulOptions { + package?: string; + arguments: + | IntMulArguments + | [val: RawTransactionArgument, multiplier: RawTransactionArgument]; +} +/** + * Multiply a `u128` integer by a fixed-point number, truncating any fractional + * part of the product. Aborts if the product overflows. + */ +export function intMul(options: IntMulOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', null] satisfies (string | null)[]; + const parameterNames = ['val', 'multiplier']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'int_mul', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface IntDivArguments { + val: RawTransactionArgument; + divisor: RawTransactionArgument; +} +export interface IntDivOptions { + package?: string; + arguments: + | IntDivArguments + | [val: RawTransactionArgument, divisor: RawTransactionArgument]; +} +/** + * Divide a `u128` integer by a fixed-point number, truncating any fractional part + * of the quotient. Aborts if the divisor is zero. Aborts if the quotient + * overflows. + */ +export function intDiv(options: IntDivOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128', null] satisfies (string | null)[]; + const parameterNames = ['val', 'divisor']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'int_div', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LeArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface LeOptions { + package?: string; + arguments: LeArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Less than or equal to. Returns `true` if and only if `a <= a`. */ +export function le(options: LeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'le', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface LtArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface LtOptions { + package?: string; + arguments: LtArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Less than. Returns `true` if and only if `a < b`. */ +export function lt(options: LtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'lt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GeArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface GeOptions { + package?: string; + arguments: GeArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Greater than or equal to. Returns `true` if and only if `a >= b`. */ +export function ge(options: GeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'ge', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface GtArguments { + a: RawTransactionArgument; + b: RawTransactionArgument; +} +export interface GtOptions { + package?: string; + arguments: GtArguments | [a: RawTransactionArgument, b: RawTransactionArgument]; +} +/** Greater than. Returns `true` if and only if `a > b`. */ +export function gt(options: GtOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null, null] satisfies (string | null)[]; + const parameterNames = ['a', 'b']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'gt', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface ToRawArguments { + a: RawTransactionArgument; +} +export interface ToRawOptions { + package?: string; + arguments: ToRawArguments | [a: RawTransactionArgument]; +} +/** + * Accessor for the raw u128 value. Can be paired with `from_raw` to perform less + * common operations on the raw values directly. + */ +export function toRaw(options: ToRawOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [null] satisfies (string | null)[]; + const parameterNames = ['a']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'to_raw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} +export interface FromRawArguments { + rawValue: RawTransactionArgument; +} +export interface FromRawOptions { + package?: string; + arguments: FromRawArguments | [rawValue: RawTransactionArgument]; +} +/** + * Accessor for the raw u128 value. Can be paired with `to_raw` to perform less + * common operations on the raw values directly. + */ +export function fromRaw(options: FromRawOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = ['u128'] satisfies (string | null)[]; + const parameterNames = ['rawValue']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'uq64_64', + function: 'from_raw', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + }); +} diff --git a/packages/suins/src/contracts/suins_auction/vector.ts b/packages/suins/src/contracts/suins_auction/vector.ts new file mode 100644 index 000000000..68cdc0017 --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/vector.ts @@ -0,0 +1,548 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** + * A variable-sized container that can hold any type. Indexing is 0-based, and + * vectors are growable. This module has many native functions. + */ + +import { type Transaction } from '@mysten/sui/transactions'; +import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; +import { type BcsType } from '@mysten/sui/bcs'; +export interface EmptyOptions { + package?: string; + arguments?: []; + typeArguments: [string]; +} +/** Create an empty vector. */ +export function empty(options: EmptyOptions) { + const packageAddress = options.package ?? '@suins/auction'; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'empty', + typeArguments: options.typeArguments, + }); +} +export interface LengthArguments> { + v: RawTransactionArgument; +} +export interface LengthOptions> { + package?: string; + arguments: LengthArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return the length of the vector. */ +export function length>(options: LengthOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'length', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowArguments> { + v: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface BorrowOptions> { + package?: string; + arguments: + | BorrowArguments + | [v: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Acquire an immutable reference to the `i`th element of the vector `v`. Aborts if + * `i` is out of bounds. + */ +export function borrow>(options: BorrowOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'borrow', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PushBackArguments> { + v: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface PushBackOptions> { + package?: string; + arguments: + | PushBackArguments + | [v: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Add element `e` to the end of the vector `v`. */ +export function pushBack>(options: PushBackOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['v', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'push_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface BorrowMutArguments> { + v: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface BorrowMutOptions> { + package?: string; + arguments: + | BorrowMutArguments + | [v: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return a mutable reference to the `i`th element in the vector `v`. Aborts if `i` + * is out of bounds. + */ +export function borrowMut>(options: BorrowMutOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'borrow_mut', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface PopBackArguments> { + v: RawTransactionArgument; +} +export interface PopBackOptions> { + package?: string; + arguments: PopBackArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Pop an element from the end of vector `v`. Aborts if `v` is empty. */ +export function popBack>(options: PopBackOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'pop_back', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface DestroyEmptyArguments> { + v: RawTransactionArgument; +} +export interface DestroyEmptyOptions> { + package?: string; + arguments: DestroyEmptyArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Destroy the vector `v`. Aborts if `v` is not empty. */ +export function destroyEmpty>(options: DestroyEmptyOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'destroy_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapArguments> { + v: RawTransactionArgument; + i: RawTransactionArgument; + j: RawTransactionArgument; +} +export interface SwapOptions> { + package?: string; + arguments: + | SwapArguments + | [ + v: RawTransactionArgument, + i: RawTransactionArgument, + j: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Swaps the elements at the `i`th and `j`th indices in the vector `v`. Aborts if + * `i` or `j` is out of bounds. + */ +export function swap>(options: SwapOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64', 'u64'] satisfies ( + | string + | null + )[]; + const parameterNames = ['v', 'i', 'j']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'swap', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SingletonArguments> { + e: RawTransactionArgument; +} +export interface SingletonOptions> { + package?: string; + arguments: SingletonArguments | [e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return an vector of size one containing element `e`. */ +export function singleton>(options: SingletonOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; + const parameterNames = ['e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'singleton', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ReverseArguments> { + v: RawTransactionArgument; +} +export interface ReverseOptions> { + package?: string; + arguments: ReverseArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Reverses the order of the elements in the vector `v` in place. */ +export function reverse>(options: ReverseOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'reverse', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface AppendArguments> { + lhs: RawTransactionArgument; + other: RawTransactionArgument; +} +export interface AppendOptions> { + package?: string; + arguments: + | AppendArguments + | [lhs: RawTransactionArgument, other: RawTransactionArgument]; + typeArguments: [string]; +} +/** Pushes all of the elements of the `other` vector into the `lhs` vector. */ +export function append>(options: AppendOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `vector<${options.typeArguments[0]}>`, + ] satisfies (string | null)[]; + const parameterNames = ['lhs', 'other']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'append', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IsEmptyArguments> { + v: RawTransactionArgument; +} +export interface IsEmptyOptions> { + package?: string; + arguments: IsEmptyArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return `true` if the vector `v` has no elements and `false` otherwise. */ +export function isEmpty>(options: IsEmptyOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'is_empty', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface ContainsArguments> { + v: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface ContainsOptions> { + package?: string; + arguments: + | ContainsArguments + | [v: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** Return true if `e` is in the vector `v`. Otherwise, returns false. */ +export function contains>(options: ContainsOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['v', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'contains', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface IndexOfArguments> { + v: RawTransactionArgument; + e: RawTransactionArgument; +} +export interface IndexOfOptions> { + package?: string; + arguments: + | IndexOfArguments + | [v: RawTransactionArgument, e: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return `(true, i)` if `e` is in the vector `v` at index `i`. Otherwise, returns + * `(false, 0)`. + */ +export function indexOf>(options: IndexOfOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + ] satisfies (string | null)[]; + const parameterNames = ['v', 'e']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'index_of', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface RemoveArguments> { + v: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface RemoveOptions> { + package?: string; + arguments: + | RemoveArguments + | [v: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Remove the `i`th element of the vector `v`, shifting all subsequent elements. + * This is O(n) and preserves ordering of elements in the vector. Aborts if `i` is + * out of bounds. + */ +export function remove>(options: RemoveOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface InsertArguments> { + v: RawTransactionArgument; + e: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface InsertOptions> { + package?: string; + arguments: + | InsertArguments + | [ + v: RawTransactionArgument, + e: RawTransactionArgument, + i: RawTransactionArgument, + ]; + typeArguments: [string]; +} +/** + * Insert `e` at position `i` in the vector `v`. If `i` is in bounds, this shifts + * the old `v[i]` and all subsequent elements to the right. If `i == v.length()`, + * this adds `e` to the end of the vector. This is O(n) and preserves ordering of + * elements in the vector. Aborts if `i > v.length()` + */ +export function insert>(options: InsertOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [ + `vector<${options.typeArguments[0]}>`, + `${options.typeArguments[0]}`, + 'u64', + ] satisfies (string | null)[]; + const parameterNames = ['v', 'e', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'insert', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SwapRemoveArguments> { + v: RawTransactionArgument; + i: RawTransactionArgument; +} +export interface SwapRemoveOptions> { + package?: string; + arguments: + | SwapRemoveArguments + | [v: RawTransactionArgument, i: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Swap the `i`th element of the vector `v` with the last element and then pop the + * vector. This is O(1), but does not preserve ordering of elements in the vector. + * Aborts if `i` is out of bounds. + */ +export function swapRemove>(options: SwapRemoveOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'i']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'swap_remove', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface SkipArguments> { + v: RawTransactionArgument; + n: RawTransactionArgument; +} +export interface SkipOptions> { + package?: string; + arguments: + | SkipArguments + | [v: RawTransactionArgument, n: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Return a new vector containing the elements of `v` except the first `n` + * elements. If `n > length`, returns an empty vector. + */ +export function skip>(options: SkipOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'n']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'skip', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface TakeArguments> { + v: RawTransactionArgument; + n: RawTransactionArgument; +} +export interface TakeOptions> { + package?: string; + arguments: + | TakeArguments + | [v: RawTransactionArgument, n: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Take the first `n` elements of the vector `v` and drop the rest. Aborts if `n` + * is greater than the length of `v`. + */ +export function take>(options: TakeOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector<${options.typeArguments[0]}>`, 'u64'] satisfies (string | null)[]; + const parameterNames = ['v', 'n']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'take', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} +export interface FlattenArguments> { + v: RawTransactionArgument; +} +export interface FlattenOptions> { + package?: string; + arguments: FlattenArguments | [v: RawTransactionArgument]; + typeArguments: [string]; +} +/** + * Concatenate the vectors of `v` into a single vector, keeping the order of the + * elements. + */ +export function flatten>(options: FlattenOptions) { + const packageAddress = options.package ?? '@suins/auction'; + const argumentsTypes = [`vector>`] satisfies ( + | string + | null + )[]; + const parameterNames = ['v']; + return (tx: Transaction) => + tx.moveCall({ + package: packageAddress, + module: 'vector', + function: 'flatten', + arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), + typeArguments: options.typeArguments, + }); +} diff --git a/packages/suins/src/index.ts b/packages/suins/src/index.ts index 3215e8fad..d148412e0 100644 --- a/packages/suins/src/index.ts +++ b/packages/suins/src/index.ts @@ -2,7 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 export { suins, SuinsClient, type SuinsExtensionOptions } from './suins-client.js'; export { SuinsTransaction } from './suins-transaction.js'; -export type { SuinsClientConfig, PackageInfo } from './types.js'; +export { SuinsMarketplaceTransaction } from './suins-marketplace-transaction.js'; +export { + SuinsMarketplaceClient, + type ListingData, + type AuctionData, + type OfferData, + type SealConfig, +} from './suins-marketplace-client.js'; +export type { + SuinsClientConfig, + PackageInfo, + MarketplacePackageInfo, + CreateListingParams, + BuyListingParams, + CancelListingParams, + PlaceOfferParams, + CancelOfferParams, + AcceptOfferParams, + DeclineOfferParams, + MakeCounterOfferParams, + AcceptCounterOfferParams, + CreateAuctionParams, + PlaceBidParams, + FinalizeAuctionParams, + CancelAuctionParams, + SealApproveParams, +} from './types.js'; export { ALLOWED_METADATA, mainPackage } from './constants.js'; export { isSubName, diff --git a/packages/suins/src/suins-marketplace-client.ts b/packages/suins/src/suins-marketplace-client.ts new file mode 100644 index 000000000..dfd6a1930 --- /dev/null +++ b/packages/suins/src/suins-marketplace-client.ts @@ -0,0 +1,362 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import { bcs } from '@mysten/sui/bcs'; +import { normalizeSuiNSName } from '@mysten/sui/utils'; + +import type { SuinsClient } from './suins-client.js'; +import type { MarketplacePackageInfo } from './types.js'; + +// ─── Response Types ─────────────────────────────────────────────── + +export type ListingData = { + /** Object ID of the listing */ + objectId: string; + /** Address of the listing owner */ + owner: string; + /** Listing price in base units */ + price: string; + /** Optional expiration timestamp in seconds */ + expiresAt: string | null; + /** The SuinsRegistration NFT ID held by the listing */ + suinsRegistrationId: string; +}; + +export type AuctionData = { + /** Object ID of the auction */ + objectId: string; + /** Address of the auction owner */ + owner: string; + /** Start time as Unix timestamp in seconds */ + startTime: string; + /** End time as Unix timestamp in seconds */ + endTime: string; + /** Minimum bid amount in base units */ + minBid: string; + /** Whether the auction has an encrypted reserve price */ + hasReservePrice: boolean; + /** Address of the current highest bidder */ + highestBidder: string; + /** Current highest bid value in base units */ + highestBidValue: string; + /** The SuinsRegistration NFT ID held by the auction */ + suinsRegistrationId: string; +}; + +export type OfferData = { + /** Offer value in base units */ + value: string; + /** Counter offer value set by the domain owner (0 if none) */ + counterOffer: string; + /** Optional expiration timestamp in seconds */ + expiresAt: string | null; +}; + +export type SealConfig = { + /** Key server object addresses */ + keyServers: string[]; + /** Public keys for each key server (as hex strings) */ + publicKeys: string[]; + /** Threshold for the vote */ + threshold: number; +}; + +// ─── Marketplace Client ─────────────────────────────────────────── + +/** + * Read-only client for querying marketplace state from on-chain data. + * + * All methods are pure RPC reads — no gas, no signing, no wallet required. + * + * @example + * ```ts + * const suinsClient = new SuinsClient({ client, network: 'testnet' }); + * const marketplace = new SuinsMarketplaceClient(suinsClient); + * + * const listing = await marketplace.getListing('example.sui'); + * const auction = await marketplace.getAuction('example.sui'); + * const sealConfig = await marketplace.getSealConfig(); + * ``` + */ +export class SuinsMarketplaceClient { + suinsClient: SuinsClient; + + constructor(client: SuinsClient) { + this.suinsClient = client; + } + + private get marketplaceConfig(): MarketplacePackageInfo { + const config = this.suinsClient.config.marketplace; + if (!config) { + throw new Error( + 'Marketplace config is not set. Make sure you are using a network that supports marketplace operations.', + ); + } + return config; + } + + // ─── Listings ───────────────────────────────────────────────── + + /** + * Fetches a fixed-price listing for a domain. + * + * Looks up the domain in the OfferTable's `listings` ObjectBag, + * then fetches the child Listing object. + * + * @param domainName - The domain name (e.g. 'example.sui') + * @returns The listing data, or null if no listing exists + */ + async getListing(domainName: string): Promise { + const normalizedName = normalizeSuiNSName(domainName, 'dot'); + + try { + // 1. Get the inner ObjectBag ID for listings + const listingsId = await this.getOfferListingsId(); + if (!listingsId) return null; + + // 2. Look up the child object in the ObjectBag + const domainNameBytes = new TextEncoder().encode(normalizedName); + const nameBcs = bcs.vector(bcs.u8()).serialize(Array.from(domainNameBytes)).toBytes(); + + const result = await this.suinsClient.client.core.getDynamicField({ + parentId: listingsId, + name: { type: 'vector', bcs: nameBcs }, + }); + + if (!result.dynamicField?.value?.bcs) { + return null; + } + + // 3. Fetch the child Listing object content + const objectId = bcs.Address.parse(result.dynamicField.value.bcs); + + const objResult = await this.suinsClient.client.core.getObject({ + objectId, + include: { json: true }, + }); + + if (!objResult.object?.json) { + return null; + } + + return this.parseListingJson(objectId, objResult.object.json); + } catch { + return null; + } + } + + // ─── Auctions ───────────────────────────────────────────────── + + /** + * Fetches an auction for a domain. + * + * Looks up the domain in the AuctionTable's `bag` ObjectBag, + * then fetches the child Auction object. + * + * @param domainName - The domain name (e.g. 'example.sui') + * @returns The auction data, or null if no auction exists + */ + async getAuction(domainName: string): Promise { + const normalizedName = normalizeSuiNSName(domainName, 'dot'); + + try { + const bagId = await this.getAuctionBagId(); + if (!bagId) return null; + + const domainNameBytes = new TextEncoder().encode(normalizedName); + const nameBcs = bcs.vector(bcs.u8()).serialize(Array.from(domainNameBytes)).toBytes(); + + const result = await this.suinsClient.client.core.getDynamicField({ + parentId: bagId, + name: { type: 'vector', bcs: nameBcs }, + }); + + if (!result.dynamicField?.value?.bcs) { + return null; + } + + const objectId = bcs.Address.parse(result.dynamicField.value.bcs); + + const objResult = await this.suinsClient.client.core.getObject({ + objectId, + include: { json: true }, + }); + + if (!objResult.object?.json) { + return null; + } + + return this.parseAuctionJson(objectId, objResult.object.json); + } catch { + return null; + } + } + + // ─── Seal Config ────────────────────────────────────────────── + + /** + * Fetches the Seal encryption configuration from the AuctionTable. + * + * This is needed before encrypting a reserve price for `createAuction` + * or before calling `sealApprove` + `getDerivedKeys` for finalization. + * + * @returns The Seal configuration (key servers, public keys, threshold) + */ + async getSealConfig(): Promise { + const config = this.marketplaceConfig; + + const result = await this.suinsClient.client.core.getObject({ + objectId: config.auctionTableId, + include: { json: true }, + }); + + if (!result.object?.json) { + throw new Error('Failed to fetch AuctionTable'); + } + + const json = result.object.json; + const keyServers = (json.key_servers as string[]) || []; + const publicKeys = (json.public_keys as string[]) || []; + const threshold = Number(json.threshold || 0); + + if (keyServers.length === 0 || publicKeys.length === 0 || threshold === 0) { + throw new Error('Seal configuration not set in AuctionTable'); + } + + return { keyServers, publicKeys, threshold }; + } + + // ─── Service Fee ────────────────────────────────────────────── + + /** + * Fetches the current service fee percentage from the OfferTable. + * + * The fee is expressed in basis points out of 100,000. + * For example, 2,500 = 2.5%. + * + * @returns The service fee as a number + */ + async getOfferServiceFee(): Promise { + const config = this.marketplaceConfig; + + const result = await this.suinsClient.client.core.getObject({ + objectId: config.offerTableId, + include: { json: true }, + }); + + if (!result.object?.json) { + throw new Error('Failed to fetch OfferTable'); + } + + return Number(result.object.json.service_fee || 0); + } + + /** + * Fetches the current service fee percentage from the AuctionTable. + * + * @returns The service fee as a number + */ + async getAuctionServiceFee(): Promise { + const config = this.marketplaceConfig; + + const result = await this.suinsClient.client.core.getObject({ + objectId: config.auctionTableId, + include: { json: true }, + }); + + if (!result.object?.json) { + throw new Error('Failed to fetch AuctionTable'); + } + + return Number(result.object.json.service_fee || 0); + } + + // ─── Helpers ────────────────────────────────────────────────── + + private async getOfferListingsId(): Promise { + const config = this.marketplaceConfig; + const result = await this.suinsClient.client.core.getObject({ + objectId: config.offerTableId, + include: { json: true }, + }); + + if (!result.object?.json) return null; + + const json = result.object.json as Record; + const listings = json.listings as Record | undefined; + const id = (listings?.fields as Record)?.id as + | Record + | undefined; + return id?.id ? String(id.id) : null; + } + + private async getAuctionBagId(): Promise { + const config = this.marketplaceConfig; + const result = await this.suinsClient.client.core.getObject({ + objectId: config.auctionTableId, + include: { json: true }, + }); + + if (!result.object?.json) return null; + + const json = result.object.json as Record; + const bag = json.bag as Record | undefined; + const id = (bag?.fields as Record)?.id as Record | undefined; + return id?.id ? String(id.id) : null; + } + + // ─── Private parsers ────────────────────────────────────────── + + private parseListingJson(objectId: string, json: Record): ListingData { + const expiresAtObj = json.expires_at as Record | null; + let expiresAtValue: string | null = null; + if (expiresAtObj) { + const vec = expiresAtObj.vec as unknown[] | undefined; + if (vec && vec.length > 0) { + expiresAtValue = String(vec[0]); + } + } + + const suinsReg = json.suins_registration as Record | undefined; + const suinsRegId = suinsReg + ? String((suinsReg.id as Record)?.id ?? suinsReg.id ?? '') + : ''; + + return { + objectId, + owner: String(json.owner ?? ''), + price: String(json.price ?? '0'), + expiresAt: expiresAtValue, + suinsRegistrationId: suinsRegId, + }; + } + + private parseAuctionJson(objectId: string, json: Record): AuctionData { + const reservePrice = json.reserve_price as Record | null; + let hasReservePrice = false; + if (reservePrice) { + const vec = reservePrice.vec as unknown[] | undefined; + hasReservePrice = !!vec && vec.length > 0; + } + + const highestBidBalance = json.highest_bid_balance as Record | undefined; + const bidValue = highestBidBalance ? String(highestBidBalance.value ?? '0') : '0'; + + const suinsReg = json.suins_registration as Record | undefined; + const suinsRegId = suinsReg + ? String((suinsReg.id as Record)?.id ?? suinsReg.id ?? '') + : ''; + + return { + objectId, + owner: String(json.owner ?? ''), + startTime: String(json.start_time ?? '0'), + endTime: String(json.end_time ?? '0'), + minBid: String(json.min_bid ?? '0'), + hasReservePrice, + highestBidder: String(json.highest_bidder ?? ''), + highestBidValue: bidValue, + suinsRegistrationId: suinsRegId, + }; + } +} diff --git a/packages/suins/src/suins-marketplace-transaction.ts b/packages/suins/src/suins-marketplace-transaction.ts new file mode 100644 index 000000000..90e08e89d --- /dev/null +++ b/packages/suins/src/suins-marketplace-transaction.ts @@ -0,0 +1,466 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions'; +import { normalizeSuiNSName } from '@mysten/sui/utils'; + +import * as auction from './contracts/suins_auction/auction.js'; +import * as offer from './contracts/suins_auction/offer.js'; +import type { SuinsClient } from './suins-client.js'; +import type { + AcceptCounterOfferParams, + AcceptOfferParams, + BuyListingParams, + CancelAuctionParams, + CancelListingParams, + CancelOfferParams, + CreateAuctionParams, + CreateListingParams, + DeclineOfferParams, + FinalizeAuctionParams, + MakeCounterOfferParams, + PlaceBidParams, + PlaceOfferParams, + SealApproveParams, +} from './types.js'; + +export class SuinsMarketplaceTransaction { + suinsClient: SuinsClient; + transaction: Transaction; + + constructor(client: SuinsClient, transaction: Transaction) { + this.suinsClient = client; + this.transaction = transaction; + + if (!this.suinsClient.config.marketplace) { + throw new Error( + 'Marketplace config not found. Make sure marketplace is configured for your network.', + ); + } + } + + private get marketplaceConfig() { + return this.suinsClient.config.marketplace!; + } + + /** + * Creates a fixed-price listing for a SuiNS domain. + * + * The caller must own the SuinsRegistration NFT being listed. + * The domain must not be expired, and if an expiry is set, + * the domain must not expire before the listing does. + * + * @param params - The listing parameters + * @param params.coinType - The coin type to price the listing in (e.g. '0x2::sui::SUI') + * @param params.price - The fixed price in base units of the coin + * @param params.expiresAt - Optional expiration timestamp in seconds + * @param params.suinsRegistration - The SuinsRegistration NFT to list + */ + createListing(params: CreateListingParams): void { + const config = this.marketplaceConfig; + + this.transaction.add( + offer.createListing({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + price: params.price, + expiresAt: params.expiresAt ?? null, + suinsRegistration: params.suinsRegistration as string, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Buys a listed domain at the fixed listing price. + * + * The payment coin must match the listing price exactly. + * The domain NFT is transferred to the buyer, and the + * payment (minus service fee) goes to the listing owner. + * + * @param params - The buy parameters + * @param params.coinType - The coin type the listing is priced in + * @param params.domainName - The domain name (e.g. 'example.sui') + * @param params.payment - The payment coin object + * @returns The SuinsRegistration NFT as a TransactionObjectArgument + */ + buyListing(params: BuyListingParams): TransactionObjectArgument { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + return this.transaction.add( + offer.buyListing({ + package: config.packageId, + arguments: { + suins: this.suinsClient.config.suins, + offerTable: config.offerTableId, + domainName, + payment: params.payment as string, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Cancels an active listing and returns the domain NFT to the owner. + * + * Only the original listing owner can cancel a listing. + * + * @param params - The cancel parameters + * @param params.coinType - The coin type the listing was created with + * @param params.domainName - The domain name to cancel the listing for + * @returns The SuinsRegistration NFT as a TransactionObjectArgument + */ + cancelListing(params: CancelListingParams): TransactionObjectArgument { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + return this.transaction.add( + offer.cancelListing({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + domainName, + }, + typeArguments: [params.coinType], + }), + ); + } + + // ─── Offers ────────────────────────────────────────────────────── + + /** + * Places an offer on a registered domain. + * + * The domain must exist and not be expired. The caller attaches a payment + * coin as the offer value. An optional expiration timestamp can be set. + * + * @param params.coinType - The coin type for the offer + * @param params.domainName - The domain name to make an offer on + * @param params.coin - The payment coin for the offer + * @param params.expiresAt - Optional expiration timestamp in seconds + */ + placeOffer(params: PlaceOfferParams): void { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + this.transaction.add( + offer.placeOffer({ + package: config.packageId, + arguments: { + suins: this.suinsClient.config.suins, + offerTable: config.offerTableId, + domainName, + coin: params.coin as string, + expiresAt: params.expiresAt ?? null, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Cancels an offer and returns the payment coin to the caller. + * + * Only the original offer maker can cancel their offer. + * + * @param params.coinType - The coin type of the offer + * @param params.domainName - The domain name the offer was placed on + * @returns The refunded coin as a TransactionObjectArgument + */ + cancelOffer(params: CancelOfferParams): TransactionObjectArgument { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + return this.transaction.add( + offer.cancelOffer({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + domainName, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Accepts an offer on a domain the caller owns. + * + * Transfers the SuinsRegistration NFT to the buyer, deducts the service + * fee, and returns the remaining payment to the domain owner. + * + * @param params.coinType - The coin type of the offer + * @param params.suinsRegistration - The SuinsRegistration NFT to transfer + * @param params.buyerAddress - The address of the offer maker + * @returns The payment coin (minus service fee) as a TransactionObjectArgument + */ + acceptOffer(params: AcceptOfferParams): TransactionObjectArgument { + const config = this.marketplaceConfig; + + return this.transaction.add( + offer.acceptOffer({ + package: config.packageId, + arguments: { + suins: this.suinsClient.config.suins, + offerTable: config.offerTableId, + suinsRegistration: params.suinsRegistration as string, + address: params.buyerAddress, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Declines an offer on a domain the caller owns. + * + * Refunds the payment coin to the offer maker. + * + * @param params.coinType - The coin type of the offer + * @param params.suinsRegistration - The SuinsRegistration NFT (read-only) + * @param params.buyerAddress - The address of the offer maker to refund + */ + declineOffer(params: DeclineOfferParams): void { + const config = this.marketplaceConfig; + + this.transaction.add( + offer.declineOffer({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + suinsRegistration: params.suinsRegistration as string, + address: params.buyerAddress, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Makes a counter offer on an existing offer. + * + * The counter offer value must be higher than the current offer. + * Only the domain owner can make a counter offer. + * + * @param params.coinType - The coin type of the original offer + * @param params.suinsRegistration - The SuinsRegistration NFT (read-only) + * @param params.buyerAddress - The address of the original offer maker + * @param params.counterOfferValue - The counter price (must exceed original) + */ + makeCounterOffer(params: MakeCounterOfferParams): void { + const config = this.marketplaceConfig; + + this.transaction.add( + offer.makeCounterOffer({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + suinsRegistration: params.suinsRegistration as string, + address: params.buyerAddress, + counterOfferValue: params.counterOfferValue, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Accepts a counter offer by topping up the payment. + * + * The payment coin must equal `counter_offer_value - original_offer_value`. + * Only the original offer maker can accept the counter offer. + * + * @param params.coinType - The coin type of the counter offer + * @param params.domainName - The domain name + * @param params.coin - The top-up payment coin + */ + acceptCounterOffer(params: AcceptCounterOfferParams): void { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + this.transaction.add( + offer.acceptCounterOffer({ + package: config.packageId, + arguments: { + offerTable: config.offerTableId, + domainName, + coin: params.coin as string, + }, + typeArguments: [params.coinType], + }), + ); + } + + // ─── Auctions ─────────────────────────────────────────────────── + + /** + * Creates a timed auction for a SuiNS domain. + * + * The caller must own the SuinsRegistration NFT. The domain must not expire + * before the auction ends. An optional encrypted reserve price can be set + * using Seal encryption. + * + * @param params.coinType - The coin type for the auction + * @param params.startTime - Auction start time (Unix timestamp in seconds) + * @param params.endTime - Auction end time (Unix timestamp in seconds) + * @param params.minBid - Minimum bid amount in base units of the coin + * @param params.suinsRegistration - The SuinsRegistration NFT to auction + * @param params.encryptedReservePrice - Optional pre-encrypted reserve price bytes + */ + createAuction(params: CreateAuctionParams): void { + const config = this.marketplaceConfig; + + this.transaction.add( + auction.createAuction({ + package: config.packageId, + arguments: { + auctionTable: config.auctionTableId, + startTime: params.startTime, + endTime: params.endTime, + minBid: params.minBid, + encryptedReservePrice: params.encryptedReservePrice + ? Array.from(params.encryptedReservePrice) + : null, + suinsRegistration: params.suinsRegistration as string, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Places a bid on an active auction. + * + * The bid must be at least 5% higher than the current highest bid. + * If the bid is placed within the last 5 minutes, the auction is + * automatically extended. + * + * @param params.coinType - The coin type the auction is denominated in + * @param params.domainName - The domain name being auctioned + * @param params.bid - The bid payment coin + */ + placeBid(params: PlaceBidParams): void { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + this.transaction.add( + auction.placeBid({ + package: config.packageId, + arguments: { + auctionTable: config.auctionTableId, + domainName, + coin: params.bid as string, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Finalizes an auction after its end time has passed. + * + * If the auction has an encrypted reserve price, derived keys and key + * server addresses must be provided for on-chain decryption. + * If the highest bid meets the reserve (or there is no reserve), + * the domain is transferred to the winner and payment to the owner. + * + * @param params.coinType - The coin type the auction is denominated in + * @param params.domainName - The domain name to finalize + * @param params.derivedKeys - Optional Seal derived keys for reserve decryption + * @param params.keyServers - Optional key server addresses for reserve decryption + */ + finalizeAuction(params: FinalizeAuctionParams): void { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + const hasSealData = + params.derivedKeys && + params.keyServers && + params.derivedKeys.length > 0 && + params.keyServers.length > 0; + + this.transaction.add( + auction.finalizeAuction({ + package: config.packageId, + arguments: { + suins: this.suinsClient.config.suins, + auctionTable: config.auctionTableId, + domainName, + derivedKeys: hasSealData ? params.derivedKeys! : null, + keyServers: hasSealData ? params.keyServers! : null, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Cancels an auction before any bids are placed. + * + * Only the original auction owner can cancel. Returns the SuinsRegistration NFT. + * + * @param params.coinType - The coin type the auction is denominated in + * @param params.domainName - The domain name to cancel the auction for + * @returns The SuinsRegistration NFT as a TransactionObjectArgument + */ + cancelAuction(params: CancelAuctionParams): TransactionObjectArgument { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + return this.transaction.add( + auction.cancelAuction({ + package: config.packageId, + arguments: { + auctionTable: config.auctionTableId, + domainName, + }, + typeArguments: [params.coinType], + }), + ); + } + + /** + * Builds the `seal_approve` moveCall used for Seal key derivation. + * + * This is needed when finalizing an auction that has an encrypted reserve + * price. The caller builds a transaction containing this moveCall, then + * passes the transaction bytes to `SealClient.getDerivedKeys()` to obtain + * the derived keys needed for `finalizeAuction`. + * + * The encryption ID is constructed as: BCS(start_time as u64) ++ domain_name_bytes, + * matching the format in `decryption.move::get_encryption_id`. + * + * @param params.coinType - The coin type the auction is denominated in + * @param params.domainName - The domain name being auctioned + * @param params.startTime - The auction start time in seconds + */ + sealApprove(params: SealApproveParams): void { + const config = this.marketplaceConfig; + const domainName = normalizeSuiNSName(params.domainName, 'dot'); + + // Build the encryption ID: BCS-encoded start_time (u64 LE) + domain name bytes + const startTimeBytes = new Uint8Array(8); + const view = new DataView(startTimeBytes.buffer); + view.setBigUint64(0, BigInt(params.startTime), true); // little-endian + + const domainNameBytes = new TextEncoder().encode(domainName); + const encryptionId = new Uint8Array(startTimeBytes.length + domainNameBytes.length); + encryptionId.set(startTimeBytes, 0); + encryptionId.set(domainNameBytes, startTimeBytes.length); + + this.transaction.add( + auction.sealApprove({ + package: config.packageId, + arguments: { + id: Array.from(encryptionId), + auctionTable: config.auctionTableId, + }, + typeArguments: [params.coinType], + }), + ); + } +} diff --git a/packages/suins/src/types.ts b/packages/suins/src/types.ts index ccbc131fa..df487e609 100644 --- a/packages/suins/src/types.ts +++ b/packages/suins/src/types.ts @@ -17,6 +17,13 @@ export interface DiscountInfo { isFreeClaim?: boolean; } +export interface MarketplacePackageInfo { + packageId: string; + originalPackageId: string; + auctionTableId: string; + offerTableId: string; +} + export interface PackageInfo { packageId: string; packageIdV1: string; @@ -47,6 +54,7 @@ export interface PackageInfo { packageId: string; }; coins: Record; + marketplace?: MarketplacePackageInfo; } export interface NameRecord { @@ -107,3 +115,152 @@ export type SuinsClientConfig = { export type SuinsPriceList = Map<[number, number], number>; export type CoinTypeDiscount = Map; + +// Marketplace types +// ----------------- + +export type CreateListingParams = { + /** The coin type to list in (e.g. '0x2::sui::SUI') */ + coinType: string; + /** The fixed price for the listing (in base units of the coin) */ + price: bigint; + /** Optional expiration timestamp in seconds */ + expiresAt?: number; + /** The SuinsRegistration NFT to list */ + suinsRegistration: TransactionObjectInput; +}; + +export type BuyListingParams = { + /** The coin type the listing is priced in */ + coinType: string; + /** The domain name (e.g. 'example.sui') */ + domainName: string; + /** The payment coin (must match the listing price exactly) */ + payment: TransactionObjectInput; +}; + +export type CancelListingParams = { + /** The coin type the listing was created with */ + coinType: string; + /** The domain name to cancel the listing for */ + domainName: string; +}; + +export type PlaceOfferParams = { + /** The coin type for the offer (e.g. '0x2::sui::SUI') */ + coinType: string; + /** The domain name to make an offer on (e.g. 'example.sui') */ + domainName: string; + /** The payment coin for the offer */ + coin: TransactionObjectInput; + /** Optional expiration timestamp in seconds */ + expiresAt?: number; +}; + +export type CancelOfferParams = { + /** The coin type of the offer */ + coinType: string; + /** The domain name the offer was placed on */ + domainName: string; +}; + +export type AcceptOfferParams = { + /** The coin type of the offer being accepted */ + coinType: string; + /** The SuinsRegistration NFT to transfer to the buyer */ + suinsRegistration: TransactionObjectInput; + /** The address of the offer maker (buyer) */ + buyerAddress: string; +}; + +export type DeclineOfferParams = { + /** The coin type of the offer being declined */ + coinType: string; + /** The SuinsRegistration NFT (read-only reference) */ + suinsRegistration: TransactionObjectInput; + /** The address of the offer maker to refund */ + buyerAddress: string; +}; + +export type MakeCounterOfferParams = { + /** The coin type of the original offer */ + coinType: string; + /** The SuinsRegistration NFT (read-only reference) */ + suinsRegistration: TransactionObjectInput; + /** The address of the original offer maker */ + buyerAddress: string; + /** The counter offer value (must be higher than original offer) */ + counterOfferValue: bigint; +}; + +export type AcceptCounterOfferParams = { + /** The coin type of the counter offer */ + coinType: string; + /** The domain name */ + domainName: string; + /** The top-up payment coin (counter_offer_value - original_offer_value) */ + coin: TransactionObjectInput; +}; + +// Auction types +// ------------- + +export type CreateAuctionParams = { + /** The coin type for the auction (e.g. '0x2::sui::SUI') */ + coinType: string; + /** Auction start time as a Unix timestamp in seconds */ + startTime: number; + /** Auction end time as a Unix timestamp in seconds */ + endTime: number; + /** Minimum bid amount in base units of the coin */ + minBid: bigint; + /** The SuinsRegistration NFT to auction */ + suinsRegistration: TransactionObjectInput; + /** + * Optional encrypted reserve price as a byte array (pre-encrypted using Seal). + * If not provided, the auction will have no reserve price. + */ + encryptedReservePrice?: number[] | Uint8Array; +}; + +export type PlaceBidParams = { + /** The coin type the auction is denominated in */ + coinType: string; + /** The domain name being auctioned (e.g. 'example.sui') */ + domainName: string; + /** The bid payment coin */ + bid: TransactionObjectInput; +}; + +export type FinalizeAuctionParams = { + /** The coin type the auction is denominated in */ + coinType: string; + /** The domain name to finalize (e.g. 'example.sui') */ + domainName: string; + /** + * Optional derived keys from Seal key servers for decrypting the reserve price. + * Required only if the auction has an encrypted reserve price. + */ + derivedKeys?: number[][]; + /** + * Optional key server addresses corresponding to the derived keys. + * Required only if the auction has an encrypted reserve price. + */ + keyServers?: string[]; +}; + +export type CancelAuctionParams = { + /** The coin type the auction is denominated in */ + coinType: string; + /** The domain name to cancel the auction for */ + domainName: string; +}; + +export type SealApproveParams = { + /** The coin type the auction is denominated in */ + coinType: string; + /** The domain name being auctioned */ + domainName: string; + /** The auction start time in seconds (must match the on-chain auction) */ + startTime: number; +}; diff --git a/packages/suins/sui-codegen.config.ts b/packages/suins/sui-codegen.config.ts index bdda5ad51..61dfc297e 100644 --- a/packages/suins/sui-codegen.config.ts +++ b/packages/suins/sui-codegen.config.ts @@ -15,6 +15,8 @@ const config: SuiCodegenConfig = { package: '@suins/subdomain-proxy', path: '../../../suins-contracts/packages/temp_subdomain_proxy', }, + // Marketplace (auction/offer/listing) contracts + { package: '@suins/auction', path: '../../../suins-contracts/packages/auction' }, // Pyth - only need State type to get upgrade_cap.package { package: '0xabf837e98c26087cba0883c0a7a28326b1fa3c5e1e2c5abdb486f9e8f594c837', From a01d034876f69b7e27957ee20a6e7f2a50560e36 Mon Sep 17 00:00:00 2001 From: Gabriel Matei Date: Mon, 16 Feb 2026 11:55:03 +0200 Subject: [PATCH 2/3] refactor: regenerated suins_auction files --- .../src/contracts/suins_auction/ascii.ts | 29 +- .../src/contracts/suins_auction/auction.ts | 2 +- .../suins_auction/deps/bridge/bridge.ts | 323 ---- .../suins_auction/deps/bridge/chain_ids.ts | 210 --- .../suins_auction/deps/bridge/committee.ts | 100 -- .../suins_auction/deps/bridge/limiter.ts | 59 - .../suins_auction/deps/bridge/message.ts | 974 ------------ .../deps/bridge/message_types.ts | 82 - .../suins_auction/deps/bridge/treasury.ts | 130 -- .../deps/seal/bf_hmac_encryption.ts | 372 +---- .../suins_auction/deps/seal/key_server.ts | 217 --- .../suins_auction/deps/seal/polynomial.ts | 40 - .../suins_auction/deps/std/type_name.ts | 24 + .../suins_auction/deps/sui/accumulator.ts | 24 - .../deps/sui/accumulator_metadata.ts | 32 - .../deps/sui/accumulator_settlement.ts | 17 - .../suins_auction/deps/sui/address.ts | 189 --- .../deps/sui/authenticator_state.ts | 45 - .../contracts/suins_auction/deps/sui/bag.ts | 273 +--- .../suins_auction/deps/sui/balance.ts | 291 +--- .../contracts/suins_auction/deps/sui/bcs.ts | 683 --------- .../suins_auction/deps/sui/bls12381.ts | 929 ------------ .../suins_auction/deps/sui/borrow.ts | 133 -- .../contracts/suins_auction/deps/sui/clock.ts | 46 - .../contracts/suins_auction/deps/sui/coin.ts | 1348 ----------------- .../suins_auction/deps/sui/coin_registry.ts | 1236 --------------- .../suins_auction/deps/sui/config.ts | 30 - .../suins_auction/deps/sui/deny_list.ts | 67 - .../suins_auction/deps/sui/derived_object.ts | 140 -- .../suins_auction/deps/sui/display.ts | 349 ----- .../suins_auction/deps/sui/dynamic_field.ts | 273 ---- .../deps/sui/dynamic_object_field.ts | 261 ---- .../suins_auction/deps/sui/ecdsa_k1.ts | 115 -- .../suins_auction/deps/sui/ecdsa_r1.ts | 91 -- .../contracts/suins_auction/deps/sui/ecvrf.ts | 46 - .../suins_auction/deps/sui/ed25519.ts | 40 - .../contracts/suins_auction/deps/sui/event.ts | 94 -- .../deps/sui/funds_accumulator.ts | 130 -- .../suins_auction/deps/sui/groth16.ts | 244 --- .../suins_auction/deps/sui/group_ops.ts | 52 +- .../contracts/suins_auction/deps/sui/hash.ts | 57 - .../contracts/suins_auction/deps/sui/hex.ts | 55 - .../contracts/suins_auction/deps/sui/hmac.ts | 31 - .../contracts/suins_auction/deps/sui/kiosk.ts | 1222 --------------- .../suins_auction/deps/sui/kiosk_extension.ts | 467 ------ .../suins_auction/deps/sui/linked_table.ts | 512 ------- .../contracts/suins_auction/deps/sui/math.ts | 166 -- .../deps/sui/nitro_attestation.ts | 247 --- .../suins_auction/deps/sui/object.ts | 317 ---- .../suins_auction/deps/sui/object_bag.ts | 301 +--- .../suins_auction/deps/sui/object_table.ts | 297 ---- .../suins_auction/deps/sui/package.ts | 572 ------- .../contracts/suins_auction/deps/sui/party.ts | 52 - .../contracts/suins_auction/deps/sui/pay.ts | 228 --- .../suins_auction/deps/sui/poseidon.ts | 47 - .../suins_auction/deps/sui/priority_queue.ts | 185 --- .../suins_auction/deps/sui/random.ts | 392 ----- .../contracts/suins_auction/deps/sui/sui.ts | 45 - .../contracts/suins_auction/deps/sui/table.ts | 272 +--- .../suins_auction/deps/sui/table_vec.ts | 316 ---- .../contracts/suins_auction/deps/sui/token.ts | 1302 ---------------- .../suins_auction/deps/sui/transfer.ts | 358 ----- .../suins_auction/deps/sui/transfer_policy.ts | 602 -------- .../suins_auction/deps/sui/tx_context.ts | 150 -- .../contracts/suins_auction/deps/sui/types.ts | 34 - .../contracts/suins_auction/deps/sui/url.ts | 106 -- .../contracts/suins_auction/deps/sui/vdf.ts | 79 - .../suins_auction/deps/sui/vec_map.ts | 568 ------- .../suins_auction/deps/sui/vec_set.ts | 281 ---- .../suins_auction/deps/sui/versioned.ts | 205 --- .../deps/sui/zklogin_verified_id.ts | 234 --- .../deps/sui/zklogin_verified_issuer.ts | 145 -- .../suins_auction/deps/sui_system/genesis.ts | 64 - .../deps/sui_system/stake_subsidy.ts | 56 - .../deps/sui_system/staking_pool.ts | 521 ------- .../deps/sui_system/storage_fund.ts | 56 - .../deps/sui_system/sui_system.ts | 1204 --------------- .../deps/sui_system/sui_system_state_inner.ts | 212 --- .../deps/sui_system/validator.ts | 870 ----------- .../deps/sui_system/validator_cap.ts | 19 - .../deps/sui_system/validator_set.ts | 426 ------ .../deps/sui_system/validator_wrapper.ts | 12 - .../deps/sui_system/voting_power.ts | 50 - .../suins_auction/deps/suins/admin.ts | 118 -- .../suins_auction/deps/suins/auction.ts | 345 ----- .../suins_auction/deps/suins/config.ts | 229 --- .../suins_auction/deps/suins/constants.ts | 167 -- .../suins_auction/deps/suins/controller.ts | 269 ---- .../suins_auction/deps/suins/core_config.ts | 212 --- .../suins_auction/deps/suins/domain.ts | 208 +-- .../suins_auction/deps/suins/name_record.ts | 319 ---- .../suins_auction/deps/suins/payment.ts | 444 ------ .../deps/suins/pricing_config.ts | 190 --- .../suins_auction/deps/suins/registry.ts | 518 ------- .../deps/suins/subdomain_registration.ts | 67 - .../suins_auction/deps/suins/suins.ts | 460 ------ .../deps/suins/suins_registration.ts | 177 +-- .../suins_auction/deps/suins/update_image.ts | 15 - .../src/contracts/suins_auction/offer.ts | 2 +- .../src/contracts/suins_auction/option.ts | 183 +-- .../src/contracts/suins_auction/string.ts | 29 +- .../src/contracts/suins_auction/type_name.ts | 4 +- 102 files changed, 137 insertions(+), 26894 deletions(-) delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/message.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts create mode 100644 packages/suins/src/contracts/suins_auction/deps/std/type_name.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/address.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/clock.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/coin.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/config.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/display.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/event.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hash.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hex.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/math.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/object.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/package.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/party.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/pay.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/random.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/sui.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/token.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/types.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/url.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/admin.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/auction.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/config.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/constants.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/controller.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/payment.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/registry.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/suins.ts delete mode 100644 packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts diff --git a/packages/suins/src/contracts/suins_auction/ascii.ts b/packages/suins/src/contracts/suins_auction/ascii.ts index a0e867e1c..7faaa5cfe 100644 --- a/packages/suins/src/contracts/suins_auction/ascii.ts +++ b/packages/suins/src/contracts/suins_auction/ascii.ts @@ -104,7 +104,7 @@ export interface AllCharactersPrintableOptions { */ export function allCharactersPrintable(options: AllCharactersPrintableOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -127,7 +127,7 @@ export interface PushCharOptions { /** Push a `Char` to the end of the `string`. */ export function pushChar(options: PushCharOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', null] satisfies (string | null)[]; + const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['string', 'char']; return (tx: Transaction) => tx.moveCall({ @@ -147,7 +147,7 @@ export interface PopCharOptions { /** Pop a `Char` from the end of the `string`. */ export function popChar(options: PopCharOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -167,7 +167,7 @@ export interface LengthOptions { /** Returns the length of the `string` in bytes. */ export function length(options: LengthOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -190,7 +190,7 @@ export interface AppendOptions { /** Append the `other` string to the end of `string`. */ export function append(options: AppendOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['string', 'other']; return (tx: Transaction) => tx.moveCall({ @@ -218,10 +218,7 @@ export interface InsertOptions { /** Insert the `other` string at the `at` index of `string`. */ export function insert(options: InsertOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'u64', '0x1::string::String'] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null, 'u64', null] satisfies (string | null)[]; const parameterNames = ['s', 'at', 'o']; return (tx: Transaction) => tx.moveCall({ @@ -249,7 +246,7 @@ export interface SubstringOptions { /** Copy the slice of the `string` from `i` to `j` into a new `String`. */ export function substring(options: SubstringOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; const parameterNames = ['string', 'i', 'j']; return (tx: Transaction) => tx.moveCall({ @@ -269,7 +266,7 @@ export interface AsBytesOptions { /** Get the inner bytes of the `string` as a reference */ export function asBytes(options: AsBytesOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -289,7 +286,7 @@ export interface IntoBytesOptions { /** Unpack the `string` to get its backing bytes */ export function intoBytes(options: IntoBytesOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -372,7 +369,7 @@ export interface IsEmptyOptions { /** Returns `true` if `string` is empty. */ export function isEmpty(options: IsEmptyOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -392,7 +389,7 @@ export interface ToUppercaseOptions { /** Convert a `string` to its uppercase equivalent. */ export function toUppercase(options: ToUppercaseOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -412,7 +409,7 @@ export interface ToLowercaseOptions { /** Convert a `string` to its lowercase equivalent. */ export function toLowercase(options: ToLowercaseOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['string']; return (tx: Transaction) => tx.moveCall({ @@ -439,7 +436,7 @@ export interface IndexOfOptions { */ export function indexOf(options: IndexOfOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['string', 'substr']; return (tx: Transaction) => tx.moveCall({ diff --git a/packages/suins/src/contracts/suins_auction/auction.ts b/packages/suins/src/contracts/suins_auction/auction.ts index a3e5713a0..3a1543daa 100644 --- a/packages/suins/src/contracts/suins_auction/auction.ts +++ b/packages/suins/src/contracts/suins_auction/auction.ts @@ -10,7 +10,7 @@ import * as suins_registration from './deps/suins/suins_registration.js'; import * as object_bag from './deps/sui/object_bag.js'; import * as table from './deps/sui/table.js'; import * as bag from './deps/sui/bag.js'; -import * as type_name from './type_name.js'; +import * as type_name from './deps/std/type_name.js'; const $moduleName = '@suins/auction::auction'; export const AuctionWitness = new MoveStruct({ name: `${$moduleName}::AuctionWitness`, diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts deleted file mode 100644 index cfb17f5f0..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/bridge.ts +++ /dev/null @@ -1,323 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as versioned from '../sui/versioned.js'; -import * as vec_map from '../sui/vec_map.js'; -import * as committee from './committee.js'; -import * as treasury from './treasury.js'; -import * as linked_table from '../sui/linked_table.js'; -import * as message from './message.js'; -import * as limiter from './limiter.js'; -const $moduleName = 'bridge::bridge'; -export const Bridge = new MoveStruct({ - name: `${$moduleName}::Bridge`, - fields: { - id: bcs.Address, - inner: versioned.Versioned, - }, -}); -export const BridgeInner = new MoveStruct({ - name: `${$moduleName}::BridgeInner`, - fields: { - bridge_version: bcs.u64(), - message_version: bcs.u8(), - chain_id: bcs.u8(), - sequence_nums: vec_map.VecMap(bcs.u8(), bcs.u64()), - committee: committee.BridgeCommittee, - treasury: treasury.BridgeTreasury, - token_transfer_records: linked_table.LinkedTable(message.BridgeMessageKey), - limiter: limiter.TransferLimiter, - paused: bcs.bool(), - }, -}); -export const TokenDepositedEvent = new MoveStruct({ - name: `${$moduleName}::TokenDepositedEvent`, - fields: { - seq_num: bcs.u64(), - source_chain: bcs.u8(), - sender_address: bcs.vector(bcs.u8()), - target_chain: bcs.u8(), - target_address: bcs.vector(bcs.u8()), - token_type: bcs.u8(), - amount: bcs.u64(), - }, -}); -export const EmergencyOpEvent = new MoveStruct({ - name: `${$moduleName}::EmergencyOpEvent`, - fields: { - frozen: bcs.bool(), - }, -}); -export const BridgeRecord = new MoveStruct({ - name: `${$moduleName}::BridgeRecord`, - fields: { - message: message.BridgeMessage, - verified_signatures: bcs.option(bcs.vector(bcs.vector(bcs.u8()))), - claimed: bcs.bool(), - }, -}); -export const TokenTransferApproved = new MoveStruct({ - name: `${$moduleName}::TokenTransferApproved`, - fields: { - message_key: message.BridgeMessageKey, - }, -}); -export const TokenTransferClaimed = new MoveStruct({ - name: `${$moduleName}::TokenTransferClaimed`, - fields: { - message_key: message.BridgeMessageKey, - }, -}); -export const TokenTransferAlreadyApproved = new MoveStruct({ - name: `${$moduleName}::TokenTransferAlreadyApproved`, - fields: { - message_key: message.BridgeMessageKey, - }, -}); -export const TokenTransferAlreadyClaimed = new MoveStruct({ - name: `${$moduleName}::TokenTransferAlreadyClaimed`, - fields: { - message_key: message.BridgeMessageKey, - }, -}); -export const TokenTransferLimitExceed = new MoveStruct({ - name: `${$moduleName}::TokenTransferLimitExceed`, - fields: { - message_key: message.BridgeMessageKey, - }, -}); -export interface CommitteeRegistrationArguments { - bridge: RawTransactionArgument; - bridgePubkeyBytes: RawTransactionArgument; - httpRestUrl: RawTransactionArgument; -} -export interface CommitteeRegistrationOptions { - package: string; - arguments: - | CommitteeRegistrationArguments - | [ - bridge: RawTransactionArgument, - bridgePubkeyBytes: RawTransactionArgument, - httpRestUrl: RawTransactionArgument, - ]; -} -export function committeeRegistration(options: CommitteeRegistrationOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - '0x3::sui_system::SuiSystemState', - 'vector', - 'vector', - ] satisfies (string | null)[]; - const parameterNames = ['bridge', 'bridgePubkeyBytes', 'httpRestUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'committee_registration', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateNodeUrlArguments { - bridge: RawTransactionArgument; - newUrl: RawTransactionArgument; -} -export interface UpdateNodeUrlOptions { - package: string; - arguments: - | UpdateNodeUrlArguments - | [bridge: RawTransactionArgument, newUrl: RawTransactionArgument]; -} -export function updateNodeUrl(options: UpdateNodeUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; - const parameterNames = ['bridge', 'newUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'update_node_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RegisterForeignTokenArguments { - bridge: RawTransactionArgument; - tc: RawTransactionArgument; - uc: RawTransactionArgument; - metadata: RawTransactionArgument; -} -export interface RegisterForeignTokenOptions { - package: string; - arguments: - | RegisterForeignTokenArguments - | [ - bridge: RawTransactionArgument, - tc: RawTransactionArgument, - uc: RawTransactionArgument, - metadata: RawTransactionArgument, - ]; - typeArguments: [string]; -} -export function registerForeignToken(options: RegisterForeignTokenOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null, null] satisfies (string | null)[]; - const parameterNames = ['bridge', 'tc', 'uc', 'metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'register_foreign_token', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SendTokenArguments { - bridge: RawTransactionArgument; - targetChain: RawTransactionArgument; - targetAddress: RawTransactionArgument; - token: RawTransactionArgument; -} -export interface SendTokenOptions { - package: string; - arguments: - | SendTokenArguments - | [ - bridge: RawTransactionArgument, - targetChain: RawTransactionArgument, - targetAddress: RawTransactionArgument, - token: RawTransactionArgument, - ]; - typeArguments: [string]; -} -export function sendToken(options: SendTokenOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8', 'vector', null] satisfies (string | null)[]; - const parameterNames = ['bridge', 'targetChain', 'targetAddress', 'token']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'send_token', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ApproveTokenTransferArguments { - bridge: RawTransactionArgument; - message: RawTransactionArgument; - signatures: RawTransactionArgument; -} -export interface ApproveTokenTransferOptions { - package: string; - arguments: - | ApproveTokenTransferArguments - | [ - bridge: RawTransactionArgument, - message: RawTransactionArgument, - signatures: RawTransactionArgument, - ]; -} -export function approveTokenTransfer(options: ApproveTokenTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; - const parameterNames = ['bridge', 'message', 'signatures']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'approve_token_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ClaimTokenArguments { - bridge: RawTransactionArgument; - sourceChain: RawTransactionArgument; - bridgeSeqNum: RawTransactionArgument; -} -export interface ClaimTokenOptions { - package: string; - arguments: - | ClaimTokenArguments - | [ - bridge: RawTransactionArgument, - sourceChain: RawTransactionArgument, - bridgeSeqNum: RawTransactionArgument, - ]; - typeArguments: [string]; -} -export function claimToken(options: ClaimTokenOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock', 'u8', 'u64'] satisfies (string | null)[]; - const parameterNames = ['bridge', 'sourceChain', 'bridgeSeqNum']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'claim_token', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ClaimAndTransferTokenArguments { - bridge: RawTransactionArgument; - sourceChain: RawTransactionArgument; - bridgeSeqNum: RawTransactionArgument; -} -export interface ClaimAndTransferTokenOptions { - package: string; - arguments: - | ClaimAndTransferTokenArguments - | [ - bridge: RawTransactionArgument, - sourceChain: RawTransactionArgument, - bridgeSeqNum: RawTransactionArgument, - ]; - typeArguments: [string]; -} -export function claimAndTransferToken(options: ClaimAndTransferTokenOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock', 'u8', 'u64'] satisfies (string | null)[]; - const parameterNames = ['bridge', 'sourceChain', 'bridgeSeqNum']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'claim_and_transfer_token', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ExecuteSystemMessageArguments { - bridge: RawTransactionArgument; - message: RawTransactionArgument; - signatures: RawTransactionArgument; -} -export interface ExecuteSystemMessageOptions { - package: string; - arguments: - | ExecuteSystemMessageArguments - | [ - bridge: RawTransactionArgument, - message: RawTransactionArgument, - signatures: RawTransactionArgument, - ]; -} -export function executeSystemMessage(options: ExecuteSystemMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; - const parameterNames = ['bridge', 'message', 'signatures']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bridge', - function: 'execute_system_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts deleted file mode 100644 index f14f62868..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/chain_ids.ts +++ /dev/null @@ -1,210 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'bridge::chain_ids'; -export const BridgeRoute = new MoveStruct({ - name: `${$moduleName}::BridgeRoute`, - fields: { - source: bcs.u8(), - destination: bcs.u8(), - }, -}); -export interface SuiMainnetOptions { - package: string; - arguments?: []; -} -export function suiMainnet(options: SuiMainnetOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'sui_mainnet', - }); -} -export interface SuiTestnetOptions { - package: string; - arguments?: []; -} -export function suiTestnet(options: SuiTestnetOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'sui_testnet', - }); -} -export interface SuiCustomOptions { - package: string; - arguments?: []; -} -export function suiCustom(options: SuiCustomOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'sui_custom', - }); -} -export interface EthMainnetOptions { - package: string; - arguments?: []; -} -export function ethMainnet(options: EthMainnetOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'eth_mainnet', - }); -} -export interface EthSepoliaOptions { - package: string; - arguments?: []; -} -export function ethSepolia(options: EthSepoliaOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'eth_sepolia', - }); -} -export interface EthCustomOptions { - package: string; - arguments?: []; -} -export function ethCustom(options: EthCustomOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'eth_custom', - }); -} -export interface RouteSourceArguments { - route: RawTransactionArgument; -} -export interface RouteSourceOptions { - package: string; - arguments: RouteSourceArguments | [route: RawTransactionArgument]; -} -export function routeSource(options: RouteSourceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['route']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'route_source', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RouteDestinationArguments { - route: RawTransactionArgument; -} -export interface RouteDestinationOptions { - package: string; - arguments: RouteDestinationArguments | [route: RawTransactionArgument]; -} -export function routeDestination(options: RouteDestinationOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['route']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'route_destination', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AssertValidChainIdArguments { - id: RawTransactionArgument; -} -export interface AssertValidChainIdOptions { - package: string; - arguments: AssertValidChainIdArguments | [id: RawTransactionArgument]; -} -export function assertValidChainId(options: AssertValidChainIdOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8'] satisfies (string | null)[]; - const parameterNames = ['id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'assert_valid_chain_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidRoutesOptions { - package: string; - arguments?: []; -} -export function validRoutes(options: ValidRoutesOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'valid_routes', - }); -} -export interface IsValidRouteArguments { - source: RawTransactionArgument; - destination: RawTransactionArgument; -} -export interface IsValidRouteOptions { - package: string; - arguments: - | IsValidRouteArguments - | [source: RawTransactionArgument, destination: RawTransactionArgument]; -} -export function isValidRoute(options: IsValidRouteOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; - const parameterNames = ['source', 'destination']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'is_valid_route', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GetRouteArguments { - source: RawTransactionArgument; - destination: RawTransactionArgument; -} -export interface GetRouteOptions { - package: string; - arguments: - | GetRouteArguments - | [source: RawTransactionArgument, destination: RawTransactionArgument]; -} -export function getRoute(options: GetRouteOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u8'] satisfies (string | null)[]; - const parameterNames = ['source', 'destination']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'chain_ids', - function: 'get_route', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts deleted file mode 100644 index 7ec9572fa..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/committee.ts +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from '../sui/vec_map.js'; -const $moduleName = 'bridge::committee'; -export const CommitteeMember = new MoveStruct({ - name: `${$moduleName}::CommitteeMember`, - fields: { - /** The Sui Address of the validator */ - sui_address: bcs.Address, - /** The public key bytes of the bridge key */ - bridge_pubkey_bytes: bcs.vector(bcs.u8()), - /** Voting power, values are voting power in the scale of 10000. */ - voting_power: bcs.u64(), - /** - * The HTTP REST URL the member's node listens to it looks like - * b'https://127.0.0.1:9191' - */ - http_rest_url: bcs.vector(bcs.u8()), - /** If this member is blocklisted */ - blocklisted: bcs.bool(), - }, -}); -export const CommitteeMemberRegistration = new MoveStruct({ - name: `${$moduleName}::CommitteeMemberRegistration`, - fields: { - /** The Sui Address of the validator */ - sui_address: bcs.Address, - /** The public key bytes of the bridge key */ - bridge_pubkey_bytes: bcs.vector(bcs.u8()), - /** - * The HTTP REST URL the member's node listens to it looks like - * b'https://127.0.0.1:9191' - */ - http_rest_url: bcs.vector(bcs.u8()), - }, -}); -export const BridgeCommittee = new MoveStruct({ - name: `${$moduleName}::BridgeCommittee`, - fields: { - members: vec_map.VecMap(bcs.vector(bcs.u8()), CommitteeMember), - member_registrations: vec_map.VecMap(bcs.Address, CommitteeMemberRegistration), - last_committee_update_epoch: bcs.u64(), - }, -}); -export const BlocklistValidatorEvent = new MoveStruct({ - name: `${$moduleName}::BlocklistValidatorEvent`, - fields: { - blocklisted: bcs.bool(), - public_keys: bcs.vector(bcs.vector(bcs.u8())), - }, -}); -export const CommitteeUpdateEvent = new MoveStruct({ - name: `${$moduleName}::CommitteeUpdateEvent`, - fields: { - members: vec_map.VecMap(bcs.vector(bcs.u8()), CommitteeMember), - stake_participation_percentage: bcs.u64(), - }, -}); -export const CommitteeMemberUrlUpdateEvent = new MoveStruct({ - name: `${$moduleName}::CommitteeMemberUrlUpdateEvent`, - fields: { - member: bcs.vector(bcs.u8()), - new_url: bcs.vector(bcs.u8()), - }, -}); -export interface VerifySignaturesArguments { - self: RawTransactionArgument; - message: RawTransactionArgument; - signatures: RawTransactionArgument; -} -export interface VerifySignaturesOptions { - package: string; - arguments: - | VerifySignaturesArguments - | [ - self: RawTransactionArgument, - message: RawTransactionArgument, - signatures: RawTransactionArgument, - ]; -} -export function verifySignatures(options: VerifySignaturesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'vector>'] satisfies (string | null)[]; - const parameterNames = ['self', 'message', 'signatures']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'committee', - function: 'verify_signatures', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts deleted file mode 100644 index a858a9abd..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/limiter.ts +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from '../sui/vec_map.js'; -import * as chain_ids from './chain_ids.js'; -const $moduleName = 'bridge::limiter'; -export const TransferRecord = new MoveStruct({ - name: `${$moduleName}::TransferRecord`, - fields: { - hour_head: bcs.u64(), - hour_tail: bcs.u64(), - per_hour_amounts: bcs.vector(bcs.u64()), - total_amount: bcs.u64(), - }, -}); -export const TransferLimiter = new MoveStruct({ - name: `${$moduleName}::TransferLimiter`, - fields: { - transfer_limits: vec_map.VecMap(chain_ids.BridgeRoute, bcs.u64()), - transfer_records: vec_map.VecMap(chain_ids.BridgeRoute, TransferRecord), - }, -}); -export const UpdateRouteLimitEvent = new MoveStruct({ - name: `${$moduleName}::UpdateRouteLimitEvent`, - fields: { - sending_chain: bcs.u8(), - receiving_chain: bcs.u8(), - new_limit: bcs.u64(), - }, -}); -export interface GetRouteLimitArguments { - self: RawTransactionArgument; - route: RawTransactionArgument; -} -export interface GetRouteLimitOptions { - package: string; - arguments: - | GetRouteLimitArguments - | [self: RawTransactionArgument, route: RawTransactionArgument]; -} -export function getRouteLimit(options: GetRouteLimitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'route']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'limiter', - function: 'get_route_limit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts deleted file mode 100644 index 17bee3ca6..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/message.ts +++ /dev/null @@ -1,974 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'bridge::message'; -export const BridgeMessageKey = new MoveStruct({ - name: `${$moduleName}::BridgeMessageKey`, - fields: { - source_chain: bcs.u8(), - message_type: bcs.u8(), - bridge_seq_num: bcs.u64(), - }, -}); -export const BridgeMessage = new MoveStruct({ - name: `${$moduleName}::BridgeMessage`, - fields: { - message_type: bcs.u8(), - message_version: bcs.u8(), - seq_num: bcs.u64(), - source_chain: bcs.u8(), - payload: bcs.vector(bcs.u8()), - }, -}); -export const TokenTransferPayload = new MoveStruct({ - name: `${$moduleName}::TokenTransferPayload`, - fields: { - sender_address: bcs.vector(bcs.u8()), - target_chain: bcs.u8(), - target_address: bcs.vector(bcs.u8()), - token_type: bcs.u8(), - amount: bcs.u64(), - }, -}); -export const EmergencyOp = new MoveStruct({ - name: `${$moduleName}::EmergencyOp`, - fields: { - op_type: bcs.u8(), - }, -}); -export const Blocklist = new MoveStruct({ - name: `${$moduleName}::Blocklist`, - fields: { - blocklist_type: bcs.u8(), - validator_eth_addresses: bcs.vector(bcs.vector(bcs.u8())), - }, -}); -export const UpdateBridgeLimit = new MoveStruct({ - name: `${$moduleName}::UpdateBridgeLimit`, - fields: { - receiving_chain: bcs.u8(), - sending_chain: bcs.u8(), - limit: bcs.u64(), - }, -}); -export const UpdateAssetPrice = new MoveStruct({ - name: `${$moduleName}::UpdateAssetPrice`, - fields: { - token_id: bcs.u8(), - new_price: bcs.u64(), - }, -}); -export const AddTokenOnSui = new MoveStruct({ - name: `${$moduleName}::AddTokenOnSui`, - fields: { - native_token: bcs.bool(), - token_ids: bcs.vector(bcs.u8()), - token_type_names: bcs.vector(bcs.string()), - token_prices: bcs.vector(bcs.u64()), - }, -}); -export const ParsedTokenTransferMessage = new MoveStruct({ - name: `${$moduleName}::ParsedTokenTransferMessage`, - fields: { - message_version: bcs.u8(), - seq_num: bcs.u64(), - source_chain: bcs.u8(), - payload: bcs.vector(bcs.u8()), - parsed_payload: TokenTransferPayload, - }, -}); -export interface ExtractTokenBridgePayloadArguments { - message: RawTransactionArgument; -} -export interface ExtractTokenBridgePayloadOptions { - package: string; - arguments: ExtractTokenBridgePayloadArguments | [message: RawTransactionArgument]; -} -export function extractTokenBridgePayload(options: ExtractTokenBridgePayloadOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_token_bridge_payload', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExtractEmergencyOpPayloadArguments { - message: RawTransactionArgument; -} -export interface ExtractEmergencyOpPayloadOptions { - package: string; - arguments: ExtractEmergencyOpPayloadArguments | [message: RawTransactionArgument]; -} -/** Emergency op payload is just a single byte */ -export function extractEmergencyOpPayload(options: ExtractEmergencyOpPayloadOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_emergency_op_payload', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExtractBlocklistPayloadArguments { - message: RawTransactionArgument; -} -export interface ExtractBlocklistPayloadOptions { - package: string; - arguments: ExtractBlocklistPayloadArguments | [message: RawTransactionArgument]; -} -export function extractBlocklistPayload(options: ExtractBlocklistPayloadOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_blocklist_payload', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExtractUpdateBridgeLimitArguments { - message: RawTransactionArgument; -} -export interface ExtractUpdateBridgeLimitOptions { - package: string; - arguments: ExtractUpdateBridgeLimitArguments | [message: RawTransactionArgument]; -} -export function extractUpdateBridgeLimit(options: ExtractUpdateBridgeLimitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_update_bridge_limit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExtractUpdateAssetPriceArguments { - message: RawTransactionArgument; -} -export interface ExtractUpdateAssetPriceOptions { - package: string; - arguments: ExtractUpdateAssetPriceArguments | [message: RawTransactionArgument]; -} -export function extractUpdateAssetPrice(options: ExtractUpdateAssetPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_update_asset_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExtractAddTokensOnSuiArguments { - message: RawTransactionArgument; -} -export interface ExtractAddTokensOnSuiOptions { - package: string; - arguments: ExtractAddTokensOnSuiArguments | [message: RawTransactionArgument]; -} -export function extractAddTokensOnSui(options: ExtractAddTokensOnSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'extract_add_tokens_on_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SerializeMessageArguments { - message: RawTransactionArgument; -} -export interface SerializeMessageOptions { - package: string; - arguments: SerializeMessageArguments | [message: RawTransactionArgument]; -} -export function serializeMessage(options: SerializeMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'serialize_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateTokenBridgeMessageArguments { - sourceChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - senderAddress: RawTransactionArgument; - targetChain: RawTransactionArgument; - targetAddress: RawTransactionArgument; - tokenType: RawTransactionArgument; - amount: RawTransactionArgument; -} -export interface CreateTokenBridgeMessageOptions { - package: string; - arguments: - | CreateTokenBridgeMessageArguments - | [ - sourceChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - senderAddress: RawTransactionArgument, - targetChain: RawTransactionArgument, - targetAddress: RawTransactionArgument, - tokenType: RawTransactionArgument, - amount: RawTransactionArgument, - ]; -} -/** - * Token Transfer Message Format: [message_type: u8] [version:u8] [nonce:u64] - * [source_chain: u8] [sender_address_length:u8] [sender_address: byte[]] - * [target_chain:u8] [target_address_length:u8] [target_address: byte[]] - * [token_type:u8] [amount:u64] - */ -export function createTokenBridgeMessage(options: CreateTokenBridgeMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u64', 'vector', 'u8', 'vector', 'u8', 'u64'] satisfies ( - | string - | null - )[]; - const parameterNames = [ - 'sourceChain', - 'seqNum', - 'senderAddress', - 'targetChain', - 'targetAddress', - 'tokenType', - 'amount', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_token_bridge_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateEmergencyOpMessageArguments { - sourceChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - opType: RawTransactionArgument; -} -export interface CreateEmergencyOpMessageOptions { - package: string; - arguments: - | CreateEmergencyOpMessageArguments - | [ - sourceChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - opType: RawTransactionArgument, - ]; -} -/** - * Emergency Op Message Format: [message_type: u8] [version:u8] [nonce:u64] - * [chain_id: u8] [op_type: u8] - */ -export function createEmergencyOpMessage(options: CreateEmergencyOpMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u64', 'u8'] satisfies (string | null)[]; - const parameterNames = ['sourceChain', 'seqNum', 'opType']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_emergency_op_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateBlocklistMessageArguments { - sourceChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - blocklistType: RawTransactionArgument; - validatorEcdsaAddresses: RawTransactionArgument; -} -export interface CreateBlocklistMessageOptions { - package: string; - arguments: - | CreateBlocklistMessageArguments - | [ - sourceChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - blocklistType: RawTransactionArgument, - validatorEcdsaAddresses: RawTransactionArgument, - ]; -} -/** - * Blocklist Message Format: [message_type: u8] [version:u8] [nonce:u64] [chain_id: - * u8] [blocklist_type: u8] [validator_length: u8] [validator_ecdsa_addresses: - * byte[][]] - */ -export function createBlocklistMessage(options: CreateBlocklistMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u64', 'u8', 'vector>'] satisfies (string | null)[]; - const parameterNames = ['sourceChain', 'seqNum', 'blocklistType', 'validatorEcdsaAddresses']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_blocklist_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateUpdateBridgeLimitMessageArguments { - receivingChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - sendingChain: RawTransactionArgument; - newLimit: RawTransactionArgument; -} -export interface CreateUpdateBridgeLimitMessageOptions { - package: string; - arguments: - | CreateUpdateBridgeLimitMessageArguments - | [ - receivingChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - sendingChain: RawTransactionArgument, - newLimit: RawTransactionArgument, - ]; -} -/** - * Update bridge limit Message Format: [message_type: u8] [version:u8] [nonce:u64] - * [receiving_chain_id: u8] [sending_chain_id: u8] [new_limit: u64] - */ -export function createUpdateBridgeLimitMessage(options: CreateUpdateBridgeLimitMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u64', 'u8', 'u64'] satisfies (string | null)[]; - const parameterNames = ['receivingChain', 'seqNum', 'sendingChain', 'newLimit']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_update_bridge_limit_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateUpdateAssetPriceMessageArguments { - tokenId: RawTransactionArgument; - sourceChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - newPrice: RawTransactionArgument; -} -export interface CreateUpdateAssetPriceMessageOptions { - package: string; - arguments: - | CreateUpdateAssetPriceMessageArguments - | [ - tokenId: RawTransactionArgument, - sourceChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - newPrice: RawTransactionArgument, - ]; -} -/** - * Update asset price message [message_type: u8] [version:u8] [nonce:u64] - * [chain_id: u8] [token_id: u8] [new_price:u64] - */ -export function createUpdateAssetPriceMessage(options: CreateUpdateAssetPriceMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u8', 'u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['tokenId', 'sourceChain', 'seqNum', 'newPrice']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_update_asset_price_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateAddTokensOnSuiMessageArguments { - sourceChain: RawTransactionArgument; - seqNum: RawTransactionArgument; - nativeToken: RawTransactionArgument; - tokenIds: RawTransactionArgument; - typeNames: RawTransactionArgument; - tokenPrices: RawTransactionArgument; -} -export interface CreateAddTokensOnSuiMessageOptions { - package: string; - arguments: - | CreateAddTokensOnSuiMessageArguments - | [ - sourceChain: RawTransactionArgument, - seqNum: RawTransactionArgument, - nativeToken: RawTransactionArgument, - tokenIds: RawTransactionArgument, - typeNames: RawTransactionArgument, - tokenPrices: RawTransactionArgument, - ]; -} -/** - * Update Sui token message [message_type:u8] [version:u8] [nonce:u64] [chain_id: - * u8] [native_token:bool] [token_ids:vector] [token_type_name:vector] - * [token_prices:vector] - */ -export function createAddTokensOnSuiMessage(options: CreateAddTokensOnSuiMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - 'u8', - 'u64', - 'bool', - 'vector', - 'vector<0x1::string::String>', - 'vector', - ] satisfies (string | null)[]; - const parameterNames = [ - 'sourceChain', - 'seqNum', - 'nativeToken', - 'tokenIds', - 'typeNames', - 'tokenPrices', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_add_tokens_on_sui_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CreateKeyArguments { - sourceChain: RawTransactionArgument; - messageType: RawTransactionArgument; - bridgeSeqNum: RawTransactionArgument; -} -export interface CreateKeyOptions { - package: string; - arguments: - | CreateKeyArguments - | [ - sourceChain: RawTransactionArgument, - messageType: RawTransactionArgument, - bridgeSeqNum: RawTransactionArgument, - ]; -} -export function createKey(options: CreateKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u8', 'u8', 'u64'] satisfies (string | null)[]; - const parameterNames = ['sourceChain', 'messageType', 'bridgeSeqNum']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'create_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface KeyArguments { - self: RawTransactionArgument; -} -export interface KeyOptions { - package: string; - arguments: KeyArguments | [self: RawTransactionArgument]; -} -export function key(options: KeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MessageVersionArguments { - self: RawTransactionArgument; -} -export interface MessageVersionOptions { - package: string; - arguments: MessageVersionArguments | [self: RawTransactionArgument]; -} -export function messageVersion(options: MessageVersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'message_version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MessageTypeArguments { - self: RawTransactionArgument; -} -export interface MessageTypeOptions { - package: string; - arguments: MessageTypeArguments | [self: RawTransactionArgument]; -} -export function messageType(options: MessageTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'message_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SeqNumArguments { - self: RawTransactionArgument; -} -export interface SeqNumOptions { - package: string; - arguments: SeqNumArguments | [self: RawTransactionArgument]; -} -export function seqNum(options: SeqNumOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'seq_num', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SourceChainArguments { - self: RawTransactionArgument; -} -export interface SourceChainOptions { - package: string; - arguments: SourceChainArguments | [self: RawTransactionArgument]; -} -export function sourceChain(options: SourceChainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'source_chain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PayloadArguments { - self: RawTransactionArgument; -} -export interface PayloadOptions { - package: string; - arguments: PayloadArguments | [self: RawTransactionArgument]; -} -export function payload(options: PayloadOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'payload', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenTargetChainArguments { - self: RawTransactionArgument; -} -export interface TokenTargetChainOptions { - package: string; - arguments: TokenTargetChainArguments | [self: RawTransactionArgument]; -} -export function tokenTargetChain(options: TokenTargetChainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_target_chain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenTargetAddressArguments { - self: RawTransactionArgument; -} -export interface TokenTargetAddressOptions { - package: string; - arguments: TokenTargetAddressArguments | [self: RawTransactionArgument]; -} -export function tokenTargetAddress(options: TokenTargetAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_target_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenTypeArguments { - self: RawTransactionArgument; -} -export interface TokenTypeOptions { - package: string; - arguments: TokenTypeArguments | [self: RawTransactionArgument]; -} -export function tokenType(options: TokenTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenAmountArguments { - self: RawTransactionArgument; -} -export interface TokenAmountOptions { - package: string; - arguments: TokenAmountArguments | [self: RawTransactionArgument]; -} -export function tokenAmount(options: TokenAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface EmergencyOpTypeArguments { - self: RawTransactionArgument; -} -export interface EmergencyOpTypeOptions { - package: string; - arguments: EmergencyOpTypeArguments | [self: RawTransactionArgument]; -} -export function emergencyOpType(options: EmergencyOpTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'emergency_op_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BlocklistTypeArguments { - self: RawTransactionArgument; -} -export interface BlocklistTypeOptions { - package: string; - arguments: BlocklistTypeArguments | [self: RawTransactionArgument]; -} -export function blocklistType(options: BlocklistTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'blocklist_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BlocklistValidatorAddressesArguments { - self: RawTransactionArgument; -} -export interface BlocklistValidatorAddressesOptions { - package: string; - arguments: BlocklistValidatorAddressesArguments | [self: RawTransactionArgument]; -} -export function blocklistValidatorAddresses(options: BlocklistValidatorAddressesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'blocklist_validator_addresses', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateBridgeLimitPayloadSendingChainArguments { - self: RawTransactionArgument; -} -export interface UpdateBridgeLimitPayloadSendingChainOptions { - package: string; - arguments: UpdateBridgeLimitPayloadSendingChainArguments | [self: RawTransactionArgument]; -} -export function updateBridgeLimitPayloadSendingChain( - options: UpdateBridgeLimitPayloadSendingChainOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'update_bridge_limit_payload_sending_chain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateBridgeLimitPayloadReceivingChainArguments { - self: RawTransactionArgument; -} -export interface UpdateBridgeLimitPayloadReceivingChainOptions { - package: string; - arguments: - | UpdateBridgeLimitPayloadReceivingChainArguments - | [self: RawTransactionArgument]; -} -export function updateBridgeLimitPayloadReceivingChain( - options: UpdateBridgeLimitPayloadReceivingChainOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'update_bridge_limit_payload_receiving_chain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateBridgeLimitPayloadLimitArguments { - self: RawTransactionArgument; -} -export interface UpdateBridgeLimitPayloadLimitOptions { - package: string; - arguments: UpdateBridgeLimitPayloadLimitArguments | [self: RawTransactionArgument]; -} -export function updateBridgeLimitPayloadLimit(options: UpdateBridgeLimitPayloadLimitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'update_bridge_limit_payload_limit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateAssetPricePayloadTokenIdArguments { - self: RawTransactionArgument; -} -export interface UpdateAssetPricePayloadTokenIdOptions { - package: string; - arguments: UpdateAssetPricePayloadTokenIdArguments | [self: RawTransactionArgument]; -} -export function updateAssetPricePayloadTokenId(options: UpdateAssetPricePayloadTokenIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'update_asset_price_payload_token_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateAssetPricePayloadNewPriceArguments { - self: RawTransactionArgument; -} -export interface UpdateAssetPricePayloadNewPriceOptions { - package: string; - arguments: UpdateAssetPricePayloadNewPriceArguments | [self: RawTransactionArgument]; -} -export function updateAssetPricePayloadNewPrice(options: UpdateAssetPricePayloadNewPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'update_asset_price_payload_new_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsNativeArguments { - self: RawTransactionArgument; -} -export interface IsNativeOptions { - package: string; - arguments: IsNativeArguments | [self: RawTransactionArgument]; -} -export function isNative(options: IsNativeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'is_native', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenIdsArguments { - self: RawTransactionArgument; -} -export interface TokenIdsOptions { - package: string; - arguments: TokenIdsArguments | [self: RawTransactionArgument]; -} -export function tokenIds(options: TokenIdsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_ids', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenTypeNamesArguments { - self: RawTransactionArgument; -} -export interface TokenTypeNamesOptions { - package: string; - arguments: TokenTypeNamesArguments | [self: RawTransactionArgument]; -} -export function tokenTypeNames(options: TokenTypeNamesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_type_names', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TokenPricesArguments { - self: RawTransactionArgument; -} -export interface TokenPricesOptions { - package: string; - arguments: TokenPricesArguments | [self: RawTransactionArgument]; -} -export function tokenPrices(options: TokenPricesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'token_prices', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface EmergencyOpPauseOptions { - package: string; - arguments?: []; -} -export function emergencyOpPause(options: EmergencyOpPauseOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'emergency_op_pause', - }); -} -export interface EmergencyOpUnpauseOptions { - package: string; - arguments?: []; -} -export function emergencyOpUnpause(options: EmergencyOpUnpauseOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'emergency_op_unpause', - }); -} -export interface RequiredVotingPowerArguments { - self: RawTransactionArgument; -} -export interface RequiredVotingPowerOptions { - package: string; - arguments: RequiredVotingPowerArguments | [self: RawTransactionArgument]; -} -/** - * Return the required signature threshold for the message, values are voting power - * in the scale of 10000 - */ -export function requiredVotingPower(options: RequiredVotingPowerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'required_voting_power', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ToParsedTokenTransferMessageArguments { - message: RawTransactionArgument; -} -export interface ToParsedTokenTransferMessageOptions { - package: string; - arguments: ToParsedTokenTransferMessageArguments | [message: RawTransactionArgument]; -} -export function toParsedTokenTransferMessage(options: ToParsedTokenTransferMessageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message', - function: 'to_parsed_token_transfer_message', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts deleted file mode 100644 index b4ab36b8b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/message_types.ts +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -export interface TokenOptions { - package: string; - arguments?: []; -} -export function token(options: TokenOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'token', - }); -} -export interface CommitteeBlocklistOptions { - package: string; - arguments?: []; -} -export function committeeBlocklist(options: CommitteeBlocklistOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'committee_blocklist', - }); -} -export interface EmergencyOpOptions { - package: string; - arguments?: []; -} -export function emergencyOp(options: EmergencyOpOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'emergency_op', - }); -} -export interface UpdateBridgeLimitOptions { - package: string; - arguments?: []; -} -export function updateBridgeLimit(options: UpdateBridgeLimitOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'update_bridge_limit', - }); -} -export interface UpdateAssetPriceOptions { - package: string; - arguments?: []; -} -export function updateAssetPrice(options: UpdateAssetPriceOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'update_asset_price', - }); -} -export interface AddTokensOnSuiOptions { - package: string; - arguments?: []; -} -export function addTokensOnSui(options: AddTokensOnSuiOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'message_types', - function: 'add_tokens_on_sui', - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts b/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts deleted file mode 100644 index 1e908de2f..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/bridge/treasury.ts +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as object_bag from '../sui/object_bag.js'; -import * as vec_map from '../sui/vec_map.js'; -import * as type_name from '../suins_auction/type_name.js'; -import * as bag from '../sui/bag.js'; -import * as _package from '../sui/package.js'; -const $moduleName = 'bridge::treasury'; -export const BridgeTokenMetadata = new MoveStruct({ - name: `${$moduleName}::BridgeTokenMetadata`, - fields: { - id: bcs.u8(), - decimal_multiplier: bcs.u64(), - notional_value: bcs.u64(), - native_token: bcs.bool(), - }, -}); -export const BridgeTreasury = new MoveStruct({ - name: `${$moduleName}::BridgeTreasury`, - fields: { - treasuries: object_bag.ObjectBag, - supported_tokens: vec_map.VecMap(type_name.TypeName, BridgeTokenMetadata), - id_token_type_map: vec_map.VecMap(bcs.u8(), type_name.TypeName), - waiting_room: bag.Bag, - }, -}); -export const ForeignTokenRegistration = new MoveStruct({ - name: `${$moduleName}::ForeignTokenRegistration`, - fields: { - type_name: type_name.TypeName, - uc: _package.UpgradeCap, - decimal: bcs.u8(), - }, -}); -export const UpdateTokenPriceEvent = new MoveStruct({ - name: `${$moduleName}::UpdateTokenPriceEvent`, - fields: { - token_id: bcs.u8(), - new_price: bcs.u64(), - }, -}); -export const NewTokenEvent = new MoveStruct({ - name: `${$moduleName}::NewTokenEvent`, - fields: { - token_id: bcs.u8(), - type_name: type_name.TypeName, - native_token: bcs.bool(), - decimal_multiplier: bcs.u64(), - notional_value: bcs.u64(), - }, -}); -export const TokenRegistrationEvent = new MoveStruct({ - name: `${$moduleName}::TokenRegistrationEvent`, - fields: { - type_name: type_name.TypeName, - decimal: bcs.u8(), - native_token: bcs.bool(), - }, -}); -export interface TokenIdArguments { - self: RawTransactionArgument; -} -export interface TokenIdOptions { - package: string; - arguments: TokenIdArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -export function tokenId(options: TokenIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'treasury', - function: 'token_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DecimalMultiplierArguments { - self: RawTransactionArgument; -} -export interface DecimalMultiplierOptions { - package: string; - arguments: DecimalMultiplierArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -export function decimalMultiplier(options: DecimalMultiplierOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'treasury', - function: 'decimal_multiplier', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NotionalValueArguments { - self: RawTransactionArgument; -} -export interface NotionalValueOptions { - package: string; - arguments: NotionalValueArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -export function notionalValue(options: NotionalValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'treasury', - function: 'notional_value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts b/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts index 3802d278d..20902c3b0 100644 --- a/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts +++ b/packages/suins/src/contracts/suins_auction/deps/seal/bf_hmac_encryption.ts @@ -8,14 +8,8 @@ * https://seal-docs.wal.app/UsingSeal/#on-chain-decryption */ -import { - MoveStruct, - MoveEnum, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; +import { MoveStruct } from '../../../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; import * as group_ops from '../sui/group_ops.js'; const $moduleName = 'seal::bf_hmac_encryption'; export const EncryptedObject = new MoveStruct({ @@ -34,367 +28,3 @@ export const EncryptedObject = new MoveStruct({ mac: bcs.vector(bcs.u8()), }, }); -export const VerifiedDerivedKey = new MoveStruct({ - name: `${$moduleName}::VerifiedDerivedKey`, - fields: { - derived_key: group_ops.Element, - package_id: bcs.Address, - id: bcs.vector(bcs.u8()), - key_server: bcs.Address, - }, -}); -export const PublicKey = new MoveStruct({ - name: `${$moduleName}::PublicKey`, - fields: { - key_server: bcs.Address, - pk: group_ops.Element, - }, -}); -/** An enum representing the different purposes of the derived key. */ -export const KeyPurpose = new MoveEnum({ - name: `${$moduleName}::KeyPurpose`, - fields: { - EncryptedRandomness: null, - DEM: null, - }, -}); -export interface NewPublicKeyArguments { - keyServerId: RawTransactionArgument; - pkBytes: RawTransactionArgument; -} -export interface NewPublicKeyOptions { - package: string; - arguments: - | NewPublicKeyArguments - | [keyServerId: RawTransactionArgument, pkBytes: RawTransactionArgument]; -} -/** Creates PublicKey from key server ID and public key bytes. */ -export function newPublicKey(options: NewPublicKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', 'vector'] satisfies (string | null)[]; - const parameterNames = ['keyServerId', 'pkBytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'new_public_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DecryptArguments { - encryptedObject: RawTransactionArgument; - verifiedDerivedKeys: RawTransactionArgument; - publicKeys: RawTransactionArgument; -} -export interface DecryptOptions { - package: string; - arguments: - | DecryptArguments - | [ - encryptedObject: RawTransactionArgument, - verifiedDerivedKeys: RawTransactionArgument, - publicKeys: RawTransactionArgument, - ]; -} -/** - * Decrypts an encrypted object using the given verified derived keys. - * - * Call `verify_derived_keys` to verify derived keys before calling this function. - * - * Aborts if there are not enough verified derived keys to reach the threshold. - * Aborts if any of the key servers for the given verified derived keys are not - * among the key servers found in the encrypted object. Aborts if the given public - * keys do not contain exactly one public key for all key servers in the encrypted - * object and no more. - * - * If the decryption fails, e.g. the AAD or MAC is invalid, the function returns - * `none`. - * - * If some key servers are weighted, each derived key contributes the weight of the - * key server to the threshold. The public keys can be in any order and there - * should be exactly one per key server. The provided verified derived keys can be - * in any order, but there should be at most one per key server. - */ -export function decrypt(options: DecryptOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['encryptedObject', 'verifiedDerivedKeys', 'publicKeys']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'decrypt', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VerifyDerivedKeysArguments { - derivedKeys: RawTransactionArgument; - packageId: RawTransactionArgument; - id: RawTransactionArgument; - publicKeys: RawTransactionArgument; -} -export interface VerifyDerivedKeysOptions { - package: string; - arguments: - | VerifyDerivedKeysArguments - | [ - derivedKeys: RawTransactionArgument, - packageId: RawTransactionArgument, - id: RawTransactionArgument, - publicKeys: RawTransactionArgument, - ]; -} -/** - * Returns a vector of `VerifiedDerivedKey`s, asserting that all derived_keys are - * valid for the given full ID and key servers. The order of the derived keys and - * the public keys must match. Aborts if the number of key servers does not match - * the number of derived keys. - */ -export function verifyDerivedKeys(options: VerifyDerivedKeysOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'address', 'vector', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['derivedKeys', 'packageId', 'id', 'publicKeys']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'verify_derived_keys', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ParseEncryptedObjectArguments { - object: RawTransactionArgument; -} -export interface ParseEncryptedObjectOptions { - package: string; - arguments: ParseEncryptedObjectArguments | [object: RawTransactionArgument]; -} -/** - * Deserialize a BCS encoded EncryptedObject. Fails if the version is not 0. Fails - * if the object is not a valid EncryptedObject. Fails if the encryption type is - * not Hmac256Ctr. Fails if the KEM type is not Boneh-Franklin over BLS12-381. - */ -export function parseEncryptedObject(options: ParseEncryptedObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['object']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'parse_encrypted_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PackageIdArguments { - self: RawTransactionArgument; -} -export interface PackageIdOptions { - package: string; - arguments: PackageIdArguments | [self: RawTransactionArgument]; -} -export function packageId(options: PackageIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'package_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdArguments { - self: RawTransactionArgument; -} -export interface IdOptions { - package: string; - arguments: IdArguments | [self: RawTransactionArgument]; -} -export function id(options: IdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ServicesArguments { - self: RawTransactionArgument; -} -export interface ServicesOptions { - package: string; - arguments: ServicesArguments | [self: RawTransactionArgument]; -} -export function services(options: ServicesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'services', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IndicesArguments { - self: RawTransactionArgument; -} -export interface IndicesOptions { - package: string; - arguments: IndicesArguments | [self: RawTransactionArgument]; -} -export function indices(options: IndicesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'indices', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ThresholdArguments { - self: RawTransactionArgument; -} -export interface ThresholdOptions { - package: string; - arguments: ThresholdArguments | [self: RawTransactionArgument]; -} -export function threshold(options: ThresholdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'threshold', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NonceArguments { - self: RawTransactionArgument; -} -export interface NonceOptions { - package: string; - arguments: NonceArguments | [self: RawTransactionArgument]; -} -export function nonce(options: NonceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'nonce', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface EncryptedSharesArguments { - self: RawTransactionArgument; -} -export interface EncryptedSharesOptions { - package: string; - arguments: EncryptedSharesArguments | [self: RawTransactionArgument]; -} -export function encryptedShares(options: EncryptedSharesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'encrypted_shares', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface EncryptedRandomnessArguments { - self: RawTransactionArgument; -} -export interface EncryptedRandomnessOptions { - package: string; - arguments: EncryptedRandomnessArguments | [self: RawTransactionArgument]; -} -export function encryptedRandomness(options: EncryptedRandomnessOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'encrypted_randomness', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BlobArguments { - self: RawTransactionArgument; -} -export interface BlobOptions { - package: string; - arguments: BlobArguments | [self: RawTransactionArgument]; -} -export function blob(options: BlobOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'blob', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AadArguments { - self: RawTransactionArgument; -} -export interface AadOptions { - package: string; - arguments: AadArguments | [self: RawTransactionArgument]; -} -export function aad(options: AadOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'aad', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MacArguments { - self: RawTransactionArgument; -} -export interface MacOptions { - package: string; - arguments: MacArguments | [self: RawTransactionArgument]; -} -export function mac(options: MacOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bf_hmac_encryption', - function: 'mac', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts b/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts deleted file mode 100644 index cb56b7fae..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/seal/key_server.ts +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'seal::key_server'; -export const KeyServer = new MoveStruct({ - name: `${$moduleName}::KeyServer`, - fields: { - id: bcs.Address, - first_version: bcs.u64(), - last_version: bcs.u64(), - }, -}); -export const KeyServerV1 = new MoveStruct({ - name: `${$moduleName}::KeyServerV1`, - fields: { - name: bcs.string(), - url: bcs.string(), - key_type: bcs.u8(), - pk: bcs.vector(bcs.u8()), - }, -}); -export interface CreateAndTransferV1Arguments { - name: RawTransactionArgument; - url: RawTransactionArgument; - keyType: RawTransactionArgument; - pk: RawTransactionArgument; -} -export interface CreateAndTransferV1Options { - package: string; - arguments: - | CreateAndTransferV1Arguments - | [ - name: RawTransactionArgument, - url: RawTransactionArgument, - keyType: RawTransactionArgument, - pk: RawTransactionArgument, - ]; -} -export function createAndTransferV1(options: CreateAndTransferV1Options) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x1::string::String', - '0x1::string::String', - 'u8', - 'vector', - ] satisfies (string | null)[]; - const parameterNames = ['name', 'url', 'keyType', 'pk']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'create_and_transfer_v1', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface V1Arguments { - s: RawTransactionArgument; -} -export interface V1Options { - package: string; - arguments: V1Arguments | [s: RawTransactionArgument]; -} -export function v1(options: V1Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'v1', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NameArguments { - s: RawTransactionArgument; -} -export interface NameOptions { - package: string; - arguments: NameArguments | [s: RawTransactionArgument]; -} -export function name(options: NameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UrlArguments { - s: RawTransactionArgument; -} -export interface UrlOptions { - package: string; - arguments: UrlArguments | [s: RawTransactionArgument]; -} -export function url(options: UrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface KeyTypeArguments { - s: RawTransactionArgument; -} -export interface KeyTypeOptions { - package: string; - arguments: KeyTypeArguments | [s: RawTransactionArgument]; -} -export function keyType(options: KeyTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'key_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PkArguments { - s: RawTransactionArgument; -} -export interface PkOptions { - package: string; - arguments: PkArguments | [s: RawTransactionArgument]; -} -export function pk(options: PkOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'pk', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdArguments { - s: RawTransactionArgument; -} -export interface IdOptions { - package: string; - arguments: IdArguments | [s: RawTransactionArgument]; -} -export function id(options: IdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PkAsBfBls12381Arguments { - s: RawTransactionArgument; -} -export interface PkAsBfBls12381Options { - package: string; - arguments: PkAsBfBls12381Arguments | [s: RawTransactionArgument]; -} -export function pkAsBfBls12381(options: PkAsBfBls12381Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['s']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'pk_as_bf_bls12381', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateArguments { - s: RawTransactionArgument; - url: RawTransactionArgument; -} -export interface UpdateOptions { - package: string; - arguments: - | UpdateArguments - | [s: RawTransactionArgument, url: RawTransactionArgument]; -} -export function update(options: UpdateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['s', 'url']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'key_server', - function: 'update', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts b/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts deleted file mode 100644 index 65ac6309d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/seal/polynomial.ts +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'seal::polynomial'; -export const Polynomial = new MoveStruct({ - name: `${$moduleName}::Polynomial`, - fields: { - coefficients: bcs.vector(bcs.u8()), - }, -}); -export interface EvaluateArguments { - p: RawTransactionArgument; - x: RawTransactionArgument; -} -export interface EvaluateOptions { - package: string; - arguments: - | EvaluateArguments - | [p: RawTransactionArgument, x: RawTransactionArgument]; -} -/** Evaluate a polynomial at a given point. */ -export function evaluate(options: EvaluateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8'] satisfies (string | null)[]; - const parameterNames = ['p', 'x']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'polynomial', - function: 'evaluate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/std/type_name.ts b/packages/suins/src/contracts/suins_auction/deps/std/type_name.ts new file mode 100644 index 000000000..91bdc2a3c --- /dev/null +++ b/packages/suins/src/contracts/suins_auction/deps/std/type_name.ts @@ -0,0 +1,24 @@ +/************************************************************** + * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * + **************************************************************/ + +/** Functionality for converting Move types into values. Use with care! */ + +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; +const $moduleName = 'std::type_name'; +export const TypeName = new MoveStruct({ + name: `${$moduleName}::TypeName`, + fields: { + /** + * String representation of the type. All types are represented using their source + * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. + * Struct types are represented as fully qualified type names; e.g. + * `00000000000000000000000000000001::string::String` or + * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` + * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or + * 32 depending on the Move platform) + */ + name: bcs.string(), + }, +}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts deleted file mode 100644 index a9272156c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator.ts +++ /dev/null @@ -1,24 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = '0x2::accumulator'; -export const AccumulatorRoot = new MoveStruct({ - name: `${$moduleName}::AccumulatorRoot`, - fields: { - id: bcs.Address, - }, -}); -export const U128 = new MoveStruct({ - name: `${$moduleName}::U128`, - fields: { - value: bcs.u128(), - }, -}); -export const Key = new MoveStruct({ - name: `${$moduleName}::Key`, - fields: { - address: bcs.Address, - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts deleted file mode 100644 index 4f172aebc..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_metadata.ts +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct, MoveTuple } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import * as bag from './bag.js'; -const $moduleName = '0x2::accumulator_metadata'; -export const OwnerKey = new MoveStruct({ - name: `${$moduleName}::OwnerKey`, - fields: { - owner: bcs.Address, - }, -}); -export const Owner = new MoveStruct({ - name: `${$moduleName}::Owner`, - fields: { - /** The individual balances owned by the owner. */ - balances: bag.Bag, - owner: bcs.Address, - }, -}); -export const MetadataKey = new MoveTuple({ - name: `${$moduleName}::MetadataKey`, - fields: [bcs.bool()], -}); -export const Metadata = new MoveStruct({ - name: `${$moduleName}::Metadata`, - fields: { - /** Any per-balance fields we wish to add in the future. */ - fields: bag.Bag, - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts b/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts deleted file mode 100644 index 5bbf2068b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/accumulator_settlement.ts +++ /dev/null @@ -1,17 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = '0x2::accumulator_settlement'; -export const EventStreamHead = new MoveStruct({ - name: `${$moduleName}::EventStreamHead`, - fields: { - /** Merkle Mountain Range of all events in the stream. */ - mmr: bcs.vector(bcs.u256()), - /** Checkpoint sequence number at which the event stream was written. */ - checkpoint_seq: bcs.u64(), - /** Number of events in the stream. */ - num_events: bcs.u64(), - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/address.ts b/packages/suins/src/contracts/suins_auction/deps/sui/address.ts deleted file mode 100644 index c9114fa1d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/address.ts +++ /dev/null @@ -1,189 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface ToU256Arguments { - a: RawTransactionArgument; -} -export interface ToU256Options { - package: string; - arguments: ToU256Arguments | [a: RawTransactionArgument]; -} -/** - * Convert `a` into a u256 by interpreting `a` as the bytes of a big-endian integer - * (e.g., `to_u256(0x1) == 1`) - */ -export function toU256(options: ToU256Options) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['a']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'to_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FromU256Arguments { - n: RawTransactionArgument; -} -export interface FromU256Options { - package: string; - arguments: FromU256Arguments | [n: RawTransactionArgument]; -} -/** - * Convert `n` into an address by encoding it as a big-endian integer (e.g., - * `from_u256(1) = @0x1`) Aborts if `n` > `MAX_ADDRESS` - */ -export function fromU256(options: FromU256Options) { - const packageAddress = options.package; - const argumentsTypes = ['u256'] satisfies (string | null)[]; - const parameterNames = ['n']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'from_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FromBytesArguments { - bytes: RawTransactionArgument; -} -export interface FromBytesOptions { - package: string; - arguments: FromBytesArguments | [bytes: RawTransactionArgument]; -} -/** - * Convert `bytes` into an address. Aborts with `EAddressParseError` if the length - * of `bytes` is not 32 - */ -export function fromBytes(options: FromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ToBytesArguments { - a: RawTransactionArgument; -} -export interface ToBytesOptions { - package: string; - arguments: ToBytesArguments | [a: RawTransactionArgument]; -} -/** Convert `a` into BCS-encoded bytes. */ -export function toBytes(options: ToBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['a']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'to_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ToAsciiStringArguments { - a: RawTransactionArgument; -} -export interface ToAsciiStringOptions { - package: string; - arguments: ToAsciiStringArguments | [a: RawTransactionArgument]; -} -/** Convert `a` to a hex-encoded ASCII string */ -export function toAsciiString(options: ToAsciiStringOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['a']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'to_ascii_string', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ToStringArguments { - a: RawTransactionArgument; -} -export interface ToStringOptions { - package: string; - arguments: ToStringArguments | [a: RawTransactionArgument]; -} -/** Convert `a` to a hex-encoded string */ -export function toString(options: ToStringOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['a']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'to_string', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FromAsciiBytesArguments { - bytes: RawTransactionArgument; -} -export interface FromAsciiBytesOptions { - package: string; - arguments: FromAsciiBytesArguments | [bytes: RawTransactionArgument]; -} -/** - * Converts an ASCII string to an address, taking the numerical value for each - * character. The string must be Base16 encoded, and thus exactly 64 characters - * long. For example, the string - * "00000000000000000000000000000000000000000000000000000000DEADB33F" will be - * converted to the address @0xDEADB33F. Aborts with `EAddressParseError` if the - * length of `s` is not 64, or if an invalid character is encountered. - */ -export function fromAsciiBytes(options: FromAsciiBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'from_ascii_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface LengthOptions { - package: string; - arguments?: []; -} -/** Length of a Sui address in bytes */ -export function length(options: LengthOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'length', - }); -} -export interface MaxOptions { - package: string; - arguments?: []; -} -/** Largest possible address */ -export function max(options: MaxOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'address', - function: 'max', - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts b/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts deleted file mode 100644 index cdeed12f6..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/authenticator_state.ts +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = '0x2::authenticator_state'; -export const AuthenticatorState = new MoveStruct({ - name: `${$moduleName}::AuthenticatorState`, - fields: { - id: bcs.Address, - version: bcs.u64(), - }, -}); -export const JwkId = new MoveStruct({ - name: `${$moduleName}::JwkId`, - fields: { - iss: bcs.string(), - kid: bcs.string(), - }, -}); -export const JWK = new MoveStruct({ - name: `${$moduleName}::JWK`, - fields: { - kty: bcs.string(), - e: bcs.string(), - n: bcs.string(), - alg: bcs.string(), - }, -}); -export const ActiveJwk = new MoveStruct({ - name: `${$moduleName}::ActiveJwk`, - fields: { - jwk_id: JwkId, - jwk: JWK, - epoch: bcs.u64(), - }, -}); -export const AuthenticatorStateInner = new MoveStruct({ - name: `${$moduleName}::AuthenticatorStateInner`, - fields: { - version: bcs.u64(), - /** List of currently active JWKs. */ - active_jwks: bcs.vector(ActiveJwk), - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts index d96ca431b..f8966dc9e 100644 --- a/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts +++ b/packages/suins/src/contracts/suins_auction/deps/sui/bag.ts @@ -27,13 +27,8 @@ * bag, on the other hand, must be empty to be destroyed. */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; const $moduleName = '0x2::bag'; export const Bag = new MoveStruct({ name: `${$moduleName}::Bag`, @@ -44,267 +39,3 @@ export const Bag = new MoveStruct({ size: bcs.u64(), }, }); -export interface NewOptions { - package: string; - arguments?: []; -} -/** Creates a new, empty bag */ -export function _new(options: NewOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'new', - }); -} -export interface AddArguments, V extends BcsType> { - bag: RawTransactionArgument; - k: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface AddOptions, V extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - bag: RawTransactionArgument, - k: RawTransactionArgument, - v: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a key-value pair to the bag `bag: &mut Bag` Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with - * that key `k: K`. - */ -export function add, V extends BcsType>(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['bag', 'k', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutable borrows the value associated with the key in the bag `bag: &Bag`. - * Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an - * entry with that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` - * if the bag has an entry for the key, but the value does not have the specified - * type. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the value associated with the key in the bag `bag: &mut Bag`. - * Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an - * entry with that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` - * if the bag has an entry for the key, but the value does not have the specified - * type. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the key-value pair in the bag `bag: &mut Bag` and returns the - * value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does not - * have an entry with that key `k: K`. Aborts with - * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, - * but the value does not have the specified type. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns true iff there is an value associated with the key `k: K` in the bag - * `bag: &Bag` - */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsWithTypeArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsWithTypeOptions> { - package: string; - arguments: - | ContainsWithTypeArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true iff there is an value associated with the key `k: K` in the bag - * `bag: &Bag` with an assigned value of type `V` - */ -export function containsWithType>(options: ContainsWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'contains_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - bag: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [bag: RawTransactionArgument]; -} -/** Returns the size of the bag, the number of key-value pairs */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsEmptyArguments { - bag: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [bag: RawTransactionArgument]; -} -/** Returns true iff the bag is empty (if `length` returns `0`) */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DestroyEmptyArguments { - bag: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [bag: RawTransactionArgument]; -} -/** - * Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains - * values - */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bag', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts b/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts index 7a08778f8..e0018f41a 100644 --- a/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts +++ b/packages/suins/src/contracts/suins_auction/deps/sui/balance.ts @@ -8,299 +8,12 @@ * and `Balance`s. */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; const $moduleName = '0x2::balance'; -export const Supply = new MoveStruct({ - name: `${$moduleName}::Supply`, - fields: { - value: bcs.u64(), - }, -}); export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { value: bcs.u64(), }, }); -export interface ValueArguments { - self: RawTransactionArgument; -} -export interface ValueOptions { - package: string; - arguments: ValueArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the amount stored in a `Balance`. */ -export function value(options: ValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SupplyValueArguments { - supply: RawTransactionArgument; -} -export interface SupplyValueOptions { - package: string; - arguments: SupplyValueArguments | [supply: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `Supply` value. */ -export function supplyValue(options: SupplyValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['supply']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'supply_value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateSupplyArguments> { - _: RawTransactionArgument; -} -export interface CreateSupplyOptions> { - package: string; - arguments: CreateSupplyArguments | [_: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a new supply for type T. */ -export function createSupply>(options: CreateSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'create_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IncreaseSupplyArguments { - self: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface IncreaseSupplyOptions { - package: string; - arguments: - | IncreaseSupplyArguments - | [self: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Increase supply by `value` and create a new `Balance` with this value. */ -export function increaseSupply(options: IncreaseSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'increase_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DecreaseSupplyArguments { - self: RawTransactionArgument; - balance: RawTransactionArgument; -} -export interface DecreaseSupplyOptions { - package: string; - arguments: - | DecreaseSupplyArguments - | [self: RawTransactionArgument, balance: RawTransactionArgument]; - typeArguments: [string]; -} -/** Burn a Balance and decrease Supply. */ -export function decreaseSupply(options: DecreaseSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'decrease_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ZeroOptions { - package: string; - arguments?: []; - typeArguments: [string]; -} -/** Create a zero `Balance` for type `T`. */ -export function zero(options: ZeroOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'zero', - typeArguments: options.typeArguments, - }); -} -export interface JoinArguments { - self: RawTransactionArgument; - balance: RawTransactionArgument; -} -export interface JoinOptions { - package: string; - arguments: - | JoinArguments - | [self: RawTransactionArgument, balance: RawTransactionArgument]; - typeArguments: [string]; -} -/** Join two balances together. */ -export function join(options: JoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'join', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitArguments { - self: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface SplitOptions { - package: string; - arguments: - | SplitArguments - | [self: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Split a `Balance` and take a sub balance from it. */ -export function split(options: SplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawAllArguments { - self: RawTransactionArgument; -} -export interface WithdrawAllOptions { - package: string; - arguments: WithdrawAllArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Withdraw all balance. After this the remaining balance must be 0. */ -export function withdrawAll(options: WithdrawAllOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'withdraw_all', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyZeroArguments { - balance: RawTransactionArgument; -} -export interface DestroyZeroOptions { - package: string; - arguments: DestroyZeroArguments | [balance: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destroy a zero `Balance`. */ -export function destroyZero(options: DestroyZeroOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'destroy_zero', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SendFundsArguments { - balance: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface SendFundsOptions { - package: string; - arguments: - | SendFundsArguments - | [balance: RawTransactionArgument, recipient: RawTransactionArgument]; - typeArguments: [string]; -} -/** Send a `Balance` to an address's funds accumulator. */ -export function sendFunds(options: SendFundsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['balance', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'send_funds', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RedeemFundsArguments { - withdrawal: RawTransactionArgument; -} -export interface RedeemFundsOptions { - package: string; - arguments: RedeemFundsArguments | [withdrawal: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Redeem a `Withdrawal>` to get the underlying `Balance` from an - * address's funds accumulator. - */ -export function redeemFunds(options: RedeemFundsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['withdrawal']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'balance', - function: 'redeem_funds', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts deleted file mode 100644 index e934d9a19..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/bcs.ts +++ /dev/null @@ -1,683 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * This module implements BCS (de)serialization in Move. Full specification can be - * found here: https://github.com/diem/bcs - * - * Short summary (for Move-supported types): - * - * - address - sequence of X bytes - * - bool - byte with 0 or 1 - * - u8 - a single u8 byte - * - u16 / u32 / u64 / u128 / u256 - LE bytes - * - vector - ULEB128 length + LEN elements - * - option - first byte bool: None (0) or Some (1), then value - * - * Usage example: - * - * ``` - * /// This function reads u8 and u64 value from the input - * /// and returns the rest of the bytes. - * fun deserialize(bytes: vector): (u8, u64, vector) { - * use sui::bcs::{Self, BCS}; - * - * let prepared: BCS = bcs::new(bytes); - * let (u8_value, u64_value) = ( - * prepared.peel_u8(), - * prepared.peel_u64() - * ); - * - * // unpack bcs struct - * let leftovers = prepared.into_remainder_bytes(); - * - * (u8_value, u64_value, leftovers) - * } - * ``` - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::bcs'; -export const BCS = new MoveStruct({ - name: `${$moduleName}::BCS`, - fields: { - bytes: bcs.vector(bcs.u8()), - }, -}); -export interface ToBytesArguments> { - value: RawTransactionArgument; -} -export interface ToBytesOptions> { - package: string; - arguments: ToBytesArguments | [value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get BCS serialized bytes for any value. Re-exports stdlib `bcs::to_bytes`. */ -export function toBytes>(options: ToBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'to_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewArguments { - bytes: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [bytes: RawTransactionArgument]; -} -/** - * Creates a new instance of BCS wrapper that holds inversed bytes for better - * performance. - */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IntoRemainderBytesArguments { - bcs: RawTransactionArgument; -} -export interface IntoRemainderBytesOptions { - package: string; - arguments: IntoRemainderBytesArguments | [bcs: RawTransactionArgument]; -} -/** - * Unpack the `BCS` struct returning the leftover bytes. Useful for passing the - * data further after partial deserialization. - */ -export function intoRemainderBytes(options: IntoRemainderBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'into_remainder_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelAddressArguments { - bcs: RawTransactionArgument; -} -export interface PeelAddressOptions { - package: string; - arguments: PeelAddressArguments | [bcs: RawTransactionArgument]; -} -/** Read address from the bcs-serialized bytes. */ -export function peelAddress(options: PeelAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelBoolArguments { - bcs: RawTransactionArgument; -} -export interface PeelBoolOptions { - package: string; - arguments: PeelBoolArguments | [bcs: RawTransactionArgument]; -} -/** Read a `bool` value from bcs-serialized bytes. */ -export function peelBool(options: PeelBoolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_bool', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU8Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU8Options { - package: string; - arguments: PeelU8Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u8` value from bcs-serialized bytes. */ -export function peelU8(options: PeelU8Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u8', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU16Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU16Options { - package: string; - arguments: PeelU16Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u16` value from bcs-serialized bytes. */ -export function peelU16(options: PeelU16Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u16', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU32Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU32Options { - package: string; - arguments: PeelU32Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u32` value from bcs-serialized bytes. */ -export function peelU32(options: PeelU32Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u32', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU64Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU64Options { - package: string; - arguments: PeelU64Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u64` value from bcs-serialized bytes. */ -export function peelU64(options: PeelU64Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u64', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU128Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU128Options { - package: string; - arguments: PeelU128Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u128` value from bcs-serialized bytes. */ -export function peelU128(options: PeelU128Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u128', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelU256Arguments { - bcs: RawTransactionArgument; -} -export interface PeelU256Options { - package: string; - arguments: PeelU256Arguments | [bcs: RawTransactionArgument]; -} -/** Read `u256` value from bcs-serialized bytes. */ -export function peelU256(options: PeelU256Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecLengthArguments { - bcs: RawTransactionArgument; -} -export interface PeelVecLengthOptions { - package: string; - arguments: PeelVecLengthArguments | [bcs: RawTransactionArgument]; -} -/** - * Read ULEB bytes expecting a vector length. Result should then be used to perform - * `peel_*` operation LEN times. - * - * In BCS `vector` length is implemented with ULEB128; See more here: - * https://en.wikipedia.org/wiki/LEB128 - */ -export function peelVecLength(options: PeelVecLengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecAddressArguments { - bcs: RawTransactionArgument; -} -export interface PeelVecAddressOptions { - package: string; - arguments: PeelVecAddressArguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `address` from serialized bytes. */ -export function peelVecAddress(options: PeelVecAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecBoolArguments { - bcs: RawTransactionArgument; -} -export interface PeelVecBoolOptions { - package: string; - arguments: PeelVecBoolArguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `address` from serialized bytes. */ -export function peelVecBool(options: PeelVecBoolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_bool', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU8Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU8Options { - package: string; - arguments: PeelVecU8Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u8` (eg string) from serialized bytes. */ -export function peelVecU8(options: PeelVecU8Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u8', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecVecU8Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecVecU8Options { - package: string; - arguments: PeelVecVecU8Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a `vector>` (eg vec of string) from serialized bytes. */ -export function peelVecVecU8(options: PeelVecVecU8Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_vec_u8', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU16Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU16Options { - package: string; - arguments: PeelVecU16Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u16` from serialized bytes. */ -export function peelVecU16(options: PeelVecU16Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u16', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU32Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU32Options { - package: string; - arguments: PeelVecU32Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u32` from serialized bytes. */ -export function peelVecU32(options: PeelVecU32Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u32', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU64Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU64Options { - package: string; - arguments: PeelVecU64Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u64` from serialized bytes. */ -export function peelVecU64(options: PeelVecU64Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u64', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU128Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU128Options { - package: string; - arguments: PeelVecU128Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u128` from serialized bytes. */ -export function peelVecU128(options: PeelVecU128Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u128', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelVecU256Arguments { - bcs: RawTransactionArgument; -} -export interface PeelVecU256Options { - package: string; - arguments: PeelVecU256Arguments | [bcs: RawTransactionArgument]; -} -/** Peel a vector of `u256` from serialized bytes. */ -export function peelVecU256(options: PeelVecU256Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_vec_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelEnumTagArguments { - bcs: RawTransactionArgument; -} -export interface PeelEnumTagOptions { - package: string; - arguments: PeelEnumTagArguments | [bcs: RawTransactionArgument]; -} -/** - * Peel enum from serialized bytes, where `$f` takes a `tag` value and returns the - * corresponding enum variant. Move enums are limited to 127 variants, however the - * tag can be any `u32` value. - * - * Example: - * - * ```rust - * let my_enum = match (bcs.peel_enum_tag()) { - * 0 => Enum::Empty, - * 1 => Enum::U8(bcs.peel_u8()), - * 2 => Enum::U16(bcs.peel_u16()), - * 3 => Enum::Struct { a: bcs.peel_address(), b: bcs.peel_u8() }, - * _ => abort, - * }; - * ``` - */ -export function peelEnumTag(options: PeelEnumTagOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_enum_tag', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionAddressArguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionAddressOptions { - package: string; - arguments: PeelOptionAddressArguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option
` from serialized bytes. */ -export function peelOptionAddress(options: PeelOptionAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionBoolArguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionBoolOptions { - package: string; - arguments: PeelOptionBoolArguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionBool(options: PeelOptionBoolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_bool', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU8Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU8Options { - package: string; - arguments: PeelOptionU8Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU8(options: PeelOptionU8Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u8', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU16Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU16Options { - package: string; - arguments: PeelOptionU16Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU16(options: PeelOptionU16Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u16', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU32Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU32Options { - package: string; - arguments: PeelOptionU32Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU32(options: PeelOptionU32Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u32', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU64Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU64Options { - package: string; - arguments: PeelOptionU64Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU64(options: PeelOptionU64Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u64', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU128Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU128Options { - package: string; - arguments: PeelOptionU128Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU128(options: PeelOptionU128Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u128', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PeelOptionU256Arguments { - bcs: RawTransactionArgument; -} -export interface PeelOptionU256Options { - package: string; - arguments: PeelOptionU256Arguments | [bcs: RawTransactionArgument]; -} -/** Peel `Option` from serialized bytes. */ -export function peelOptionU256(options: PeelOptionU256Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bcs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bcs', - function: 'peel_option_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts b/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts deleted file mode 100644 index 55f44534e..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/bls12381.ts +++ /dev/null @@ -1,929 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** Group operations of BLS12-381. */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::bls12381'; -export const Scalar = new MoveStruct({ - name: `${$moduleName}::Scalar`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const G1 = new MoveStruct({ - name: `${$moduleName}::G1`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const G2 = new MoveStruct({ - name: `${$moduleName}::G2`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const GT = new MoveStruct({ - name: `${$moduleName}::GT`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const UncompressedG1 = new MoveStruct({ - name: `${$moduleName}::UncompressedG1`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface Bls12381MinSigVerifyArguments { - signature: RawTransactionArgument; - publicKey: RawTransactionArgument; - msg: RawTransactionArgument; -} -export interface Bls12381MinSigVerifyOptions { - package: string; - arguments: - | Bls12381MinSigVerifyArguments - | [ - signature: RawTransactionArgument, - publicKey: RawTransactionArgument, - msg: RawTransactionArgument, - ]; -} -/** - * @param signature: A 48-bytes signature that is a point on the G1 subgroup. - * @param public_key: A 96-bytes public key that is a point on the G2 subgroup. - * @param msg: The message that we test the signature against. - * - * If the signature is a valid signature of the message and public key according to - * BLS*SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL*, return true. Otherwise, return - * false. - */ -export function bls12381MinSigVerify(options: Bls12381MinSigVerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['signature', 'publicKey', 'msg']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'bls12381_min_sig_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface Bls12381MinPkVerifyArguments { - signature: RawTransactionArgument; - publicKey: RawTransactionArgument; - msg: RawTransactionArgument; -} -export interface Bls12381MinPkVerifyOptions { - package: string; - arguments: - | Bls12381MinPkVerifyArguments - | [ - signature: RawTransactionArgument, - publicKey: RawTransactionArgument, - msg: RawTransactionArgument, - ]; -} -/** - * @param signature: A 96-bytes signature that is a point on the G2 subgroup. - * @param public_key: A 48-bytes public key that is a point on the G1 subgroup. - * @param msg: The message that we test the signature against. - * - * If the signature is a valid signature of the message and public key according to - * BLS*SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL*, return true. Otherwise, return - * false. - */ -export function bls12381MinPkVerify(options: Bls12381MinPkVerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['signature', 'publicKey', 'msg']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'bls12381_min_pk_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarFromBytesArguments { - bytes: RawTransactionArgument; -} -export interface ScalarFromBytesOptions { - package: string; - arguments: ScalarFromBytesArguments | [bytes: RawTransactionArgument]; -} -export function scalarFromBytes(options: ScalarFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarFromU64Arguments { - x: RawTransactionArgument; -} -export interface ScalarFromU64Options { - package: string; - arguments: ScalarFromU64Arguments | [x: RawTransactionArgument]; -} -export function scalarFromU64(options: ScalarFromU64Options) { - const packageAddress = options.package; - const argumentsTypes = ['u64'] satisfies (string | null)[]; - const parameterNames = ['x']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_from_u64', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarZeroOptions { - package: string; - arguments?: []; -} -export function scalarZero(options: ScalarZeroOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_zero', - }); -} -export interface ScalarOneOptions { - package: string; - arguments?: []; -} -export function scalarOne(options: ScalarOneOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_one', - }); -} -export interface ScalarAddArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface ScalarAddOptions { - package: string; - arguments: - | ScalarAddArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function scalarAdd(options: ScalarAddOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarSubArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface ScalarSubOptions { - package: string; - arguments: - | ScalarSubArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function scalarSub(options: ScalarSubOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_sub', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarMulArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface ScalarMulOptions { - package: string; - arguments: - | ScalarMulArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function scalarMul(options: ScalarMulOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_mul', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarDivArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface ScalarDivOptions { - package: string; - arguments: - | ScalarDivArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -/** Returns e2/e1, fails if a is zero. */ -export function scalarDiv(options: ScalarDivOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_div', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarNegArguments { - e: RawTransactionArgument; -} -export interface ScalarNegOptions { - package: string; - arguments: ScalarNegArguments | [e: RawTransactionArgument]; -} -export function scalarNeg(options: ScalarNegOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_neg', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ScalarInvArguments { - e: RawTransactionArgument; -} -export interface ScalarInvOptions { - package: string; - arguments: ScalarInvArguments | [e: RawTransactionArgument]; -} -export function scalarInv(options: ScalarInvOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'scalar_inv', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1FromBytesArguments { - bytes: RawTransactionArgument; -} -export interface G1FromBytesOptions { - package: string; - arguments: G1FromBytesArguments | [bytes: RawTransactionArgument]; -} -export function g1FromBytes(options: G1FromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1IdentityOptions { - package: string; - arguments?: []; -} -export function g1Identity(options: G1IdentityOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_identity', - }); -} -export interface G1GeneratorOptions { - package: string; - arguments?: []; -} -export function g1Generator(options: G1GeneratorOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_generator', - }); -} -export interface G1AddArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G1AddOptions { - package: string; - arguments: - | G1AddArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g1Add(options: G1AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1SubArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G1SubOptions { - package: string; - arguments: - | G1SubArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g1Sub(options: G1SubOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_sub', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1MulArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G1MulOptions { - package: string; - arguments: - | G1MulArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g1Mul(options: G1MulOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_mul', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1DivArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G1DivOptions { - package: string; - arguments: - | G1DivArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -/** Returns e2 / e1, fails if scalar is zero. */ -export function g1Div(options: G1DivOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_div', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1NegArguments { - e: RawTransactionArgument; -} -export interface G1NegOptions { - package: string; - arguments: G1NegArguments | [e: RawTransactionArgument]; -} -export function g1Neg(options: G1NegOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_neg', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HashToG1Arguments { - m: RawTransactionArgument; -} -export interface HashToG1Options { - package: string; - arguments: HashToG1Arguments | [m: RawTransactionArgument]; -} -/** Hash using DST = BLS*SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL* */ -export function hashToG1(options: HashToG1Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['m']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'hash_to_g1', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1MultiScalarMultiplicationArguments { - scalars: RawTransactionArgument; - elements: RawTransactionArgument; -} -export interface G1MultiScalarMultiplicationOptions { - package: string; - arguments: - | G1MultiScalarMultiplicationArguments - | [scalars: RawTransactionArgument, elements: RawTransactionArgument]; -} -/** - * Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, - * e2, ..., en]. Returns s1*e1 + s2*e2 + ... + sn\*en. Aborts with `EInputTooLong` - * if the vectors are larger than 32 (may increase in the future). - */ -export function g1MultiScalarMultiplication(options: G1MultiScalarMultiplicationOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['scalars', 'elements']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_multi_scalar_multiplication', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G1ToUncompressedG1Arguments { - e: RawTransactionArgument; -} -export interface G1ToUncompressedG1Options { - package: string; - arguments: G1ToUncompressedG1Arguments | [e: RawTransactionArgument]; -} -/** Convert an `Element` to uncompressed form. */ -export function g1ToUncompressedG1(options: G1ToUncompressedG1Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g1_to_uncompressed_g1', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2FromBytesArguments { - bytes: RawTransactionArgument; -} -export interface G2FromBytesOptions { - package: string; - arguments: G2FromBytesArguments | [bytes: RawTransactionArgument]; -} -export function g2FromBytes(options: G2FromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2IdentityOptions { - package: string; - arguments?: []; -} -export function g2Identity(options: G2IdentityOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_identity', - }); -} -export interface G2GeneratorOptions { - package: string; - arguments?: []; -} -export function g2Generator(options: G2GeneratorOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_generator', - }); -} -export interface G2AddArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G2AddOptions { - package: string; - arguments: - | G2AddArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g2Add(options: G2AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2SubArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G2SubOptions { - package: string; - arguments: - | G2SubArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g2Sub(options: G2SubOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_sub', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2MulArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G2MulOptions { - package: string; - arguments: - | G2MulArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function g2Mul(options: G2MulOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_mul', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2DivArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface G2DivOptions { - package: string; - arguments: - | G2DivArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -/** Returns e2 / e1, fails if scalar is zero. */ -export function g2Div(options: G2DivOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_div', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2NegArguments { - e: RawTransactionArgument; -} -export interface G2NegOptions { - package: string; - arguments: G2NegArguments | [e: RawTransactionArgument]; -} -export function g2Neg(options: G2NegOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_neg', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HashToG2Arguments { - m: RawTransactionArgument; -} -export interface HashToG2Options { - package: string; - arguments: HashToG2Arguments | [m: RawTransactionArgument]; -} -/** Hash using DST = BLS*SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL* */ -export function hashToG2(options: HashToG2Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['m']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'hash_to_g2', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface G2MultiScalarMultiplicationArguments { - scalars: RawTransactionArgument; - elements: RawTransactionArgument; -} -export interface G2MultiScalarMultiplicationOptions { - package: string; - arguments: - | G2MultiScalarMultiplicationArguments - | [scalars: RawTransactionArgument, elements: RawTransactionArgument]; -} -/** - * Let 'scalars' be the vector [s1, s2, ..., sn] and 'elements' be the vector [e1, - * e2, ..., en]. Returns s1*e1 + s2*e2 + ... + sn\*en. Aborts with `EInputTooLong` - * if the vectors are larger than 32 (may increase in the future). - */ -export function g2MultiScalarMultiplication(options: G2MultiScalarMultiplicationOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['scalars', 'elements']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'g2_multi_scalar_multiplication', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GtIdentityOptions { - package: string; - arguments?: []; -} -export function gtIdentity(options: GtIdentityOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_identity', - }); -} -export interface GtGeneratorOptions { - package: string; - arguments?: []; -} -export function gtGenerator(options: GtGeneratorOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_generator', - }); -} -export interface GtAddArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface GtAddOptions { - package: string; - arguments: - | GtAddArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function gtAdd(options: GtAddOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GtSubArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface GtSubOptions { - package: string; - arguments: - | GtSubArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function gtSub(options: GtSubOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_sub', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GtMulArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface GtMulOptions { - package: string; - arguments: - | GtMulArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function gtMul(options: GtMulOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_mul', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GtDivArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface GtDivOptions { - package: string; - arguments: - | GtDivArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -/** Returns e2 / e1, fails if scalar is zero. */ -export function gtDiv(options: GtDivOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_div', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GtNegArguments { - e: RawTransactionArgument; -} -export interface GtNegOptions { - package: string; - arguments: GtNegArguments | [e: RawTransactionArgument]; -} -export function gtNeg(options: GtNegOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'gt_neg', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PairingArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface PairingOptions { - package: string; - arguments: - | PairingArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; -} -export function pairing(options: PairingOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'pairing', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UncompressedG1ToG1Arguments { - e: RawTransactionArgument; -} -export interface UncompressedG1ToG1Options { - package: string; - arguments: UncompressedG1ToG1Arguments | [e: RawTransactionArgument]; -} -/** - * UncompressedG1 group operations /// Create a `Element` from its uncompressed - * form. - */ -export function uncompressedG1ToG1(options: UncompressedG1ToG1Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'uncompressed_g1_to_g1', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UncompressedG1SumArguments { - terms: RawTransactionArgument; -} -export interface UncompressedG1SumOptions { - package: string; - arguments: UncompressedG1SumArguments | [terms: RawTransactionArgument]; -} -/** - * Compute the sum of a list of uncompressed elements. This is significantly faster - * and cheaper than summing the elements. - */ -export function uncompressedG1Sum(options: UncompressedG1SumOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['terms']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'bls12381', - function: 'uncompressed_g1_sum', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts b/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts deleted file mode 100644 index 7a2dd270c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/borrow.ts +++ /dev/null @@ -1,133 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * A simple library that enables hot-potato-locked borrow mechanics. - * - * With Programmable transactions, it is possible to borrow a value within a - * transaction, use it and put back in the end. Hot-potato `Borrow` makes sure the - * object is returned and was not swapped for another one. - */ - -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::borrow'; -/** An object wrapping a `T` and providing the borrow API. */ -export function Referent>(...typeParameters: [T]) { - return new MoveStruct({ - name: `${$moduleName}::Referent<${typeParameters[0].name as T['name']}>`, - fields: { - id: bcs.Address, - value: bcs.option(typeParameters[0]), - }, - }); -} -export const Borrow = new MoveStruct({ - name: `${$moduleName}::Borrow`, - fields: { - ref: bcs.Address, - obj: bcs.Address, - }, -}); -export interface NewArguments> { - value: RawTransactionArgument; -} -export interface NewOptions> { - package: string; - arguments: NewArguments | [value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a new `Referent` struct */ -export function _new>(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'borrow', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments { - self: RawTransactionArgument; -} -export interface BorrowOptions { - package: string; - arguments: BorrowArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Borrow the `T` from the `Referent`, receiving the `T` and a `Borrow` hot potato. */ -export function borrow(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'borrow', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PutBackArguments> { - self: RawTransactionArgument; - value: RawTransactionArgument; - borrow: RawTransactionArgument; -} -export interface PutBackOptions> { - package: string; - arguments: - | PutBackArguments - | [ - self: RawTransactionArgument, - value: RawTransactionArgument, - borrow: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Put an object and the `Borrow` hot potato back. */ -export function putBack>(options: PutBackOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['self', 'value', 'borrow']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'borrow', - function: 'put_back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyArguments { - self: RawTransactionArgument; -} -export interface DestroyOptions { - package: string; - arguments: DestroyArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Unpack the `Referent` struct and return the value. */ -export function destroy(options: DestroyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'borrow', - function: 'destroy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts b/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts deleted file mode 100644 index ece3b1ba9..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/clock.ts +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * APIs for accessing time from move calls, via the `Clock`: a unique shared object - * that is created at 0x6 during genesis. - */ - -import { MoveStruct, normalizeMoveArguments } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::clock'; -export const Clock = new MoveStruct({ - name: `${$moduleName}::Clock`, - fields: { - id: bcs.Address, - /** - * The clock's timestamp, which is set automatically by a system transaction every - * time consensus commits a schedule, or by `sui::clock::increment_for_testing` - * during testing. - */ - timestamp_ms: bcs.u64(), - }, -}); -export interface TimestampMsArguments {} -export interface TimestampMsOptions { - package: string; - arguments?: TimestampMsArguments | []; -} -/** - * The `clock`'s current timestamp as a running total of milliseconds since an - * arbitrary point in the past. - */ -export function timestampMs(options: TimestampMsOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'clock', - function: 'timestamp_ms', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts b/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts deleted file mode 100644 index e252f9252..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/coin.ts +++ /dev/null @@ -1,1348 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Defines the `Coin` type - platform wide representation of fungible tokens and - * coins. `Coin` can be described as a secure wrapper around `Balance` type. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance_1 from './balance.js'; -import * as url from './url.js'; -const $moduleName = '0x2::coin'; -export const Coin = new MoveStruct({ - name: `${$moduleName}::Coin`, - fields: { - id: bcs.Address, - balance: balance_1.Balance, - }, -}); -export const CoinMetadata = new MoveStruct({ - name: `${$moduleName}::CoinMetadata`, - fields: { - id: bcs.Address, - /** - * Number of decimal places the coin uses. A coin with `value ` N and `decimals` D - * should be shown as N / 10^D E.g., a coin with `value` 7002 and decimals 3 should - * be displayed as 7.002 This is metadata for display usage only. - */ - decimals: bcs.u8(), - /** Name for the token */ - name: bcs.string(), - /** Symbol for the token */ - symbol: bcs.string(), - /** Description of the token */ - description: bcs.string(), - /** URL for the token logo */ - icon_url: bcs.option(url.Url), - }, -}); -export const RegulatedCoinMetadata = new MoveStruct({ - name: `${$moduleName}::RegulatedCoinMetadata`, - fields: { - id: bcs.Address, - /** The ID of the coin's CoinMetadata object. */ - coin_metadata_object: bcs.Address, - /** The ID of the coin's DenyCap object. */ - deny_cap_object: bcs.Address, - }, -}); -export const TreasuryCap = new MoveStruct({ - name: `${$moduleName}::TreasuryCap`, - fields: { - id: bcs.Address, - total_supply: balance_1.Supply, - }, -}); -export const DenyCapV2 = new MoveStruct({ - name: `${$moduleName}::DenyCapV2`, - fields: { - id: bcs.Address, - allow_global_pause: bcs.bool(), - }, -}); -export const CurrencyCreated = new MoveStruct({ - name: `${$moduleName}::CurrencyCreated`, - fields: { - decimals: bcs.u8(), - }, -}); -export const DenyCap = new MoveStruct({ - name: `${$moduleName}::DenyCap`, - fields: { - id: bcs.Address, - }, -}); -export interface TotalSupplyArguments { - cap: RawTransactionArgument; -} -export interface TotalSupplyOptions { - package: string; - arguments: TotalSupplyArguments | [cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return the total number of `T`'s in circulation. */ -export function totalSupply(options: TotalSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'total_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TreasuryIntoSupplyArguments { - treasury: RawTransactionArgument; -} -export interface TreasuryIntoSupplyOptions { - package: string; - arguments: TreasuryIntoSupplyArguments | [treasury: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Unwrap `TreasuryCap` getting the `Supply`. - * - * Operation is irreversible. Supply cannot be converted into a `TreasuryCap` due - * to different security guarantees (TreasuryCap can be created only once for a - * type) - */ -export function treasuryIntoSupply(options: TreasuryIntoSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['treasury']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'treasury_into_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SupplyImmutArguments { - treasury: RawTransactionArgument; -} -export interface SupplyImmutOptions { - package: string; - arguments: SupplyImmutArguments | [treasury: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get immutable reference to the treasury's `Supply`. */ -export function supplyImmut(options: SupplyImmutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['treasury']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'supply_immut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SupplyMutArguments { - treasury: RawTransactionArgument; -} -export interface SupplyMutOptions { - package: string; - arguments: SupplyMutArguments | [treasury: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get mutable reference to the treasury's `Supply`. */ -export function supplyMut(options: SupplyMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['treasury']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'supply_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ValueArguments { - self: RawTransactionArgument; -} -export interface ValueOptions { - package: string; - arguments: ValueArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Public getter for the coin's value */ -export function value(options: ValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BalanceArguments { - coin: RawTransactionArgument; -} -export interface BalanceOptions { - package: string; - arguments: BalanceArguments | [coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get immutable reference to the balance of a coin. */ -export function balance(options: BalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BalanceMutArguments { - coin: RawTransactionArgument; -} -export interface BalanceMutOptions { - package: string; - arguments: BalanceMutArguments | [coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get a mutable reference to the balance of a coin. */ -export function balanceMut(options: BalanceMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'balance_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromBalanceArguments { - balance: RawTransactionArgument; -} -export interface FromBalanceOptions { - package: string; - arguments: FromBalanceArguments | [balance: RawTransactionArgument]; - typeArguments: [string]; -} -/** Wrap a balance into a Coin to make it transferable. */ -export function fromBalance(options: FromBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'from_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IntoBalanceArguments { - coin: RawTransactionArgument; -} -export interface IntoBalanceOptions { - package: string; - arguments: IntoBalanceArguments | [coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destruct a Coin wrapper and keep the balance. */ -export function intoBalance(options: IntoBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'into_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TakeArguments { - balance: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface TakeOptions { - package: string; - arguments: - | TakeArguments - | [balance: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Take a `Coin` worth of `value` from `Balance`. Aborts if `value > balance.value` */ -export function take(options: TakeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['balance', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'take', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PutArguments { - balance: RawTransactionArgument; - coin: RawTransactionArgument; -} -export interface PutOptions { - package: string; - arguments: - | PutArguments - | [balance: RawTransactionArgument, coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** Put a `Coin` to the `Balance`. */ -export function put(options: PutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['balance', 'coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'put', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RedeemFundsArguments { - withdrawal: RawTransactionArgument; -} -export interface RedeemFundsOptions { - package: string; - arguments: RedeemFundsArguments | [withdrawal: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Redeem a `Withdrawal>` and create a `Coin` from the withdrawn - * Balance. - */ -export function redeemFunds(options: RedeemFundsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['withdrawal']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'redeem_funds', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SendFundsArguments { - coin: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface SendFundsOptions { - package: string; - arguments: - | SendFundsArguments - | [coin: RawTransactionArgument, recipient: RawTransactionArgument]; - typeArguments: [string]; -} -/** Send a coin to an address balance */ -export function sendFunds(options: SendFundsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['coin', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'send_funds', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface JoinArguments { - self: RawTransactionArgument; - c: RawTransactionArgument; -} -export interface JoinOptions { - package: string; - arguments: - | JoinArguments - | [self: RawTransactionArgument, c: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Consume the coin `c` and add its value to `self`. Aborts if - * `c.value + self.value > U64_MAX` - */ -export function join(options: JoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'c']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'join', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitArguments { - self: RawTransactionArgument; - splitAmount: RawTransactionArgument; -} -export interface SplitOptions { - package: string; - arguments: - | SplitArguments - | [self: RawTransactionArgument, splitAmount: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Split coin `self` to two coins, one with balance `split_amount`, and the - * remaining balance is left is `self`. - */ -export function split(options: SplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'splitAmount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DivideIntoNArguments { - self: RawTransactionArgument; - n: RawTransactionArgument; -} -export interface DivideIntoNOptions { - package: string; - arguments: - | DivideIntoNArguments - | [self: RawTransactionArgument, n: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Split coin `self` into `n - 1` coins with equal balances. The remainder is left - * in `self`. Return newly created coins. - */ -export function divideIntoN(options: DivideIntoNOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'n']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'divide_into_n', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ZeroOptions { - package: string; - arguments?: []; - typeArguments: [string]; -} -/** - * Make any Coin with a zero value. Useful for placeholding bids/payments or - * preemptively making empty balances. - */ -export function zero(options: ZeroOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'zero', - typeArguments: options.typeArguments, - }); -} -export interface DestroyZeroArguments { - c: RawTransactionArgument; -} -export interface DestroyZeroOptions { - package: string; - arguments: DestroyZeroArguments | [c: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destroy a coin with value zero */ -export function destroyZero(options: DestroyZeroOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['c']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'destroy_zero', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateCurrencyArguments> { - witness: RawTransactionArgument; - decimals: RawTransactionArgument; - symbol: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - iconUrl: RawTransactionArgument; -} -export interface CreateCurrencyOptions> { - package: string; - arguments: - | CreateCurrencyArguments - | [ - witness: RawTransactionArgument, - decimals: RawTransactionArgument, - symbol: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - iconUrl: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Create a new currency type `T` as and return the `TreasuryCap` for `T` to the - * caller. Can only be called with a `one-time-witness` type, ensuring that there's - * only one `TreasuryCap` per `T`. - */ -export function createCurrency>(options: CreateCurrencyOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - 'u8', - 'vector', - 'vector', - 'vector', - '0x1::option::Option', - ] satisfies (string | null)[]; - const parameterNames = ['witness', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'create_currency', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateRegulatedCurrencyV2Arguments> { - witness: RawTransactionArgument; - decimals: RawTransactionArgument; - symbol: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - iconUrl: RawTransactionArgument; - allowGlobalPause: RawTransactionArgument; -} -export interface CreateRegulatedCurrencyV2Options> { - package: string; - arguments: - | CreateRegulatedCurrencyV2Arguments - | [ - witness: RawTransactionArgument, - decimals: RawTransactionArgument, - symbol: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - iconUrl: RawTransactionArgument, - allowGlobalPause: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * This creates a new currency, via `create_currency`, but with an extra capability - * that allows for specific addresses to have their coins frozen. When an address - * is added to the deny list, it is immediately unable to interact with the - * currency's coin as input objects. Additionally at the start of the next epoch, - * they will be unable to receive the currency's coin. The `allow_global_pause` - * flag enables an additional API that will cause all addresses to be denied. Note - * however, that this doesn't affect per-address entries of the deny list and will - * not change the result of the "contains" APIs. - */ -export function createRegulatedCurrencyV2>( - options: CreateRegulatedCurrencyV2Options, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - 'u8', - 'vector', - 'vector', - 'vector', - '0x1::option::Option', - 'bool', - ] satisfies (string | null)[]; - const parameterNames = [ - 'witness', - 'decimals', - 'symbol', - 'name', - 'description', - 'iconUrl', - 'allowGlobalPause', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'create_regulated_currency_v2', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MigrateRegulatedCurrencyToV2Arguments { - cap: RawTransactionArgument; - allowGlobalPause: RawTransactionArgument; -} -export interface MigrateRegulatedCurrencyToV2Options { - package: string; - arguments: - | MigrateRegulatedCurrencyToV2Arguments - | [cap: RawTransactionArgument, allowGlobalPause: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Given the `DenyCap` for a regulated currency, migrate it to the new `DenyCapV2` - * type. All entries in the deny list will be migrated to the new format. See - * `create_regulated_currency_v2` for details on the new v2 of the deny list. - */ -export function migrateRegulatedCurrencyToV2(options: MigrateRegulatedCurrencyToV2Options) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null, 'bool'] satisfies (string | null)[]; - const parameterNames = ['cap', 'allowGlobalPause']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'migrate_regulated_currency_to_v2', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MintArguments { - cap: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface MintOptions { - package: string; - arguments: - | MintArguments - | [cap: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a coin worth `value` and increase the total supply in `cap` accordingly. */ -export function mint(options: MintOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['cap', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'mint', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MintBalanceArguments { - cap: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface MintBalanceOptions { - package: string; - arguments: - | MintBalanceArguments - | [cap: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Mint some amount of T as a `Balance` and increase the total supply in `cap` - * accordingly. Aborts if `value` + `cap.total_supply` >= U64_MAX - */ -export function mintBalance(options: MintBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['cap', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'mint_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BurnArguments { - cap: RawTransactionArgument; - c: RawTransactionArgument; -} -export interface BurnOptions { - package: string; - arguments: - | BurnArguments - | [cap: RawTransactionArgument, c: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destroy the coin `c` and decrease the total supply in `cap` accordingly. */ -export function burn(options: BurnOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['cap', 'c']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'burn', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2AddArguments { - DenyCap: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface DenyListV2AddOptions { - package: string; - arguments: - | DenyListV2AddArguments - | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Adds the given address to the deny list, preventing it from interacting with the - * specified coin type as an input to a transaction. Additionally at the start of - * the next epoch, the address will be unable to receive objects of this coin type. - */ -export function denyListV2Add(options: DenyListV2AddOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; - const parameterNames = ['DenyCap', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2RemoveArguments { - DenyCap: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface DenyListV2RemoveOptions { - package: string; - arguments: - | DenyListV2RemoveArguments - | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Removes an address from the deny list. Similar to `deny_list_v2_add`, the effect - * for input objects will be immediate, but the effect for receiving objects will - * be delayed until the next epoch. - */ -export function denyListV2Remove(options: DenyListV2RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; - const parameterNames = ['DenyCap', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2ContainsCurrentEpochArguments { - addr: RawTransactionArgument; -} -export interface DenyListV2ContainsCurrentEpochOptions { - package: string; - arguments: DenyListV2ContainsCurrentEpochArguments | [addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Check if the deny list contains the given address for the current epoch. Denied - * addresses in the current epoch will be unable to receive objects of this coin - * type. - */ -export function denyListV2ContainsCurrentEpoch(options: DenyListV2ContainsCurrentEpochOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; - const parameterNames = ['addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_contains_current_epoch', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2ContainsNextEpochArguments { - addr: RawTransactionArgument; -} -export interface DenyListV2ContainsNextEpochOptions { - package: string; - arguments: DenyListV2ContainsNextEpochArguments | [addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Check if the deny list contains the given address for the next epoch. Denied - * addresses in the next epoch will immediately be unable to use objects of this - * coin type as inputs. At the start of the next epoch, the address will be unable - * to receive objects of this coin type. - */ -export function denyListV2ContainsNextEpoch(options: DenyListV2ContainsNextEpochOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; - const parameterNames = ['addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_contains_next_epoch', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2EnableGlobalPauseArguments { - denyCap: RawTransactionArgument; -} -export interface DenyListV2EnableGlobalPauseOptions { - package: string; - arguments: DenyListV2EnableGlobalPauseArguments | [denyCap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Enable the global pause for the given coin type. This will immediately prevent - * all addresses from using objects of this coin type as inputs. At the start of - * the next epoch, all addresses will be unable to receive objects of this coin - * type. - */ -export function denyListV2EnableGlobalPause(options: DenyListV2EnableGlobalPauseOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null] satisfies (string | null)[]; - const parameterNames = ['denyCap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_enable_global_pause', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2DisableGlobalPauseArguments { - denyCap: RawTransactionArgument; -} -export interface DenyListV2DisableGlobalPauseOptions { - package: string; - arguments: DenyListV2DisableGlobalPauseArguments | [denyCap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Disable the global pause for the given coin type. This will immediately allow - * all addresses to resume using objects of this coin type as inputs. However, - * receiving objects of this coin type will still be paused until the start of the - * next epoch. - */ -export function denyListV2DisableGlobalPause(options: DenyListV2DisableGlobalPauseOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null] satisfies (string | null)[]; - const parameterNames = ['denyCap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_disable_global_pause', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2IsGlobalPauseEnabledCurrentEpochArguments {} -export interface DenyListV2IsGlobalPauseEnabledCurrentEpochOptions { - package: string; - arguments?: DenyListV2IsGlobalPauseEnabledCurrentEpochArguments | []; - typeArguments: [string]; -} -/** - * Check if the global pause is enabled for the given coin type in the current - * epoch. - */ -export function denyListV2IsGlobalPauseEnabledCurrentEpoch( - options: DenyListV2IsGlobalPauseEnabledCurrentEpochOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_is_global_pause_enabled_current_epoch', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListV2IsGlobalPauseEnabledNextEpochArguments {} -export interface DenyListV2IsGlobalPauseEnabledNextEpochOptions { - package: string; - arguments?: DenyListV2IsGlobalPauseEnabledNextEpochArguments | []; - typeArguments: [string]; -} -/** Check if the global pause is enabled for the given coin type in the next epoch. */ -export function denyListV2IsGlobalPauseEnabledNextEpoch( - options: DenyListV2IsGlobalPauseEnabledNextEpochOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_v2_is_global_pause_enabled_next_epoch', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MintAndTransferArguments { - c: RawTransactionArgument; - amount: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface MintAndTransferOptions { - package: string; - arguments: - | MintAndTransferArguments - | [ - c: RawTransactionArgument, - amount: RawTransactionArgument, - recipient: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Mint `amount` of `Coin` and send it to `recipient`. Invokes `mint()`. */ -export function mintAndTransfer(options: MintAndTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', 'address'] satisfies (string | null)[]; - const parameterNames = ['c', 'amount', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'mint_and_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateNameArguments { - Treasury: RawTransactionArgument; - metadata: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface UpdateNameOptions { - package: string; - arguments: - | UpdateNameArguments - | [ - Treasury: RawTransactionArgument, - metadata: RawTransactionArgument, - name: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update name of the coin in `CoinMetadata` */ -export function updateName(options: UpdateNameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['Treasury', 'metadata', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'update_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateSymbolArguments { - Treasury: RawTransactionArgument; - metadata: RawTransactionArgument; - symbol: RawTransactionArgument; -} -export interface UpdateSymbolOptions { - package: string; - arguments: - | UpdateSymbolArguments - | [ - Treasury: RawTransactionArgument, - metadata: RawTransactionArgument, - symbol: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the symbol of the coin in `CoinMetadata` */ -export function updateSymbol(options: UpdateSymbolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['Treasury', 'metadata', 'symbol']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'update_symbol', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateDescriptionArguments { - Treasury: RawTransactionArgument; - metadata: RawTransactionArgument; - description: RawTransactionArgument; -} -export interface UpdateDescriptionOptions { - package: string; - arguments: - | UpdateDescriptionArguments - | [ - Treasury: RawTransactionArgument, - metadata: RawTransactionArgument, - description: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the description of the coin in `CoinMetadata` */ -export function updateDescription(options: UpdateDescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['Treasury', 'metadata', 'description']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'update_description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateIconUrlArguments { - Treasury: RawTransactionArgument; - metadata: RawTransactionArgument; - url: RawTransactionArgument; -} -export interface UpdateIconUrlOptions { - package: string; - arguments: - | UpdateIconUrlArguments - | [ - Treasury: RawTransactionArgument, - metadata: RawTransactionArgument, - url: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the url of the coin in `CoinMetadata` */ -export function updateIconUrl(options: UpdateIconUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['Treasury', 'metadata', 'url']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'update_icon_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetDecimalsArguments { - metadata: RawTransactionArgument; -} -export interface GetDecimalsOptions { - package: string; - arguments: GetDecimalsArguments | [metadata: RawTransactionArgument]; - typeArguments: [string]; -} -export function getDecimals(options: GetDecimalsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'get_decimals', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetNameArguments { - metadata: RawTransactionArgument; -} -export interface GetNameOptions { - package: string; - arguments: GetNameArguments | [metadata: RawTransactionArgument]; - typeArguments: [string]; -} -export function getName(options: GetNameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'get_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetSymbolArguments { - metadata: RawTransactionArgument; -} -export interface GetSymbolOptions { - package: string; - arguments: GetSymbolArguments | [metadata: RawTransactionArgument]; - typeArguments: [string]; -} -export function getSymbol(options: GetSymbolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'get_symbol', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetDescriptionArguments { - metadata: RawTransactionArgument; -} -export interface GetDescriptionOptions { - package: string; - arguments: GetDescriptionArguments | [metadata: RawTransactionArgument]; - typeArguments: [string]; -} -export function getDescription(options: GetDescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'get_description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetIconUrlArguments { - metadata: RawTransactionArgument; -} -export interface GetIconUrlOptions { - package: string; - arguments: GetIconUrlArguments | [metadata: RawTransactionArgument]; - typeArguments: [string]; -} -export function getIconUrl(options: GetIconUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'get_icon_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SupplyArguments { - treasury: RawTransactionArgument; -} -export interface SupplyOptions { - package: string; - arguments: SupplyArguments | [treasury: RawTransactionArgument]; - typeArguments: [string]; -} -export function supply(options: SupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['treasury']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateRegulatedCurrencyArguments> { - witness: RawTransactionArgument; - decimals: RawTransactionArgument; - symbol: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - iconUrl: RawTransactionArgument; -} -export interface CreateRegulatedCurrencyOptions> { - package: string; - arguments: - | CreateRegulatedCurrencyArguments - | [ - witness: RawTransactionArgument, - decimals: RawTransactionArgument, - symbol: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - iconUrl: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * This creates a new currency, via `create_currency`, but with an extra capability - * that allows for specific addresses to have their coins frozen. Those addresses - * cannot interact with the coin as input objects. - */ -export function createRegulatedCurrency>( - options: CreateRegulatedCurrencyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - 'u8', - 'vector', - 'vector', - 'vector', - '0x1::option::Option', - ] satisfies (string | null)[]; - const parameterNames = ['witness', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'create_regulated_currency', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListAddArguments { - DenyCap: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface DenyListAddOptions { - package: string; - arguments: - | DenyListAddArguments - | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Adds the given address to the deny list, preventing it from interacting with the - * specified coin type as an input to a transaction. - */ -export function denyListAdd(options: DenyListAddOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; - const parameterNames = ['DenyCap', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListRemoveArguments { - DenyCap: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface DenyListRemoveOptions { - package: string; - arguments: - | DenyListRemoveArguments - | [DenyCap: RawTransactionArgument, addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Removes an address from the deny list. Aborts with `ENotFrozen` if the address - * is not already in the list. - */ -export function denyListRemove(options: DenyListRemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', null, 'address'] satisfies (string | null)[]; - const parameterNames = ['DenyCap', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyListContainsArguments { - addr: RawTransactionArgument; -} -export interface DenyListContainsOptions { - package: string; - arguments: DenyListContainsArguments | [addr: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns true iff the given address is denied for the given coin type. It will - * return false if given a non-coin type. - */ -export function denyListContains(options: DenyListContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::deny_list::DenyList', 'address'] satisfies (string | null)[]; - const parameterNames = ['addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin', - function: 'deny_list_contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts b/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts deleted file mode 100644 index 405c9567c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/coin_registry.ts +++ /dev/null @@ -1,1236 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Defines the system object for managing coin data in a central registry. This - * module provides a centralized way to store and manage metadata for all - * currencies in the Sui ecosystem, including their supply information, regulatory - * status, and metadata capabilities. - */ - -import { - MoveStruct, - MoveTuple, - MoveEnum, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as type_name from '../suins_auction/type_name.js'; -import * as balance from './balance.js'; -import * as vec_map from './vec_map.js'; -import * as bag from './bag.js'; -const $moduleName = '0x2::coin_registry'; -export const CoinRegistry = new MoveStruct({ - name: `${$moduleName}::CoinRegistry`, - fields: { - id: bcs.Address, - }, -}); -export const ExtraField = new MoveTuple({ - name: `${$moduleName}::ExtraField`, - fields: [type_name.TypeName, bcs.vector(bcs.u8())], -}); -export const CurrencyKey = new MoveTuple({ - name: `${$moduleName}::CurrencyKey`, - fields: [bcs.bool()], -}); -export const LegacyMetadataKey = new MoveTuple({ - name: `${$moduleName}::LegacyMetadataKey`, - fields: [bcs.bool()], -}); -export const MetadataCap = new MoveStruct({ - name: `${$moduleName}::MetadataCap`, - fields: { - id: bcs.Address, - }, -}); -export const Borrow = new MoveStruct({ - name: `${$moduleName}::Borrow`, - fields: { - dummy_field: bcs.bool(), - }, -}); -/** - * Supply state marks the type of Currency Supply, which can be - * - * - Fixed: no minting or burning; - * - BurnOnly: no minting, burning is allowed; - * - Unknown: flexible (supply is controlled by its `TreasuryCap`); - */ -export const SupplyState = new MoveEnum({ - name: `${$moduleName}::SupplyState`, - fields: { - /** Coin has a fixed supply with the given Supply object. */ - Fixed: balance.Supply, - /** Coin has a supply that can ONLY decrease. */ - BurnOnly: balance.Supply, - /** Supply information is not yet known or registered. */ - Unknown: null, - }, -}); -/** - * Regulated state of a coin type. - * - * - Regulated: `DenyCap` exists or a `RegulatedCoinMetadata` used to mark currency - * as regulated; - * - Unregulated: the currency was created without deny list; - * - Unknown: the regulatory status is unknown. - */ -export const RegulatedState = new MoveEnum({ - name: `${$moduleName}::RegulatedState`, - fields: { - /** - * Coin is regulated with a deny cap for address restrictions. `allow_global_pause` - * is `None` if the information is unknown (has not been migrated from - * `DenyCapV2`). - */ - Regulated: new MoveStruct({ - name: `RegulatedState.Regulated`, - fields: { - cap: bcs.Address, - allow_global_pause: bcs.option(bcs.bool()), - variant: bcs.u8(), - }, - }), - /** The coin has been created without deny list. */ - Unregulated: null, - /** - * Regulatory status is unknown. Result of a legacy migration for that coin (from - * `coin.move` constructors) - */ - Unknown: null, - }, -}); -/** State of the `MetadataCap` for a single `Currency`. */ -export const MetadataCapState = new MoveEnum({ - name: `${$moduleName}::MetadataCapState`, - fields: { - /** The metadata cap has been claimed. */ - Claimed: bcs.Address, - /** The metadata cap has not been claimed. */ - Unclaimed: null, - /** The metadata cap has been claimed and then deleted. */ - Deleted: null, - }, -}); -export const Currency = new MoveStruct({ - name: `${$moduleName}::Currency`, - fields: { - id: bcs.Address, - /** Number of decimal places the coin uses for display purposes. */ - decimals: bcs.u8(), - /** Human-readable name for the coin. */ - name: bcs.string(), - /** Short symbol/ticker for the coin. */ - symbol: bcs.string(), - /** Detailed description of the coin. */ - description: bcs.string(), - /** URL for the coin's icon/logo. */ - icon_url: bcs.string(), - /** - * Current supply state of the coin (fixed supply or unknown) Note: We're using - * `Option` because `SupplyState` does not have drop, meaning we cannot swap out - * its value at a later state. - */ - supply: bcs.option(SupplyState), - /** Regulatory status of the coin (regulated with deny cap or unknown) */ - regulated: RegulatedState, - /** ID of the treasury cap for this coin type, if registered. */ - treasury_cap_id: bcs.option(bcs.Address), - /** ID of the metadata capability for this coin type, if claimed. */ - metadata_cap_id: MetadataCapState, - /** Additional fields for extensibility. */ - extra_fields: vec_map.VecMap(bcs.string(), ExtraField), - }, -}); -export const CurrencyInitializer = new MoveStruct({ - name: `${$moduleName}::CurrencyInitializer`, - fields: { - currency: Currency, - extra_fields: bag.Bag, - is_otw: bcs.bool(), - }, -}); -export interface NewCurrencyArguments { - registry: RawTransactionArgument; - decimals: RawTransactionArgument; - symbol: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - iconUrl: RawTransactionArgument; -} -export interface NewCurrencyOptions { - package: string; - arguments: - | NewCurrencyArguments - | [ - registry: RawTransactionArgument, - decimals: RawTransactionArgument, - symbol: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - iconUrl: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Creates a new currency. - * - * Note: This constructor has no long term difference from `new_currency_with_otw`. - * This can be called from the module that defines `T` any time after it has been - * published. - */ -export function newCurrency(options: NewCurrencyOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - 'u8', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - ] satisfies (string | null)[]; - const parameterNames = ['registry', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'new_currency', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewCurrencyWithOtwArguments> { - otw: RawTransactionArgument; - decimals: RawTransactionArgument; - symbol: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - iconUrl: RawTransactionArgument; -} -export interface NewCurrencyWithOtwOptions> { - package: string; - arguments: - | NewCurrencyWithOtwArguments - | [ - otw: RawTransactionArgument, - decimals: RawTransactionArgument, - symbol: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - iconUrl: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Creates a new currency with using an OTW as proof of uniqueness. - * - * This is a two-step operation: - * - * 1. `Currency` is constructed in the `init` function and sent to the - * `CoinRegistry`; - * 2. `Currency` is promoted to a shared object in the `finalize_registration` - * call; - */ -export function newCurrencyWithOtw>(options: NewCurrencyWithOtwOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - 'u8', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - ] satisfies (string | null)[]; - const parameterNames = ['otw', 'decimals', 'symbol', 'name', 'description', 'iconUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'new_currency_with_otw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ClaimMetadataCapArguments { - currency: RawTransactionArgument; - _: RawTransactionArgument; -} -export interface ClaimMetadataCapOptions { - package: string; - arguments: - | ClaimMetadataCapArguments - | [currency: RawTransactionArgument, _: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Claim a `MetadataCap` for a coin type. Only allowed from the owner of - * `TreasuryCap`, and only once. - * - * Aborts if the `MetadataCap` has already been claimed. Deleted `MetadataCap` - * cannot be reclaimed. - */ -export function claimMetadataCap(options: ClaimMetadataCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', '_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'claim_metadata_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MakeRegulatedArguments { - init: RawTransactionArgument; - allowGlobalPause: RawTransactionArgument; -} -export interface MakeRegulatedOptions { - package: string; - arguments: - | MakeRegulatedArguments - | [init: RawTransactionArgument, allowGlobalPause: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Allows converting a currency, on init, to regulated, which creates a `DenyCapV2` - * object, and a denylist entry. Sets regulated state to `Regulated`. - * - * This action is irreversible. - */ -export function makeRegulated(options: MakeRegulatedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'bool'] satisfies (string | null)[]; - const parameterNames = ['init', 'allowGlobalPause']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'make_regulated', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MakeSupplyFixedInitArguments { - init: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface MakeSupplyFixedInitOptions { - package: string; - arguments: - | MakeSupplyFixedInitArguments - | [init: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Initializer function to make the supply fixed. Aborts if Supply is `0` to - * enforce minting during initialization. - */ -export function makeSupplyFixedInit(options: MakeSupplyFixedInitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['init', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'make_supply_fixed_init', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MakeSupplyBurnOnlyInitArguments { - init: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface MakeSupplyBurnOnlyInitOptions { - package: string; - arguments: - | MakeSupplyBurnOnlyInitArguments - | [init: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Initializer function to make the supply burn-only. Aborts if Supply is `0` to - * enforce minting during initialization. - */ -export function makeSupplyBurnOnlyInit(options: MakeSupplyBurnOnlyInitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['init', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'make_supply_burn_only_init', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MakeSupplyFixedArguments { - currency: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface MakeSupplyFixedOptions { - package: string; - arguments: - | MakeSupplyFixedArguments - | [currency: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Freeze the supply by destroying the `TreasuryCap` and storing it in the - * `Currency`. - */ -export function makeSupplyFixed(options: MakeSupplyFixedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'make_supply_fixed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MakeSupplyBurnOnlyArguments { - currency: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface MakeSupplyBurnOnlyOptions { - package: string; - arguments: - | MakeSupplyBurnOnlyArguments - | [currency: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Make the supply `BurnOnly` by giving up the `TreasuryCap`, and allowing burning - * of Coins through the `Currency`. - */ -export function makeSupplyBurnOnly(options: MakeSupplyBurnOnlyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'make_supply_burn_only', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FinalizeArguments { - builder: RawTransactionArgument; -} -export interface FinalizeOptions { - package: string; - arguments: FinalizeArguments | [builder: RawTransactionArgument]; - typeArguments: [string]; -} -/** Finalize the coin initialization, returning `MetadataCap` */ -export function finalize(options: FinalizeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['builder']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'finalize', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FinalizeAndDeleteMetadataCapArguments { - builder: RawTransactionArgument; -} -export interface FinalizeAndDeleteMetadataCapOptions { - package: string; - arguments: FinalizeAndDeleteMetadataCapArguments | [builder: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Does the same as `finalize`, but also deletes the `MetadataCap` after - * finalization. - */ -export function finalizeAndDeleteMetadataCap(options: FinalizeAndDeleteMetadataCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['builder']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'finalize_and_delete_metadata_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FinalizeRegistrationArguments { - registry: RawTransactionArgument; - currency: RawTransactionArgument; -} -export interface FinalizeRegistrationOptions { - package: string; - arguments: - | FinalizeRegistrationArguments - | [registry: RawTransactionArgument, currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * The second step in the "otw" initialization of coin metadata, that takes in the - * `Currency` that was transferred from init, and transforms it in to a "derived - * address" shared object. - * - * Can be performed by anyone. - */ -export function finalizeRegistration(options: FinalizeRegistrationOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['registry', 'currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'finalize_registration', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DeleteMetadataCapArguments { - currency: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface DeleteMetadataCapOptions { - package: string; - arguments: - | DeleteMetadataCapArguments - | [currency: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Delete the metadata cap making further updates of `Currency` metadata - * impossible. This action is IRREVERSIBLE, and the `MetadataCap` can no longer be - * claimed. - */ -export function deleteMetadataCap(options: DeleteMetadataCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'delete_metadata_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BurnArguments { - currency: RawTransactionArgument; - coin: RawTransactionArgument; -} -export interface BurnOptions { - package: string; - arguments: - | BurnArguments - | [currency: RawTransactionArgument, coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** Burn the `Coin` if the `Currency` has a `BurnOnly` supply state. */ -export function burn(options: BurnOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'burn', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BurnBalanceArguments { - currency: RawTransactionArgument; - balance: RawTransactionArgument; -} -export interface BurnBalanceOptions { - package: string; - arguments: - | BurnBalanceArguments - | [currency: RawTransactionArgument, balance: RawTransactionArgument]; - typeArguments: [string]; -} -/** Burn the `Balance` if the `Currency` has a `BurnOnly` supply state. */ -export function burnBalance(options: BurnBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'burn_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SetNameArguments { - currency: RawTransactionArgument; - _: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface SetNameOptions { - package: string; - arguments: - | SetNameArguments - | [ - currency: RawTransactionArgument, - _: RawTransactionArgument, - name: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the name of the `Currency`. */ -export function setName(options: SetNameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['currency', '_', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'set_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SetDescriptionArguments { - currency: RawTransactionArgument; - _: RawTransactionArgument; - description: RawTransactionArgument; -} -export interface SetDescriptionOptions { - package: string; - arguments: - | SetDescriptionArguments - | [ - currency: RawTransactionArgument, - _: RawTransactionArgument, - description: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the description of the `Currency`. */ -export function setDescription(options: SetDescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['currency', '_', 'description']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'set_description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SetIconUrlArguments { - currency: RawTransactionArgument; - _: RawTransactionArgument; - iconUrl: RawTransactionArgument; -} -export interface SetIconUrlOptions { - package: string; - arguments: - | SetIconUrlArguments - | [ - currency: RawTransactionArgument, - _: RawTransactionArgument, - iconUrl: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Update the icon URL of the `Currency`. */ -export function setIconUrl(options: SetIconUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['currency', '_', 'iconUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'set_icon_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SetTreasuryCapIdArguments { - currency: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface SetTreasuryCapIdOptions { - package: string; - arguments: - | SetTreasuryCapIdArguments - | [currency: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Register the treasury cap ID for a migrated `Currency`. All currencies created - * with `new_currency` or `new_currency_with_otw` have their treasury cap ID set - * during initialization. - */ -export function setTreasuryCapId(options: SetTreasuryCapIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'set_treasury_cap_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MigrateLegacyMetadataArguments { - registry: RawTransactionArgument; - legacy: RawTransactionArgument; -} -export interface MigrateLegacyMetadataOptions { - package: string; - arguments: - | MigrateLegacyMetadataArguments - | [registry: RawTransactionArgument, legacy: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Register `CoinMetadata` in the `CoinRegistry`. This can happen only once, if the - * `Currency` did not exist yet. Further updates are possible through - * `update_from_legacy_metadata`. - */ -export function migrateLegacyMetadata(options: MigrateLegacyMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['registry', 'legacy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'migrate_legacy_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateFromLegacyMetadataArguments { - currency: RawTransactionArgument; - legacy: RawTransactionArgument; -} -export interface UpdateFromLegacyMetadataOptions { - package: string; - arguments: - | UpdateFromLegacyMetadataArguments - | [currency: RawTransactionArgument, legacy: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Update `Currency` from `CoinMetadata` if the `MetadataCap` is not claimed. After - * the `MetadataCap` is claimed, updates can only be made through `set_*` - * functions. - */ -export function updateFromLegacyMetadata(options: UpdateFromLegacyMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'legacy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'update_from_legacy_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DeleteMigratedLegacyMetadataOptions { - package: string; - arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; - typeArguments: [string]; -} -export function deleteMigratedLegacyMetadata(options: DeleteMigratedLegacyMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'delete_migrated_legacy_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - typeArguments: options.typeArguments, - }); -} -export interface MigrateRegulatedStateByMetadataArguments { - currency: RawTransactionArgument; - metadata: RawTransactionArgument; -} -export interface MigrateRegulatedStateByMetadataOptions { - package: string; - arguments: - | MigrateRegulatedStateByMetadataArguments - | [currency: RawTransactionArgument, metadata: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Allow migrating the regulated state by access to `RegulatedCoinMetadata` frozen - * object. This is a permissionless operation which can be performed only once. - */ -export function migrateRegulatedStateByMetadata(options: MigrateRegulatedStateByMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'migrate_regulated_state_by_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MigrateRegulatedStateByCapArguments { - currency: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface MigrateRegulatedStateByCapOptions { - package: string; - arguments: - | MigrateRegulatedStateByCapArguments - | [currency: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** Mark regulated state by showing the `DenyCapV2` object for the `Currency`. */ -export function migrateRegulatedStateByCap(options: MigrateRegulatedStateByCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'migrate_regulated_state_by_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowLegacyMetadataArguments { - currency: RawTransactionArgument; -} -export interface BorrowLegacyMetadataOptions { - package: string; - arguments: BorrowLegacyMetadataArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Borrow the legacy `CoinMetadata` from a new `Currency`. To preserve the `ID` of - * the legacy `CoinMetadata`, we create it on request and then store it as a - * dynamic field for future borrows. - * - * `Borrow` ensures that the `CoinMetadata` is returned in the same transaction. - */ -export function borrowLegacyMetadata(options: BorrowLegacyMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'borrow_legacy_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ReturnBorrowedLegacyMetadataArguments { - currency: RawTransactionArgument; - legacy: RawTransactionArgument; - borrow: RawTransactionArgument; -} -export interface ReturnBorrowedLegacyMetadataOptions { - package: string; - arguments: - | ReturnBorrowedLegacyMetadataArguments - | [ - currency: RawTransactionArgument, - legacy: RawTransactionArgument, - borrow: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Return the borrowed `CoinMetadata` and the `Borrow` potato to the `Currency`. - * - * Note to self: Borrow requirement prevents deletion through this method. - */ -export function returnBorrowedLegacyMetadata(options: ReturnBorrowedLegacyMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null] satisfies (string | null)[]; - const parameterNames = ['currency', 'legacy', 'borrow']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'return_borrowed_legacy_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DecimalsArguments { - currency: RawTransactionArgument; -} -export interface DecimalsOptions { - package: string; - arguments: DecimalsArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the number of decimal places for the coin type. */ -export function decimals(options: DecimalsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'decimals', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NameArguments { - currency: RawTransactionArgument; -} -export interface NameOptions { - package: string; - arguments: NameArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the human-readable name of the coin. */ -export function name(options: NameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SymbolArguments { - currency: RawTransactionArgument; -} -export interface SymbolOptions { - package: string; - arguments: SymbolArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the symbol/ticker of the coin. */ -export function symbol(options: SymbolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'symbol', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DescriptionArguments { - currency: RawTransactionArgument; -} -export interface DescriptionOptions { - package: string; - arguments: DescriptionArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the description of the coin. */ -export function description(options: DescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IconUrlArguments { - currency: RawTransactionArgument; -} -export interface IconUrlOptions { - package: string; - arguments: IconUrlArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the icon URL for the coin. */ -export function iconUrl(options: IconUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'icon_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsMetadataCapClaimedArguments { - currency: RawTransactionArgument; -} -export interface IsMetadataCapClaimedOptions { - package: string; - arguments: IsMetadataCapClaimedArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if the metadata capability has been claimed for this `Currency` type. */ -export function isMetadataCapClaimed(options: IsMetadataCapClaimedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'is_metadata_cap_claimed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsMetadataCapDeletedArguments { - currency: RawTransactionArgument; -} -export interface IsMetadataCapDeletedOptions { - package: string; - arguments: IsMetadataCapDeletedArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if the metadata capability has been deleted for this `Currency` type. */ -export function isMetadataCapDeleted(options: IsMetadataCapDeletedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'is_metadata_cap_deleted', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MetadataCapIdArguments { - currency: RawTransactionArgument; -} -export interface MetadataCapIdOptions { - package: string; - arguments: MetadataCapIdArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the metadata cap ID, or none if it has not been claimed. */ -export function metadataCapId(options: MetadataCapIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'metadata_cap_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TreasuryCapIdArguments { - currency: RawTransactionArgument; -} -export interface TreasuryCapIdOptions { - package: string; - arguments: TreasuryCapIdArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the treasury cap ID for this coin type, if registered. */ -export function treasuryCapId(options: TreasuryCapIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'treasury_cap_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DenyCapIdArguments { - currency: RawTransactionArgument; -} -export interface DenyCapIdOptions { - package: string; - arguments: DenyCapIdArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get the deny cap ID for this coin type, if it's a regulated coin. Returns `None` - * if: - * - * - The `Currency` is not regulated; - * - The `Currency` is migrated from legacy, and its regulated state has not been - * set; - */ -export function denyCapId(options: DenyCapIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'deny_cap_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsSupplyFixedArguments { - currency: RawTransactionArgument; -} -export interface IsSupplyFixedOptions { - package: string; - arguments: IsSupplyFixedArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if the supply is fixed. */ -export function isSupplyFixed(options: IsSupplyFixedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'is_supply_fixed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsSupplyBurnOnlyArguments { - currency: RawTransactionArgument; -} -export interface IsSupplyBurnOnlyOptions { - package: string; - arguments: IsSupplyBurnOnlyArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if the supply is burn-only. */ -export function isSupplyBurnOnly(options: IsSupplyBurnOnlyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'is_supply_burn_only', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsRegulatedArguments { - currency: RawTransactionArgument; -} -export interface IsRegulatedOptions { - package: string; - arguments: IsRegulatedArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if the currency is regulated. */ -export function isRegulated(options: IsRegulatedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'is_regulated', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TotalSupplyArguments { - currency: RawTransactionArgument; -} -export interface TotalSupplyOptions { - package: string; - arguments: TotalSupplyArguments | [currency: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get the total supply for the `Currency` if the Supply is in fixed or - * burn-only state. Returns `None` if the SupplyState is Unknown. - */ -export function totalSupply(options: TotalSupplyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['currency']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'total_supply', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ExistsArguments { - registry: RawTransactionArgument; -} -export interface ExistsOptions { - package: string; - arguments: ExistsArguments | [registry: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if coin data exists for the given type T in the registry. */ -export function exists(options: ExistsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['registry']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'coin_registry', - function: 'exists', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/config.ts b/packages/suins/src/contracts/suins_auction/deps/sui/config.ts deleted file mode 100644 index 50e55d2de..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -const $moduleName = '0x2::config'; -export const Config = new MoveStruct({ - name: `${$moduleName}::Config`, - fields: { - id: bcs.Address, - }, -}); -export function SettingData>(...typeParameters: [Value]) { - return new MoveStruct({ - name: `${$moduleName}::SettingData<${typeParameters[0].name as Value['name']}>`, - fields: { - newer_value_epoch: bcs.u64(), - newer_value: bcs.option(typeParameters[0]), - older_value_opt: bcs.option(typeParameters[0]), - }, - }); -} -export function Setting>(...typeParameters: [Value]) { - return new MoveStruct({ - name: `${$moduleName}::Setting<${typeParameters[0].name as Value['name']}>`, - fields: { - data: bcs.option(SettingData(typeParameters[0])), - }, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts b/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts deleted file mode 100644 index 63cceff6f..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/deny_list.ts +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Defines the `DenyList` type. The `DenyList` shared object is used to restrict - * access to instances of certain core types from being used as inputs by specified - * addresses in the deny list. - */ - -import { MoveStruct, MoveTuple } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import * as bag from './bag.js'; -import * as table from './table.js'; -const $moduleName = '0x2::deny_list'; -export const DenyList = new MoveStruct({ - name: `${$moduleName}::DenyList`, - fields: { - id: bcs.Address, - /** The individual deny lists. */ - lists: bag.Bag, - }, -}); -export const ConfigWriteCap = new MoveTuple({ - name: `${$moduleName}::ConfigWriteCap`, - fields: [bcs.bool()], -}); -export const ConfigKey = new MoveStruct({ - name: `${$moduleName}::ConfigKey`, - fields: { - per_type_index: bcs.u64(), - per_type_key: bcs.vector(bcs.u8()), - }, -}); -export const AddressKey = new MoveTuple({ - name: `${$moduleName}::AddressKey`, - fields: [bcs.Address], -}); -export const GlobalPauseKey = new MoveTuple({ - name: `${$moduleName}::GlobalPauseKey`, - fields: [bcs.bool()], -}); -export const PerTypeConfigCreated = new MoveStruct({ - name: `${$moduleName}::PerTypeConfigCreated`, - fields: { - key: ConfigKey, - config_id: bcs.Address, - }, -}); -export const PerTypeList = new MoveStruct({ - name: `${$moduleName}::PerTypeList`, - fields: { - id: bcs.Address, - /** - * Number of object types that have been banned for a given address. Used to - * quickly skip checks for most addresses. - */ - denied_count: table.Table, - /** - * Set of addresses that are banned for a given type. For example with - * `sui::coin::Coin`: If addresses A and B are banned from using - * "0...0123::my_coin::MY_COIN", this will be "0...0123::my_coin::MY_COIN" -> {A, - * B}. - */ - denied_addresses: table.Table, - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts b/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts deleted file mode 100644 index 9820e693d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/derived_object.ts +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Enables the creation of objects with deterministic addresses derived from a - * parent object's UID. This module provides a way to generate objects with - * predictable addresses based on a parent UID and a key, creating a namespace that - * ensures uniqueness for each parent-key combination, which is usually how - * registries are built. - * - * Key features: - * - * - Deterministic address generation based on parent object UID and key - * - Derived objects can exist and operate independently of their parent - * - * The derived UIDs, once created, are independent and do not require sequencing on - * the parent object. They can be used without affecting the parent. The parent - * only maintains a record of which derived addresses have been claimed to prevent - * duplicates. - */ - -import { - MoveTuple, - MoveEnum, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::derived_object'; -export const Claimed = new MoveTuple({ name: `${$moduleName}::Claimed`, fields: [bcs.Address] }); -/** - * An internal key to protect from generating the same UID twice (e.g. collide with - * DFs) - */ -export function DerivedObjectKey>(...typeParameters: [K]) { - return new MoveTuple({ - name: `${$moduleName}::DerivedObjectKey<${typeParameters[0].name as K['name']}>`, - fields: [typeParameters[0]], - }); -} -/** - * The possible values of a claimed UID. We make it an enum to make upgradeability - * easier in the future. - */ -export const ClaimedStatus = new MoveEnum({ - name: `${$moduleName}::ClaimedStatus`, - fields: { - /** The UID has been claimed and cannot be re-claimed or used. */ - Reserved: null, - }, -}); -export interface ClaimArguments> { - parent: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface ClaimOptions> { - package: string; - arguments: - | ClaimArguments - | [parent: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Claim a deterministic UID, using the parent's UID & any key. */ -export function claim>(options: ClaimOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['parent', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'derived_object', - function: 'claim', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ExistsArguments> { - parent: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface ExistsOptions> { - package: string; - arguments: - | ExistsArguments - | [parent: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Checks if a provided `key` has been claimed for the given parent. Note: If the - * UID has been deleted through `object::delete`, this will always return true. - */ -export function exists>(options: ExistsOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['parent', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'derived_object', - function: 'exists', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DeriveAddressArguments> { - parent: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface DeriveAddressOptions> { - package: string; - arguments: - | DeriveAddressArguments - | [parent: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Given an ID and a Key, it calculates the derived address. */ -export function deriveAddress>(options: DeriveAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['parent', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'derived_object', - function: 'derive_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/display.ts b/packages/suins/src/contracts/suins_auction/deps/sui/display.ts deleted file mode 100644 index 30bada5a2..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/display.ts +++ /dev/null @@ -1,349 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Defines a Display struct which defines the way an Object should be displayed. - * The intention is to keep data as independent from its display as possible, - * protecting the development process and keeping it separate from the ecosystem - * agreements. - * - * Each of the fields of the Display object should allow for pattern substitution - * and filling-in the pieces using the data from the object T. - * - * More entry functions might be added in the future depending on the use cases. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from './vec_map.js'; -const $moduleName = '0x2::display'; -export const Display = new MoveStruct({ - name: `${$moduleName}::Display`, - fields: { - id: bcs.Address, - /** - * Contains fields for display. Currently supported fields are: name, link, image - * and description. - */ - fields: vec_map.VecMap(bcs.string(), bcs.string()), - /** Version that can only be updated manually by the Publisher. */ - version: bcs.u16(), - }, -}); -export const DisplayCreated = new MoveStruct({ - name: `${$moduleName}::DisplayCreated`, - fields: { - id: bcs.Address, - }, -}); -export const VersionUpdated = new MoveStruct({ - name: `${$moduleName}::VersionUpdated`, - fields: { - id: bcs.Address, - version: bcs.u16(), - fields: vec_map.VecMap(bcs.string(), bcs.string()), - }, -}); -export interface NewArguments { - pub: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [pub: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Create an empty Display object. It can either be shared empty or filled with - * data right away via cheaper `set_owned` method. - */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pub']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewWithFieldsArguments { - pub: RawTransactionArgument; - fields: RawTransactionArgument; - values: RawTransactionArgument; -} -export interface NewWithFieldsOptions { - package: string; - arguments: - | NewWithFieldsArguments - | [ - pub: RawTransactionArgument, - fields: RawTransactionArgument, - values: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Create a new Display object with a set of fields. */ -export function newWithFields(options: NewWithFieldsOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - 'vector<0x1::string::String>', - 'vector<0x1::string::String>', - ] satisfies (string | null)[]; - const parameterNames = ['pub', 'fields', 'values']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'new_with_fields', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateAndKeepArguments { - pub: RawTransactionArgument; -} -export interface CreateAndKeepOptions { - package: string; - arguments: CreateAndKeepArguments | [pub: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a new empty Display object and keep it. */ -export function createAndKeep(options: CreateAndKeepOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pub']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'create_and_keep', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpdateVersionArguments { - display: RawTransactionArgument; -} -export interface UpdateVersionOptions { - package: string; - arguments: UpdateVersionArguments | [display: RawTransactionArgument]; - typeArguments: [string]; -} -/** Manually bump the version and emit an event with the updated version's contents. */ -export function updateVersion(options: UpdateVersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['display']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'update_version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddArguments { - self: RawTransactionArgument; - name: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface AddOptions { - package: string; - arguments: - | AddArguments - | [ - self: RawTransactionArgument, - name: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Sets a custom `name` field with the `value`. */ -export function add(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String', '0x1::string::String'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'name', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddMultipleArguments { - self: RawTransactionArgument; - fields: RawTransactionArgument; - values: RawTransactionArgument; -} -export interface AddMultipleOptions { - package: string; - arguments: - | AddMultipleArguments - | [ - self: RawTransactionArgument, - fields: RawTransactionArgument, - values: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Sets multiple `fields` with `values`. */ -export function addMultiple(options: AddMultipleOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - 'vector<0x1::string::String>', - 'vector<0x1::string::String>', - ] satisfies (string | null)[]; - const parameterNames = ['self', 'fields', 'values']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'add_multiple', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface EditArguments { - self: RawTransactionArgument; - name: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface EditOptions { - package: string; - arguments: - | EditArguments - | [ - self: RawTransactionArgument, - name: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Change the value of the field. TODO (long run): version changes; */ -export function edit(options: EditOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String', '0x1::string::String'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'name', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'edit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments { - self: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface RemoveOptions { - package: string; - arguments: - | RemoveArguments - | [self: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string]; -} -/** Remove the key from the Display. */ -export function remove(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsAuthorizedArguments { - pub: RawTransactionArgument; -} -export interface IsAuthorizedOptions { - package: string; - arguments: IsAuthorizedArguments | [pub: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Authorization check; can be performed externally to implement protection rules - * for Display. - */ -export function isAuthorized(options: IsAuthorizedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pub']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'is_authorized', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface VersionArguments { - d: RawTransactionArgument; -} -export interface VersionOptions { - package: string; - arguments: VersionArguments | [d: RawTransactionArgument]; - typeArguments: [string]; -} -/** Read the `version` field. */ -export function version(options: VersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['d']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FieldsArguments { - d: RawTransactionArgument; -} -export interface FieldsOptions { - package: string; - arguments: FieldsArguments | [d: RawTransactionArgument]; - typeArguments: [string]; -} -/** Read the `fields` field. */ -export function fields(options: FieldsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['d']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'display', - function: 'fields', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts deleted file mode 100644 index 89fc1c85d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_field.ts +++ /dev/null @@ -1,273 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * In addition to the fields declared in its type definition, a Sui object can have - * dynamic fields that can be added after the object has been constructed. Unlike - * ordinary field names (which are always statically declared identifiers) a - * dynamic field name can be any value with the `copy`, `drop`, and `store` - * abilities, e.g. an integer, a boolean, or a string. This gives Sui programmers - * the flexibility to extend objects on-the-fly, and it also serves as a building - * block for core collection types - */ - -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::dynamic_field'; -/** Internal object used for storing the field and value */ -export function Field, Value extends BcsType>( - ...typeParameters: [Name, Value] -) { - return new MoveStruct({ - name: `${$moduleName}::Field<${typeParameters[0].name as Name['name']}, ${typeParameters[1].name as Value['name']}>`, - fields: { - /** - * Determined by the hash of the object ID, the field name value and it's type, - * i.e. hash(parent.id || name || Name) - */ - id: bcs.Address, - /** The value for the name of this field */ - name: typeParameters[0], - /** The value bound to this field */ - value: typeParameters[1], - }, - }); -} -export interface AddArguments, Value extends BcsType> { - object: RawTransactionArgument; - name: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface AddOptions, Value extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - object: RawTransactionArgument, - name: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a dynamic field to the object `object: &mut UID` at field specified by - * `name: Name`. Aborts with `EFieldAlreadyExists` if the object already has that - * field with that name. - */ -export function add, Value extends BcsType>( - options: AddOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x2::object::ID', - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['object', 'name', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutably borrows the `object`s dynamic field with the name specified by - * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a - * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but - * the value does not have the specified type. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the `object`s dynamic field with the name specified by - * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a - * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but - * the value does not have the specified type. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the `object`s dynamic field with the name specified by `name: Name` and - * returns the bound value. Aborts with `EFieldDoesNotExist` if the object does not - * have a field with that name. Aborts with `EFieldTypeMismatch` if the field - * exists, but the value does not have the specified type. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface Exists_Arguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface Exists_Options> { - package: string; - arguments: - | Exists_Arguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns true if and only if the `object` has a dynamic field with the name - * specified by `name: Name` but without specifying the `Value` type - */ -export function exists_>(options: Exists_Options) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'exists_', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveIfExistsArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface RemoveIfExistsOptions> { - package: string; - arguments: - | RemoveIfExistsArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the dynamic field if it exists. Returns the `some(Value)` if it exists - * or none otherwise. - */ -export function removeIfExists>(options: RemoveIfExistsOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'remove_if_exists', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ExistsWithTypeArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface ExistsWithTypeOptions> { - package: string; - arguments: - | ExistsWithTypeArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true if and only if the `object` has a dynamic field with the name - * specified by `name: Name` with an assigned value of type `Value`. - */ -export function existsWithType>(options: ExistsWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_field', - function: 'exists_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts b/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts deleted file mode 100644 index b4b439ee9..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/dynamic_object_field.ts +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Similar to `sui::dynamic_field`, this module allows for the access of dynamic - * fields. But unlike, `sui::dynamic_field` the values bound to these dynamic - * fields _must_ be objects themselves. This allows for the objects to still exist - * within in storage, which may be important for external tools. The difference is - * otherwise not observable from within Move. - */ - -import { type BcsType } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::dynamic_object_field'; -export function Wrapper>(...typeParameters: [Name]) { - return new MoveStruct({ - name: `${$moduleName}::Wrapper<${typeParameters[0].name as Name['name']}>`, - fields: { - name: typeParameters[0], - }, - }); -} -export interface AddArguments, Value extends BcsType> { - object: RawTransactionArgument; - name: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface AddOptions, Value extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - object: RawTransactionArgument, - name: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a dynamic object field to the object `object: &mut UID` at field specified - * by `name: Name`. Aborts with `EFieldAlreadyExists` if the object already has - * that field with that name. - */ -export function add, Value extends BcsType>( - options: AddOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x2::object::ID', - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['object', 'name', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutably borrows the `object`s dynamic object field with the name specified by - * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a - * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but - * the value object does not have the specified type. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the `object`s dynamic object field with the name specified by - * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a - * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but - * the value object does not have the specified type. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the `object`s dynamic object field with the name specified by - * `name: Name` and returns the bound object. Aborts with `EFieldDoesNotExist` if - * the object does not have a field with that name. Aborts with - * `EFieldTypeMismatch` if the field exists, but the value object does not have the - * specified type. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface Exists_Arguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface Exists_Options> { - package: string; - arguments: - | Exists_Arguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns true if and only if the `object` has a dynamic object field with the - * name specified by `name: Name`. - */ -export function exists_>(options: Exists_Options) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'exists_', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ExistsWithTypeArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface ExistsWithTypeOptions> { - package: string; - arguments: - | ExistsWithTypeArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true if and only if the `object` has a dynamic field with the name - * specified by `name: Name` with an assigned value of type `Value`. - */ -export function existsWithType>(options: ExistsWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'exists_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IdArguments> { - object: RawTransactionArgument; - name: RawTransactionArgument; -} -export interface IdOptions> { - package: string; - arguments: - | IdArguments - | [object: RawTransactionArgument, name: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns the ID of the object associated with the dynamic object field Returns - * none otherwise - */ -export function id>(options: IdOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['object', 'name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'dynamic_object_field', - function: 'id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts deleted file mode 100644 index 374b67222..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_k1.ts +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface Secp256k1EcrecoverArguments { - signature: RawTransactionArgument; - msg: RawTransactionArgument; - hash: RawTransactionArgument; -} -export interface Secp256k1EcrecoverOptions { - package: string; - arguments: - | Secp256k1EcrecoverArguments - | [ - signature: RawTransactionArgument, - msg: RawTransactionArgument, - hash: RawTransactionArgument, - ]; -} -/** - * @param signature: A 65-bytes signature in form (r, s, v) that is signed using - * Secp256k1. Reference implementation on signature generation using RFC6979: - * https://github.com/MystenLabs/narwhal/blob/5d6f6df8ccee94446ff88786c0dbbc98be7cfc09/crypto/src/secp256k1.rs - * The accepted v values are {0, 1, 2, 3}. @param msg: The message that the - * signature is signed against, this is raw message without hashing. @param hash: - * The hash function used to hash the message when signing. - * - * If the signature is valid, return the corresponding recovered Secpk256k1 public - * key, otherwise throw error. This is similar to ecrecover in Ethereum, can only - * be applied to Secp256k1 signatures. May abort with `EFailToRecoverPubKey` or - * `EInvalidSignature`. - */ -export function secp256k1Ecrecover(options: Secp256k1EcrecoverOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'u8'] satisfies (string | null)[]; - const parameterNames = ['signature', 'msg', 'hash']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecdsa_k1', - function: 'secp256k1_ecrecover', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DecompressPubkeyArguments { - pubkey: RawTransactionArgument; -} -export interface DecompressPubkeyOptions { - package: string; - arguments: DecompressPubkeyArguments | [pubkey: RawTransactionArgument]; -} -/** - * @param pubkey: A 33-bytes compressed public key, a prefix either 0x02 or 0x03 - * and a 256-bit integer. - * - * If the compressed public key is valid, return the 65-bytes uncompressed public - * key, otherwise throw error. May abort with `EInvalidPubKey`. - */ -export function decompressPubkey(options: DecompressPubkeyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['pubkey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecdsa_k1', - function: 'decompress_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface Secp256k1VerifyArguments { - signature: RawTransactionArgument; - publicKey: RawTransactionArgument; - msg: RawTransactionArgument; - hash: RawTransactionArgument; -} -export interface Secp256k1VerifyOptions { - package: string; - arguments: - | Secp256k1VerifyArguments - | [ - signature: RawTransactionArgument, - publicKey: RawTransactionArgument, - msg: RawTransactionArgument, - hash: RawTransactionArgument, - ]; -} -/** - * @param signature: A 64-bytes signature in form (r, s) that is signed using - * Secp256k1. This is an non-recoverable signature without recovery id. Reference - * implementation on signature generation using RFC6979: - * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256k1/mod.rs#L193 - * @param public_key: The public key to verify the signature against @param msg: - * The message that the signature is signed against, this is raw message without - * hashing. @param hash: The hash function used to hash the message when signing. - * - * If the signature is valid to the pubkey and hashed message, return true. Else - * false. - */ -export function secp256k1Verify(options: Secp256k1VerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector', 'u8'] satisfies ( - | string - | null - )[]; - const parameterNames = ['signature', 'publicKey', 'msg', 'hash']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecdsa_k1', - function: 'secp256k1_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts deleted file mode 100644 index d6ee72a74..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/ecdsa_r1.ts +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface Secp256r1EcrecoverArguments { - signature: RawTransactionArgument; - msg: RawTransactionArgument; - hash: RawTransactionArgument; -} -export interface Secp256r1EcrecoverOptions { - package: string; - arguments: - | Secp256r1EcrecoverArguments - | [ - signature: RawTransactionArgument, - msg: RawTransactionArgument, - hash: RawTransactionArgument, - ]; -} -/** - * @param signature: A 65-bytes signature in form (r, s, v) that is signed using - * Secp256r1. Reference implementation on signature generation using RFC6979: - * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs - * The accepted v values are {0, 1, 2, 3}. @param msg: The message that the - * signature is signed against, this is raw message without hashing. @param hash: - * The u8 representing the name of hash function used to hash the message when - * signing. - * - * If the signature is valid, return the corresponding recovered Secpk256r1 public - * key, otherwise throw error. This is similar to ecrecover in Ethereum, can only - * be applied to Secp256r1 signatures. May fail with `EFailToRecoverPubKey` or - * `EInvalidSignature`. - */ -export function secp256r1Ecrecover(options: Secp256r1EcrecoverOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'u8'] satisfies (string | null)[]; - const parameterNames = ['signature', 'msg', 'hash']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecdsa_r1', - function: 'secp256r1_ecrecover', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface Secp256r1VerifyArguments { - signature: RawTransactionArgument; - publicKey: RawTransactionArgument; - msg: RawTransactionArgument; - hash: RawTransactionArgument; -} -export interface Secp256r1VerifyOptions { - package: string; - arguments: - | Secp256r1VerifyArguments - | [ - signature: RawTransactionArgument, - publicKey: RawTransactionArgument, - msg: RawTransactionArgument, - hash: RawTransactionArgument, - ]; -} -/** - * @param signature: A 64-bytes signature in form (r, s) that is signed using - * Secp256r1. This is an non-recoverable signature without recovery id. Reference - * implementation on signature generation using RFC6979: - * https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs - * @param public_key: The public key to verify the signature against @param msg: - * The message that the signature is signed against, this is raw message without - * hashing. @param hash: The u8 representing the name of hash function used to hash - * the message when signing. - * - * If the signature is valid to the pubkey and hashed message, return true. Else - * false. - */ -export function secp256r1Verify(options: Secp256r1VerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector', 'u8'] satisfies ( - | string - | null - )[]; - const parameterNames = ['signature', 'publicKey', 'msg', 'hash']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecdsa_r1', - function: 'secp256r1_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts deleted file mode 100644 index f2f397b95..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/ecvrf.ts +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface EcvrfVerifyArguments { - hash: RawTransactionArgument; - alphaString: RawTransactionArgument; - publicKey: RawTransactionArgument; - proof: RawTransactionArgument; -} -export interface EcvrfVerifyOptions { - package: string; - arguments: - | EcvrfVerifyArguments - | [ - hash: RawTransactionArgument, - alphaString: RawTransactionArgument, - publicKey: RawTransactionArgument, - proof: RawTransactionArgument, - ]; -} -/** - * @param hash: The hash/output from a ECVRF to be verified. @param alpha_string: - * Input/seed to the ECVRF used to generate the output. @param public_key: The - * public key corresponding to the private key used to generate the output. @param - * proof: The proof of validity of the output. Verify a proof for a Ristretto - * ECVRF. Returns true if the proof is valid and corresponds to the given output. - * May abort with `EInvalidHashLength`, `EInvalidPublicKeyEncoding` or - * `EInvalidProofEncoding`. - */ -export function ecvrfVerify(options: EcvrfVerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['hash', 'alphaString', 'publicKey', 'proof']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ecvrf', - function: 'ecvrf_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts b/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts deleted file mode 100644 index 21f5469cc..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/ed25519.ts +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface Ed25519VerifyArguments { - signature: RawTransactionArgument; - publicKey: RawTransactionArgument; - msg: RawTransactionArgument; -} -export interface Ed25519VerifyOptions { - package: string; - arguments: - | Ed25519VerifyArguments - | [ - signature: RawTransactionArgument, - publicKey: RawTransactionArgument, - msg: RawTransactionArgument, - ]; -} -/** - * @param signature: 32-byte signature that is a point on the Ed25519 elliptic - * curve. @param public_key: 32-byte signature that is a point on the Ed25519 - * elliptic curve. @param msg: The message that we test the signature against. - * - * If the signature is a valid Ed25519 signature of the message and public key, - * return true. Otherwise, return false. - */ -export function ed25519Verify(options: Ed25519VerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['signature', 'publicKey', 'msg']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'ed25519', - function: 'ed25519_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/event.ts b/packages/suins/src/contracts/suins_auction/deps/sui/event.ts deleted file mode 100644 index 3a7162d08..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/event.ts +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Events module. Defines the `sui::event::emit` function which creates and sends a - * custom MoveEvent as a part of the effects certificate of the transaction. - * - * Every MoveEvent has the following properties: - * - * - sender - * - type signature (`T`) - * - event data (the value of `T`) - * - timestamp (local to a node) - * - transaction digest - * - * Example: - * - * ``` - * module my::marketplace { - * use sui::event; - * /* ... *\/ - * struct ItemPurchased has copy, drop { - * item_id: ID, buyer: address - * } - * entry fun buy(/* .... *\/) { - * /* ... *\/ - * event::emit(ItemPurchased { item_id: ..., buyer: .... }) - * } - * } - * ``` - */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -import { type BcsType } from '@mysten/sui/bcs'; -export interface EmitArguments> { - event: RawTransactionArgument; -} -export interface EmitOptions> { - package: string; - arguments: EmitArguments | [event: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Emit a custom Move event, sending the data offchain. - * - * Used for creating custom indexes and tracking onchain activity in a way that - * suits a specific application the most. - * - * The type `T` is the main way to index the event, and can contain phantom - * parameters, eg `emit(MyEvent)`. - */ -export function emit>(options: EmitOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['event']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'event', - function: 'emit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface EmitAuthenticatedArguments> { - event: RawTransactionArgument; -} -export interface EmitAuthenticatedOptions> { - package: string; - arguments: EmitAuthenticatedArguments | [event: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Emits a custom Move event which can be authenticated by a light client. - * - * This method emits the authenticated event to the event stream for the Move - * package that defines the event type `T`. Only the package that defines the type - * `T` can emit authenticated events to this stream. - */ -export function emitAuthenticated>(options: EmitAuthenticatedOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['event']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'event', - function: 'emit_authenticated', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts b/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts deleted file mode 100644 index 9d064b1af..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/funds_accumulator.ts +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** A module for accumulating funds, i.e. Balance-like types. */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::funds_accumulator'; -export const Withdrawal = new MoveStruct({ - name: `${$moduleName}::Withdrawal`, - fields: { - /** The owner of the funds, either an object or a transaction sender */ - owner: bcs.Address, - /** - * At signing we check the limit <= balance when taking this as a call arg. If this - * was generated from an object, we cannot check this until redemption. - */ - limit: bcs.u256(), - }, -}); -export interface WithdrawalOwnerArguments { - withdrawal: RawTransactionArgument; -} -export interface WithdrawalOwnerOptions { - package: string; - arguments: WithdrawalOwnerArguments | [withdrawal: RawTransactionArgument]; - typeArguments: [string]; -} -/** Returns the owner, either a sender's address or an object, of the withdrawal. */ -export function withdrawalOwner(options: WithdrawalOwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['withdrawal']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'funds_accumulator', - function: 'withdrawal_owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawalLimitArguments { - withdrawal: RawTransactionArgument; -} -export interface WithdrawalLimitOptions { - package: string; - arguments: WithdrawalLimitArguments | [withdrawal: RawTransactionArgument]; - typeArguments: [string]; -} -/** Returns the remaining limit of the withdrawal. */ -export function withdrawalLimit(options: WithdrawalLimitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['withdrawal']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'funds_accumulator', - function: 'withdrawal_limit', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawalSplitArguments { - withdrawal: RawTransactionArgument; - subLimit: RawTransactionArgument; -} -export interface WithdrawalSplitOptions { - package: string; - arguments: - | WithdrawalSplitArguments - | [ - withdrawal: RawTransactionArgument, - subLimit: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Split a `Withdrawal` and take a sub-withdrawal from it with the specified - * sub-limit. - */ -export function withdrawalSplit(options: WithdrawalSplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u256'] satisfies (string | null)[]; - const parameterNames = ['withdrawal', 'subLimit']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'funds_accumulator', - function: 'withdrawal_split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawalJoinArguments { - withdrawal: RawTransactionArgument; - other: RawTransactionArgument; -} -export interface WithdrawalJoinOptions { - package: string; - arguments: - | WithdrawalJoinArguments - | [withdrawal: RawTransactionArgument, other: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Join two withdrawals together, increasing the limit of `self` by the limit of - * `other`. Aborts with `EOwnerMismatch` if the owners are not equal. Aborts with - * `EOverflow` if the resulting limit would overflow `u256`. - */ -export function withdrawalJoin(options: WithdrawalJoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['withdrawal', 'other']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'funds_accumulator', - function: 'withdrawal_join', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts b/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts deleted file mode 100644 index 52462c37b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/groth16.ts +++ /dev/null @@ -1,244 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::groth16'; -export const Curve = new MoveStruct({ - name: `${$moduleName}::Curve`, - fields: { - id: bcs.u8(), - }, -}); -export const PreparedVerifyingKey = new MoveStruct({ - name: `${$moduleName}::PreparedVerifyingKey`, - fields: { - vk_gamma_abc_g1_bytes: bcs.vector(bcs.u8()), - alpha_g1_beta_g2_bytes: bcs.vector(bcs.u8()), - gamma_g2_neg_pc_bytes: bcs.vector(bcs.u8()), - delta_g2_neg_pc_bytes: bcs.vector(bcs.u8()), - }, -}); -export const PublicProofInputs = new MoveStruct({ - name: `${$moduleName}::PublicProofInputs`, - fields: { - bytes: bcs.vector(bcs.u8()), - }, -}); -export const ProofPoints = new MoveStruct({ - name: `${$moduleName}::ProofPoints`, - fields: { - bytes: bcs.vector(bcs.u8()), - }, -}); -export interface Bls12381Options { - package: string; - arguments?: []; -} -/** - * Return the `Curve` value indicating that the BLS12-381 construction should be - * used in a given function. - */ -export function bls12381(options: Bls12381Options = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'bls12381', - }); -} -export interface Bn254Options { - package: string; - arguments?: []; -} -/** - * Return the `Curve` value indicating that the BN254 construction should be used - * in a given function. - */ -export function bn254(options: Bn254Options = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'bn254', - }); -} -export interface PvkFromBytesArguments { - vkGammaAbcG1Bytes: RawTransactionArgument; - alphaG1BetaG2Bytes: RawTransactionArgument; - gammaG2NegPcBytes: RawTransactionArgument; - deltaG2NegPcBytes: RawTransactionArgument; -} -export interface PvkFromBytesOptions { - package: string; - arguments: - | PvkFromBytesArguments - | [ - vkGammaAbcG1Bytes: RawTransactionArgument, - alphaG1BetaG2Bytes: RawTransactionArgument, - gammaG2NegPcBytes: RawTransactionArgument, - deltaG2NegPcBytes: RawTransactionArgument, - ]; -} -/** Creates a `PreparedVerifyingKey` from bytes. */ -export function pvkFromBytes(options: PvkFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = [ - 'vkGammaAbcG1Bytes', - 'alphaG1BetaG2Bytes', - 'gammaG2NegPcBytes', - 'deltaG2NegPcBytes', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'pvk_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PvkToBytesArguments { - pvk: RawTransactionArgument; -} -export interface PvkToBytesOptions { - package: string; - arguments: PvkToBytesArguments | [pvk: RawTransactionArgument]; -} -/** Returns bytes of the four components of the `PreparedVerifyingKey`. */ -export function pvkToBytes(options: PvkToBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pvk']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'pvk_to_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PublicProofInputsFromBytesArguments { - bytes: RawTransactionArgument; -} -export interface PublicProofInputsFromBytesOptions { - package: string; - arguments: PublicProofInputsFromBytesArguments | [bytes: RawTransactionArgument]; -} -/** - * Creates a `PublicProofInputs` wrapper from bytes. The `bytes` parameter should - * be a concatenation of a number of 32 bytes scalar field elements to be used as - * public inputs in little-endian format to a circuit. - */ -export function publicProofInputsFromBytes(options: PublicProofInputsFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'public_proof_inputs_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProofPointsFromBytesArguments { - bytes: RawTransactionArgument; -} -export interface ProofPointsFromBytesOptions { - package: string; - arguments: ProofPointsFromBytesArguments | [bytes: RawTransactionArgument]; -} -/** Creates a Groth16 `ProofPoints` from bytes. */ -export function proofPointsFromBytes(options: ProofPointsFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'proof_points_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PrepareVerifyingKeyArguments { - curve: RawTransactionArgument; - verifyingKey: RawTransactionArgument; -} -export interface PrepareVerifyingKeyOptions { - package: string; - arguments: - | PrepareVerifyingKeyArguments - | [curve: RawTransactionArgument, verifyingKey: RawTransactionArgument]; -} -/** - * @param curve: What elliptic curve construction to use. See `bls12381` and - * `bn254`. @param verifying_key: An Arkworks canonical compressed serialization of - * a verifying key. - * - * Returns four vectors of bytes representing the four components of a prepared - * verifying key. This step computes one pairing e(P, Q), and binds the - * verification to one particular proof statement. This can be used as inputs for - * the `verify_groth16_proof` function. - */ -export function prepareVerifyingKey(options: PrepareVerifyingKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; - const parameterNames = ['curve', 'verifyingKey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'prepare_verifying_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VerifyGroth16ProofArguments { - curve: RawTransactionArgument; - preparedVerifyingKey: RawTransactionArgument; - publicProofInputs: RawTransactionArgument; - proofPoints: RawTransactionArgument; -} -export interface VerifyGroth16ProofOptions { - package: string; - arguments: - | VerifyGroth16ProofArguments - | [ - curve: RawTransactionArgument, - preparedVerifyingKey: RawTransactionArgument, - publicProofInputs: RawTransactionArgument, - proofPoints: RawTransactionArgument, - ]; -} -/** - * @param curve: What elliptic curve construction to use. See the `bls12381` and - * `bn254` functions. @param prepared_verifying_key: Consists of four vectors of - * bytes representing the four components of a prepared verifying key. @param - * public_proof_inputs: Represent inputs that are public. @param proof_points: - * Represent three proof points. - * - * Returns a boolean indicating whether the proof is valid. - */ -export function verifyGroth16Proof(options: VerifyGroth16ProofOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null, null] satisfies (string | null)[]; - const parameterNames = ['curve', 'preparedVerifyingKey', 'publicProofInputs', 'proofPoints']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'groth16', - function: 'verify_groth16_proof', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts b/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts index bbd1820ea..3c2c1f8d7 100644 --- a/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts +++ b/packages/suins/src/contracts/suins_auction/deps/sui/group_ops.ts @@ -4,13 +4,8 @@ /** Generic Move and native functions for group operations. */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; +import { MoveStruct } from '../../../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; const $moduleName = '0x2::group_ops'; export const Element = new MoveStruct({ name: `${$moduleName}::Element`, @@ -18,48 +13,3 @@ export const Element = new MoveStruct({ bytes: bcs.vector(bcs.u8()), }, }); -export interface BytesArguments { - e: RawTransactionArgument; -} -export interface BytesOptions { - package: string; - arguments: BytesArguments | [e: RawTransactionArgument]; - typeArguments: [string]; -} -export function bytes(options: BytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'group_ops', - function: 'bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface EqualArguments { - e1: RawTransactionArgument; - e2: RawTransactionArgument; -} -export interface EqualOptions { - package: string; - arguments: - | EqualArguments - | [e1: RawTransactionArgument, e2: RawTransactionArgument]; - typeArguments: [string]; -} -export function equal(options: EqualOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['e1', 'e2']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'group_ops', - function: 'equal', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts deleted file mode 100644 index 476def426..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/hash.ts +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Module which defines hash functions. Note that Sha-256 and Sha3-256 is available - * in the std::hash module in the standard library. - */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface Blake2b256Arguments { - data: RawTransactionArgument; -} -export interface Blake2b256Options { - package: string; - arguments: Blake2b256Arguments | [data: RawTransactionArgument]; -} -/** - * @param data: Arbitrary binary data to hash Hash the input bytes using - * Blake2b-256 and returns 32 bytes. - */ -export function blake2b256(options: Blake2b256Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['data']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'hash', - function: 'blake2b256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface Keccak256Arguments { - data: RawTransactionArgument; -} -export interface Keccak256Options { - package: string; - arguments: Keccak256Arguments | [data: RawTransactionArgument]; -} -/** - * @param data: Arbitrary binary data to hash Hash the input bytes using keccak256 - * and returns 32 bytes. - */ -export function keccak256(options: Keccak256Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['data']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'hash', - function: 'keccak256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts deleted file mode 100644 index 8e6f4f6b3..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/hex.ts +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** HEX (Base16) encoding utility. */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface EncodeArguments { - bytes: RawTransactionArgument; -} -export interface EncodeOptions { - package: string; - arguments: EncodeArguments | [bytes: RawTransactionArgument]; -} -/** Encode `bytes` in lowercase hex */ -export function encode(options: EncodeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'hex', - function: 'encode', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DecodeArguments { - hex: RawTransactionArgument; -} -export interface DecodeOptions { - package: string; - arguments: DecodeArguments | [hex: RawTransactionArgument]; -} -/** - * Decode hex into `bytes` Takes a hex string (no 0x prefix) (e.g. b"0f3a") Returns - * vector of `bytes` that represents the hex string (e.g. x"0f3a") Hex string can - * be case insensitive (e.g. b"0F3A" and b"0f3a" both return x"0f3a") Aborts if the - * hex string does not have an even number of characters (as each hex character is - * 2 characters long) Aborts if the hex string contains non-valid hex characters - * (valid characters are 0 - 9, a - f, A - F) - */ -export function decode(options: DecodeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['hex']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'hex', - function: 'decode', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts b/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts deleted file mode 100644 index 20fa6085f..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/hmac.ts +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface HmacSha3_256Arguments { - key: RawTransactionArgument; - msg: RawTransactionArgument; -} -export interface HmacSha3_256Options { - package: string; - arguments: - | HmacSha3_256Arguments - | [key: RawTransactionArgument, msg: RawTransactionArgument]; -} -/** - * @param key: HMAC key, arbitrary bytes. @param msg: message to sign, arbitrary - * bytes. Returns the 32 bytes digest of HMAC-SHA3-256(key, msg). - */ -export function hmacSha3_256(options: HmacSha3_256Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['key', 'msg']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'hmac', - function: 'hmac_sha3_256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts deleted file mode 100644 index 69d7da6d1..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk.ts +++ /dev/null @@ -1,1222 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Kiosk is a primitive for building safe, decentralized and trustless trading - * experiences. It allows storing and trading any types of assets as long as the - * creator of these assets implements a `TransferPolicy` for them. - * - * ### Principles and philosophy: - * - * - Kiosk provides guarantees of "true ownership"; - just like single owner - * objects, assets stored in the Kiosk can only be managed by the Kiosk owner. - * Only the owner can `place`, `take`, `list`, perform any other actions on - * assets in the Kiosk. - * - * - Kiosk aims to be generic - allowing for a small set of default behaviors and - * not imposing any restrictions on how the assets can be traded. The only - * default scenario is a `list` + `purchase` flow; any other trading logic can be - * implemented on top using the `list_with_purchase_cap` (and a matching - * `purchase_with_cap`) flow. - * - * - For every transaction happening with a third party a `TransferRequest` is - * created - this way creators are fully in control of the trading experience. - * - * ### Asset states in the Kiosk: - * - * - `placed` - An asset is `place`d into the Kiosk and can be `take`n out by the - * Kiosk owner; it's freely tradable and modifiable via the `borrow_mut` and - * `borrow_val` functions. - * - * - `locked` - Similar to `placed` except that `take` is disabled and the only way - * to move the asset out of the Kiosk is to `list` it or `list_with_purchase_cap` - * therefore performing a trade (issuing a `TransferRequest`). The check on the - * `lock` function makes sure that the `TransferPolicy` exists to not lock the - * item in a `Kiosk` forever. - * - * - `listed` - A `place`d or a `lock`ed item can be `list`ed for a fixed price - * allowing anyone to `purchase` it from the Kiosk. While listed, an item can not - * be taken or modified. However, an immutable borrow via `borrow` call is still - * available. The `delist` function returns the asset to the previous state. - * - * - `listed_exclusively` - An item is listed via the `list_with_purchase_cap` - * function (and a `PurchaseCap` is created). While listed this way, an item can - * not be `delist`-ed unless a `PurchaseCap` is returned. All actions available - * at this item state require a `PurchaseCap`: - * - * 1. `purchase_with_cap` - to purchase the item for a price equal or higher than - * the `min_price` set in the `PurchaseCap`. - * 2. `return_purchase_cap` - to return the `PurchaseCap` and return the asset - * into the previous state. - * - * When an item is listed exclusively it cannot be modified nor taken and losing a - * `PurchaseCap` would lock the item in the Kiosk forever. Therefore, it is - * recommended to only use `PurchaseCap` functionality in trusted applications and - * not use it for direct trading (eg sending to another account). - * - * ### Using multiple Transfer Policies for different "tracks": - * - * Every `purchase` or `purchase_with_purchase_cap` creates a `TransferRequest` hot - * potato which must be resolved in a matching `TransferPolicy` for the transaction - * to pass. While the default scenario implies that there should be a single - * `TransferPolicy` for `T`; it is possible to have multiple, each one having - * its own set of rules. - * - * ### Examples: - * - * - I create one `TransferPolicy` with "Royalty Rule" for everyone - * - I create a special `TransferPolicy` for bearers of a "Club Membership" object - * so they don't have to pay anything - * - I create and wrap a `TransferPolicy` so that players of my game can transfer - * items between `Kiosk`s in game without any charge (and maybe not even paying - * the price with a 0 SUI PurchaseCap) - * - * ``` - * Kiosk -> (Item, TransferRequest) - * ... TransferRequest ------> Common Transfer Policy - * ... TransferRequest ------> In-game Wrapped Transfer Policy - * ... TransferRequest ------> Club Membership Transfer Policy - * ``` - * - * See `transfer_policy` module for more details on how they function. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from './balance.js'; -const $moduleName = '0x2::kiosk'; -export const Kiosk = new MoveStruct({ - name: `${$moduleName}::Kiosk`, - fields: { - id: bcs.Address, - /** Balance of the Kiosk - all profits from sales go here. */ - profits: balance.Balance, - /** - * Always point to `sender` of the transaction. Can be changed by calling - * `set_owner` with Cap. - */ - owner: bcs.Address, - /** - * Number of items stored in a Kiosk. Used to allow unpacking an empty Kiosk if it - * was wrapped or has a single owner. - */ - item_count: bcs.u32(), - /** - * [DEPRECATED] Please, don't use the `allow_extensions` and the matching - * `set_allow_extensions` function - it is a legacy feature that is being replaced - * by the `kiosk_extension` module and its Extensions API. - * - * Exposes `uid_mut` publicly when set to `true`, set to `false` by default. - */ - allow_extensions: bcs.bool(), - }, -}); -export const KioskOwnerCap = new MoveStruct({ - name: `${$moduleName}::KioskOwnerCap`, - fields: { - id: bcs.Address, - for: bcs.Address, - }, -}); -export const PurchaseCap = new MoveStruct({ - name: `${$moduleName}::PurchaseCap`, - fields: { - id: bcs.Address, - /** ID of the `Kiosk` the cap belongs to. */ - kiosk_id: bcs.Address, - /** ID of the listed item. */ - item_id: bcs.Address, - /** Minimum price for which the item can be purchased. */ - min_price: bcs.u64(), - }, -}); -export const Borrow = new MoveStruct({ - name: `${$moduleName}::Borrow`, - fields: { - kiosk_id: bcs.Address, - item_id: bcs.Address, - }, -}); -export const Item = new MoveStruct({ - name: `${$moduleName}::Item`, - fields: { - id: bcs.Address, - }, -}); -export const Listing = new MoveStruct({ - name: `${$moduleName}::Listing`, - fields: { - id: bcs.Address, - is_exclusive: bcs.bool(), - }, -}); -export const Lock = new MoveStruct({ - name: `${$moduleName}::Lock`, - fields: { - id: bcs.Address, - }, -}); -export const ItemListed = new MoveStruct({ - name: `${$moduleName}::ItemListed`, - fields: { - kiosk: bcs.Address, - id: bcs.Address, - price: bcs.u64(), - }, -}); -export const ItemPurchased = new MoveStruct({ - name: `${$moduleName}::ItemPurchased`, - fields: { - kiosk: bcs.Address, - id: bcs.Address, - price: bcs.u64(), - }, -}); -export const ItemDelisted = new MoveStruct({ - name: `${$moduleName}::ItemDelisted`, - fields: { - kiosk: bcs.Address, - id: bcs.Address, - }, -}); -export interface DefaultOptions { - package: string; - arguments?: []; -} -/** - * Creates a new Kiosk in a default configuration: sender receives the - * `KioskOwnerCap` and becomes the Owner, the `Kiosk` is shared. - */ -export function _default(options: DefaultOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'default', - }); -} -export interface NewOptions { - package: string; - arguments?: []; -} -/** Creates a new `Kiosk` with a matching `KioskOwnerCap`. */ -export function _new(options: NewOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'new', - }); -} -export interface CloseAndWithdrawArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface CloseAndWithdrawOptions { - package: string; - arguments: - | CloseAndWithdrawArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; -} -/** - * Unpacks and destroys a Kiosk returning the profits (even if "0"). Can only be - * performed by the bearer of the `KioskOwnerCap` in the case where there's no - * items inside and a `Kiosk` is not shared. - */ -export function closeAndWithdraw(options: CloseAndWithdrawOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'close_and_withdraw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetOwnerArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface SetOwnerOptions { - package: string; - arguments: - | SetOwnerArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; -} -/** - * Change the `owner` field to the transaction sender. The change is purely - * cosmetical and does not affect any of the basic kiosk functions unless some - * logic for this is implemented in a third party module. - */ -export function setOwner(options: SetOwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'set_owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetOwnerCustomArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - owner: RawTransactionArgument; -} -export interface SetOwnerCustomOptions { - package: string; - arguments: - | SetOwnerCustomArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - owner: RawTransactionArgument, - ]; -} -/** - * Update the `owner` field with a custom address. Can be used for implementing a - * custom logic that relies on the `Kiosk` owner. - */ -export function setOwnerCustom(options: SetOwnerCustomOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'owner']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'set_owner_custom', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PlaceArguments> { - self: RawTransactionArgument; - cap: RawTransactionArgument; - item: RawTransactionArgument; -} -export interface PlaceOptions> { - package: string; - arguments: - | PlaceArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - item: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Place any object into a Kiosk. Performs an authorization check to make sure only - * owner can do that. - */ -export function place>(options: PlaceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'item']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'place', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LockArguments> { - self: RawTransactionArgument; - cap: RawTransactionArgument; - Policy: RawTransactionArgument; - item: RawTransactionArgument; -} -export interface LockOptions> { - package: string; - arguments: - | LockArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - Policy: RawTransactionArgument, - item: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Place an item to the `Kiosk` and issue a `Lock` for it. Once placed this way, an - * item can only be listed either with a `list` function or with a - * `list_with_purchase_cap`. - * - * Requires policy for `T` to make sure that there's an issued `TransferPolicy` and - * the item can be sold, otherwise the asset might be locked forever. - */ -export function lock>(options: LockOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null, `${options.typeArguments[0]}`] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'cap', 'Policy', 'item']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'lock', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TakeArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface TakeOptions { - package: string; - arguments: - | TakeArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Take any object from the Kiosk. Performs an authorization check to make sure - * only owner can do that. - */ -export function take(options: TakeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'take', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ListArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; - price: RawTransactionArgument; -} -export interface ListOptions { - package: string; - arguments: - | ListArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - price: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * List the item by setting a price and making it available for purchase. Performs - * an authorization check to make sure only owner can sell. - */ -export function list(options: ListOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID', 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id', 'price']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'list', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PlaceAndListArguments> { - self: RawTransactionArgument; - cap: RawTransactionArgument; - item: RawTransactionArgument; - price: RawTransactionArgument; -} -export interface PlaceAndListOptions> { - package: string; - arguments: - | PlaceAndListArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - item: RawTransactionArgument, - price: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Calls `place` and `list` together - simplifies the flow. */ -export function placeAndList>(options: PlaceAndListOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, `${options.typeArguments[0]}`, 'u64'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'cap', 'item', 'price']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'place_and_list', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DelistArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface DelistOptions { - package: string; - arguments: - | DelistArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Remove an existing listing from the `Kiosk` and keep the item in the user Kiosk. - * Can only be performed by the owner of the `Kiosk`. - */ -export function delist(options: DelistOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'delist', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PurchaseArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; - payment: RawTransactionArgument; -} -export interface PurchaseOptions { - package: string; - arguments: - | PurchaseArguments - | [ - self: RawTransactionArgument, - id: RawTransactionArgument, - payment: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Make a trade: pay the owner of the item and request a Transfer to the `target` - * kiosk (to prevent item being taken by the approving party). - * - * Received `TransferRequest` needs to be handled by the publisher of the T, if - * they have a method implemented that allows a trade, it is possible to request - * their approval (by calling some function) so that the trade can be finalized. - */ -export function purchase(options: PurchaseOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID', null] satisfies (string | null)[]; - const parameterNames = ['self', 'id', 'payment']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'purchase', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ListWithPurchaseCapArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; - minPrice: RawTransactionArgument; -} -export interface ListWithPurchaseCapOptions { - package: string; - arguments: - | ListWithPurchaseCapArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - minPrice: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Creates a `PurchaseCap` which gives the right to purchase an item for any price - * equal or higher than the `min_price`. - */ -export function listWithPurchaseCap(options: ListWithPurchaseCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID', 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id', 'minPrice']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'list_with_purchase_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PurchaseWithCapArguments { - self: RawTransactionArgument; - purchaseCap: RawTransactionArgument; - payment: RawTransactionArgument; -} -export interface PurchaseWithCapOptions { - package: string; - arguments: - | PurchaseWithCapArguments - | [ - self: RawTransactionArgument, - purchaseCap: RawTransactionArgument, - payment: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Unpack the `PurchaseCap` and call `purchase`. Sets the payment amount as the - * price for the listing making sure it's no less than `min_amount`. - */ -export function purchaseWithCap(options: PurchaseWithCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'purchaseCap', 'payment']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'purchase_with_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ReturnPurchaseCapArguments { - self: RawTransactionArgument; - purchaseCap: RawTransactionArgument; -} -export interface ReturnPurchaseCapOptions { - package: string; - arguments: - | ReturnPurchaseCapArguments - | [self: RawTransactionArgument, purchaseCap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Return the `PurchaseCap` without making a purchase; remove an active offer and - * allow the item for taking. Can only be returned to its `Kiosk`, aborts - * otherwise. - */ -export function returnPurchaseCap(options: ReturnPurchaseCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'purchaseCap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'return_purchase_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - amount: RawTransactionArgument; -} -export interface WithdrawOptions { - package: string; - arguments: - | WithdrawArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - amount: RawTransactionArgument, - ]; -} -/** Withdraw profits from the Kiosk. */ -export function withdraw(options: WithdrawOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::option::Option'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'amount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'withdraw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasItemArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface HasItemOptions { - package: string; - arguments: - | HasItemArguments - | [self: RawTransactionArgument, id: RawTransactionArgument]; -} -/** Check whether the `item` is present in the `Kiosk`. */ -export function hasItem(options: HasItemOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'has_item', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasItemWithTypeArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface HasItemWithTypeOptions { - package: string; - arguments: - | HasItemWithTypeArguments - | [self: RawTransactionArgument, id: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether the `item` is present in the `Kiosk` and has type T. */ -export function hasItemWithType(options: HasItemWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'has_item_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsLockedArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface IsLockedOptions { - package: string; - arguments: - | IsLockedArguments - | [self: RawTransactionArgument, id: RawTransactionArgument]; -} -/** - * Check whether an item with the `id` is locked in the `Kiosk`. Meaning that the - * only two actions that can be performed on it are `list` and - * `list_with_purchase_cap`, it cannot be `take`n out of the `Kiosk`. - */ -export function isLocked(options: IsLockedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'is_locked', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsListedArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface IsListedOptions { - package: string; - arguments: - | IsListedArguments - | [self: RawTransactionArgument, id: RawTransactionArgument]; -} -/** Check whether an `item` is listed (exclusively or non exclusively). */ -export function isListed(options: IsListedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'is_listed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsListedExclusivelyArguments { - self: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface IsListedExclusivelyOptions { - package: string; - arguments: - | IsListedExclusivelyArguments - | [self: RawTransactionArgument, id: RawTransactionArgument]; -} -/** Check whether there's a `PurchaseCap` issued for an item. */ -export function isListedExclusively(options: IsListedExclusivelyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'is_listed_exclusively', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasAccessArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface HasAccessOptions { - package: string; - arguments: - | HasAccessArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; -} -/** Check whether the `KioskOwnerCap` matches the `Kiosk`. */ -export function hasAccess(options: HasAccessOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'has_access', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidMutAsOwnerArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface UidMutAsOwnerOptions { - package: string; - arguments: - | UidMutAsOwnerArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; -} -/** Access the `UID` using the `KioskOwnerCap`. */ -export function uidMutAsOwner(options: UidMutAsOwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'uid_mut_as_owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetAllowExtensionsArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - allowExtensions: RawTransactionArgument; -} -export interface SetAllowExtensionsOptions { - package: string; - arguments: - | SetAllowExtensionsArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - allowExtensions: RawTransactionArgument, - ]; -} -/** - * [DEPRECATED] Allow or disallow `uid` and `uid_mut` access via the - * `allow_extensions` setting. - */ -export function setAllowExtensions(options: SetAllowExtensionsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'bool'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'allowExtensions']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'set_allow_extensions', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidArguments { - self: RawTransactionArgument; -} -export interface UidOptions { - package: string; - arguments: UidArguments | [self: RawTransactionArgument]; -} -/** - * Get the immutable `UID` for dynamic field access. Always enabled. - * - * Given the &UID can be used for reading keys and authorization, its access - */ -export function uid(options: UidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'uid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidMutArguments { - self: RawTransactionArgument; -} -export interface UidMutOptions { - package: string; - arguments: UidMutArguments | [self: RawTransactionArgument]; -} -/** - * Get the mutable `UID` for dynamic field access and extensions. Aborts if - * `allow_extensions` set to `false`. - */ -export function uidMut(options: UidMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'uid_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface OwnerArguments { - self: RawTransactionArgument; -} -export interface OwnerOptions { - package: string; - arguments: OwnerArguments | [self: RawTransactionArgument]; -} -/** Get the owner of the Kiosk. */ -export function owner(options: OwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ItemCountArguments { - self: RawTransactionArgument; -} -export interface ItemCountOptions { - package: string; - arguments: ItemCountArguments | [self: RawTransactionArgument]; -} -/** Get the number of items stored in a Kiosk. */ -export function itemCount(options: ItemCountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'item_count', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProfitsAmountArguments { - self: RawTransactionArgument; -} -export interface ProfitsAmountOptions { - package: string; - arguments: ProfitsAmountArguments | [self: RawTransactionArgument]; -} -/** Get the amount of profits collected by selling items. */ -export function profitsAmount(options: ProfitsAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'profits_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProfitsMutArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface ProfitsMutOptions { - package: string; - arguments: - | ProfitsMutArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; -} -/** Get mutable access to `profits` - owner only action. */ -export function profitsMut(options: ProfitsMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'profits_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BorrowArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface BorrowOptions { - package: string; - arguments: - | BorrowArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Immutably borrow an item from the `Kiosk`. Any item can be `borrow`ed at any - * time. - */ -export function borrow(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface BorrowMutOptions { - package: string; - arguments: - | BorrowMutArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Mutably borrow an item from the `Kiosk`. Item can be `borrow_mut`ed only if it's - * not `is_listed`. - */ -export function borrowMut(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowValArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - id: RawTransactionArgument; -} -export interface BorrowValOptions { - package: string; - arguments: - | BorrowValArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - id: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Take the item from the `Kiosk` with a guarantee that it will be returned. Item - * can be `borrow_val`-ed only if it's not `is_listed`. - */ -export function borrowVal(options: BorrowValOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'borrow_val', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ReturnValArguments> { - self: RawTransactionArgument; - item: RawTransactionArgument; - borrow: RawTransactionArgument; -} -export interface ReturnValOptions> { - package: string; - arguments: - | ReturnValArguments - | [ - self: RawTransactionArgument, - item: RawTransactionArgument, - borrow: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Return the borrowed item to the `Kiosk`. This method cannot be avoided if - * `borrow_val` is used. - */ -export function returnVal>(options: ReturnValOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['self', 'item', 'borrow']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'return_val', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface KioskOwnerCapForArguments { - cap: RawTransactionArgument; -} -export interface KioskOwnerCapForOptions { - package: string; - arguments: KioskOwnerCapForArguments | [cap: RawTransactionArgument]; -} -/** Get the `for` field of the `KioskOwnerCap`. */ -export function kioskOwnerCapFor(options: KioskOwnerCapForOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'kiosk_owner_cap_for', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PurchaseCapKioskArguments { - self: RawTransactionArgument; -} -export interface PurchaseCapKioskOptions { - package: string; - arguments: PurchaseCapKioskArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `kiosk_id` from the `PurchaseCap`. */ -export function purchaseCapKiosk(options: PurchaseCapKioskOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'purchase_cap_kiosk', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PurchaseCapItemArguments { - self: RawTransactionArgument; -} -export interface PurchaseCapItemOptions { - package: string; - arguments: PurchaseCapItemArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `Item_id` from the `PurchaseCap`. */ -export function purchaseCapItem(options: PurchaseCapItemOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'purchase_cap_item', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PurchaseCapMinPriceArguments { - self: RawTransactionArgument; -} -export interface PurchaseCapMinPriceOptions { - package: string; - arguments: PurchaseCapMinPriceArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `min_price` from the `PurchaseCap`. */ -export function purchaseCapMinPrice(options: PurchaseCapMinPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk', - function: 'purchase_cap_min_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts b/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts deleted file mode 100644 index b75aa51c9..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/kiosk_extension.ts +++ /dev/null @@ -1,467 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * This module implements the Kiosk Extensions functionality. It allows exposing - * previously protected (only-owner) methods to third-party apps. - * - * A Kiosk Extension is a module that implements any functionality on top of the - * `Kiosk` without discarding nor blocking the base. Given that `Kiosk` itself is a - * trading primitive, most of the extensions are expected to be related to trading. - * However, there's no limit to what can be built using the `kiosk_extension` - * module, as it gives certain benefits such as using `Kiosk` as the storage for - * any type of data / assets. - * - * ### Flow: - * - * - An extension can only be installed by the Kiosk Owner and requires an - * authorization via the `KioskOwnerCap`. - * - When installed, the extension is given a permission bitmap that allows it to - * perform certain protected actions (eg `place`, `lock`). However, it is - * possible to install an extension that does not have any permissions. - * - Kiosk Owner can `disable` the extension at any time, which prevents it from - * performing any protected actions. The storage is still available to the - * extension until it is completely removed. - * - A disabled extension can be `enable`d at any time giving the permissions back - * to the extension. - * - An extension permissions follow the all-or-nothing policy. Either all of the - * requested permissions are granted or none of them (can't install). - * - * ### Examples: - * - * - An Auction extension can utilize the storage to store Auction-related data - * while utilizing the same `Kiosk` object that the items are stored in. - * - A Marketplace extension that implements custom events and fees for the default - * trading functionality. - * - * ### Notes: - * - * - Trading functionality can utilize the `PurchaseCap` to build a custom logic - * around the purchase flow. However, it should be carefully managed to prevent - * asset locking. - * - `kiosk_extension` is a friend module to `kiosk` and has access to its internal - * functions (such as `place_internal` and `lock_internal` to implement custom - * authorization scheme for `place` and `lock` respectively). - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as bag from './bag.js'; -const $moduleName = '0x2::kiosk_extension'; -export const Extension = new MoveStruct({ - name: `${$moduleName}::Extension`, - fields: { - /** - * Storage for the extension, an isolated Bag. By putting the extension into a - * single dynamic field, we reduce the amount of fields on the top level (eg items - * / listings) while giving extension developers the ability to store any data they - * want. - */ - storage: bag.Bag, - /** - * Bitmap of permissions that the extension has (can be revoked any moment). It's - * all or nothing policy - either the extension has the required permissions or no - * permissions at all. - * - * 1st bit - `place` - allows to place items for sale 2nd bit - `lock` and - * `place` - allows to lock items (and place) - * - * For example: - * - * - `10` - allows to place items and lock them. - * - `11` - allows to place items and lock them (`lock` includes `place`). - * - `01` - allows to place items, but not lock them. - * - `00` - no permissions. - */ - permissions: bcs.u128(), - /** - * Whether the extension can call protected actions. By default, all extensions are - * enabled (on `add` call), however the Kiosk owner can disable them at any time. - * - * Disabling the extension does not limit its access to the storage. - */ - is_enabled: bcs.bool(), - }, -}); -export const ExtensionKey = new MoveStruct({ - name: `${$moduleName}::ExtensionKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface AddArguments> { - Ext: RawTransactionArgument; - self: RawTransactionArgument; - cap: RawTransactionArgument; - permissions: RawTransactionArgument; -} -export interface AddOptions> { - package: string; - arguments: - | AddArguments - | [ - Ext: RawTransactionArgument, - self: RawTransactionArgument, - cap: RawTransactionArgument, - permissions: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Add an extension to the Kiosk. Can only be performed by the owner. The extension - * witness is required to allow extensions define their set of permissions in the - * custom `add` call. - */ -export function add>(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null, null, 'u128'] satisfies ( - | string - | null - )[]; - const parameterNames = ['Ext', 'self', 'cap', 'permissions']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DisableArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface DisableOptions { - package: string; - arguments: - | DisableArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Revoke permissions from the extension. While it does not remove the extension - * completely, it keeps it from performing any protected actions. The storage is - * still available to the extension (until it's removed). - */ -export function disable(options: DisableOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'disable', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface EnableArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface EnableOptions { - package: string; - arguments: - | EnableArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Re-enable the extension allowing it to call protected actions (eg `place`, - * `lock`). By default, all added extensions are enabled. Kiosk owner can disable - * them via `disable` call. - */ -export function enable(options: EnableOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'enable', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface RemoveOptions { - package: string; - arguments: - | RemoveArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Remove an extension from the Kiosk. Can only be performed by the owner, the - * extension storage must be empty for the transaction to succeed. - */ -export function remove(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface StorageArguments> { - Ext: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface StorageOptions> { - package: string; - arguments: - | StorageArguments - | [Ext: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get immutable access to the extension storage. Can only be performed by the - * extension as long as the extension is installed. - */ -export function storage>(options: StorageOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['Ext', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'storage', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface StorageMutArguments> { - Ext: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface StorageMutOptions> { - package: string; - arguments: - | StorageMutArguments - | [Ext: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get mutable access to the extension storage. Can only be performed by the - * extension as long as the extension is installed. Disabling the extension does - * not prevent it from accessing the storage. - * - * Potentially dangerous: extension developer can keep data in a Bag therefore - * never really allowing the KioskOwner to remove the extension. However, it is the - * case with any other solution (1) and this way we prevent intentional extension - * freeze when the owner wants to ruin a trade (2) - eg locking extension while an - * auction is in progress. - * - * Extensions should be crafted carefully, and the KioskOwner should be aware of - * the risks. - */ -export function storageMut>(options: StorageMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['Ext', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'storage_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PlaceArguments, T extends BcsType> { - Ext: RawTransactionArgument; - self: RawTransactionArgument; - item: RawTransactionArgument; - Policy: RawTransactionArgument; -} -export interface PlaceOptions, T extends BcsType> { - package: string; - arguments: - | PlaceArguments - | [ - Ext: RawTransactionArgument, - self: RawTransactionArgument, - item: RawTransactionArgument, - Policy: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Protected action: place an item into the Kiosk. Can be performed by an - * authorized extension. The extension must have the `place` permission or a `lock` - * permission. - * - * To prevent non-tradable items from being placed into `Kiosk` the method requires - * a `TransferPolicy` for the placed type to exist. - */ -export function place, T extends BcsType>( - options: PlaceOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - null, - `${options.typeArguments[1]}`, - null, - ] satisfies (string | null)[]; - const parameterNames = ['Ext', 'self', 'item', 'Policy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'place', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LockArguments, T extends BcsType> { - Ext: RawTransactionArgument; - self: RawTransactionArgument; - item: RawTransactionArgument; - Policy: RawTransactionArgument; -} -export interface LockOptions, T extends BcsType> { - package: string; - arguments: - | LockArguments - | [ - Ext: RawTransactionArgument, - self: RawTransactionArgument, - item: RawTransactionArgument, - Policy: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Protected action: lock an item in the Kiosk. Can be performed by an authorized - * extension. The extension must have the `lock` permission. - */ -export function lock, T extends BcsType>( - options: LockOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[0]}`, - null, - `${options.typeArguments[1]}`, - null, - ] satisfies (string | null)[]; - const parameterNames = ['Ext', 'self', 'item', 'Policy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'lock', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsInstalledArguments { - self: RawTransactionArgument; -} -export interface IsInstalledOptions { - package: string; - arguments: IsInstalledArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether an extension of type `Ext` is installed. */ -export function isInstalled(options: IsInstalledOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'is_installed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEnabledArguments { - self: RawTransactionArgument; -} -export interface IsEnabledOptions { - package: string; - arguments: IsEnabledArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether an extension of type `Ext` is enabled. */ -export function isEnabled(options: IsEnabledOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'is_enabled', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CanPlaceArguments { - self: RawTransactionArgument; -} -export interface CanPlaceOptions { - package: string; - arguments: CanPlaceArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether an extension of type `Ext` can `place` into Kiosk. */ -export function canPlace(options: CanPlaceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'can_place', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CanLockArguments { - self: RawTransactionArgument; -} -export interface CanLockOptions { - package: string; - arguments: CanLockArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Check whether an extension of type `Ext` can `lock` items in Kiosk. Locking also - * enables `place`. - */ -export function canLock(options: CanLockOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'kiosk_extension', - function: 'can_lock', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts deleted file mode 100644 index 37f9652d1..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/linked_table.ts +++ /dev/null @@ -1,512 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Similar to `sui::table` but the values are linked together, allowing for ordered - * insertion and removal - */ - -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::linked_table'; -export function LinkedTable>(...typeParameters: [K]) { - return new MoveStruct({ - name: `${$moduleName}::LinkedTable<${typeParameters[0].name as K['name']}, phantom V>`, - fields: { - /** the ID of this table */ - id: bcs.Address, - /** the number of key-value pairs in the table */ - size: bcs.u64(), - /** the front of the table, i.e. the key of the first entry */ - head: bcs.option(typeParameters[0]), - /** the back of the table, i.e. the key of the last entry */ - tail: bcs.option(typeParameters[0]), - }, - }); -} -export function Node, V extends BcsType>(...typeParameters: [K, V]) { - return new MoveStruct({ - name: `${$moduleName}::Node<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, - fields: { - /** the previous key */ - prev: bcs.option(typeParameters[0]), - /** the next key */ - next: bcs.option(typeParameters[0]), - /** the value being stored */ - value: typeParameters[1], - }, - }); -} -export interface NewOptions { - package: string; - arguments?: []; - typeArguments: [string, string]; -} -/** Creates a new, empty table */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'new', - typeArguments: options.typeArguments, - }); -} -export interface FrontArguments { - table: RawTransactionArgument; -} -export interface FrontOptions { - package: string; - arguments: FrontArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns the key for the first element in the table, or None if the table is - * empty - */ -export function front(options: FrontOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'front', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BackArguments { - table: RawTransactionArgument; -} -export interface BackOptions { - package: string; - arguments: BackArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns the key for the last element in the table, or None if the table is empty */ -export function back(options: BackOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PushFrontArguments, V extends BcsType> { - table: RawTransactionArgument; - k: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface PushFrontOptions, V extends BcsType> { - package: string; - arguments: - | PushFrontArguments - | [ - table: RawTransactionArgument, - k: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Inserts a key-value pair at the front of the table, i.e. the newly inserted pair - * will be the first element in the table Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with - * that key `k: K`. - */ -export function pushFront, V extends BcsType>( - options: PushFrontOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['table', 'k', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'push_front', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PushBackArguments, V extends BcsType> { - table: RawTransactionArgument; - k: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface PushBackOptions, V extends BcsType> { - package: string; - arguments: - | PushBackArguments - | [ - table: RawTransactionArgument, - k: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Inserts a key-value pair at the back of the table, i.e. the newly inserted pair - * will be the last element in the table Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with - * that key `k: K`. - */ -export function pushBack, V extends BcsType>( - options: PushBackOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['table', 'k', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'push_back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutable borrows the value associated with the key in the table - * `table: &LinkedTable`. Aborts with - * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry - * with that key `k: K`. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the value associated with the key in the table - * `table: &mut LinkedTable`. Aborts with - * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry - * with that key `k: K`. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PrevArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface PrevOptions> { - package: string; - arguments: - | PrevArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Borrows the key for the previous entry of the specified key `k: K` in the table - * `table: &LinkedTable`. Returns None if the entry does not have a - * predecessor. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table - * does not have an entry with that key `k: K` - */ -export function prev>(options: PrevOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'prev', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NextArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface NextOptions> { - package: string; - arguments: - | NextArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Borrows the key for the next entry of the specified key `k: K` in the table - * `table: &LinkedTable`. Returns None if the entry does not have a - * predecessor. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table - * does not have an entry with that key `k: K` - */ -export function next>(options: NextOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'next', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the key-value pair in the table `table: &mut LinkedTable` and - * returns the value. This splices the element out of the ordering. Aborts with - * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry - * with that key `k: K`. Note: this is also what happens when the table is empty. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PopFrontArguments { - table: RawTransactionArgument; -} -export interface PopFrontOptions { - package: string; - arguments: PopFrontArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the front of the table `table: &mut LinkedTable`, returns the key - * and value. Aborts with `ETableIsEmpty` if the table is empty - */ -export function popFront(options: PopFrontOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'pop_front', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PopBackArguments { - table: RawTransactionArgument; -} -export interface PopBackOptions { - package: string; - arguments: PopBackArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the back of the table `table: &mut LinkedTable`, returns the key - * and value. Aborts with `ETableIsEmpty` if the table is empty - */ -export function popBack(options: PopBackOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'pop_back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true iff there is a value associated with the key `k: K` in table - * `table: &LinkedTable` - */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - table: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns the size of the table, the number of key-value pairs */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - table: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns true iff the table is empty (if `length` returns `0`) */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyEmptyArguments { - table: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains - * values - */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DropArguments { - table: RawTransactionArgument; -} -export interface DropOptions { - package: string; - arguments: DropArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Drop a possibly non-empty table. Usable only if the value type `V` has the - * `drop` ability - */ -export function drop(options: DropOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'linked_table', - function: 'drop', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/math.ts b/packages/suins/src/contracts/suins_auction/deps/sui/math.ts deleted file mode 100644 index a3d30fb52..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/math.ts +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * DEPRECATED, use the each integer type's individual module instead, e.g. - * `std::u64` - */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface MaxArguments { - x: RawTransactionArgument; - y: RawTransactionArgument; -} -export interface MaxOptions { - package: string; - arguments: - | MaxArguments - | [x: RawTransactionArgument, y: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::max` instead */ -export function max(options: MaxOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['x', 'y']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'max', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MinArguments { - x: RawTransactionArgument; - y: RawTransactionArgument; -} -export interface MinOptions { - package: string; - arguments: - | MinArguments - | [x: RawTransactionArgument, y: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::min` instead */ -export function min(options: MinOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['x', 'y']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'min', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DiffArguments { - x: RawTransactionArgument; - y: RawTransactionArgument; -} -export interface DiffOptions { - package: string; - arguments: - | DiffArguments - | [x: RawTransactionArgument, y: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::diff` instead */ -export function diff(options: DiffOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['x', 'y']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'diff', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PowArguments { - base: RawTransactionArgument; - exponent: RawTransactionArgument; -} -export interface PowOptions { - package: string; - arguments: - | PowArguments - | [base: RawTransactionArgument, exponent: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::pow` instead */ -export function pow(options: PowOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', 'u8'] satisfies (string | null)[]; - const parameterNames = ['base', 'exponent']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'pow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SqrtArguments { - x: RawTransactionArgument; -} -export interface SqrtOptions { - package: string; - arguments: SqrtArguments | [x: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::sqrt` instead */ -export function sqrt(options: SqrtOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64'] satisfies (string | null)[]; - const parameterNames = ['x']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'sqrt', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SqrtU128Arguments { - x: RawTransactionArgument; -} -export interface SqrtU128Options { - package: string; - arguments: SqrtU128Arguments | [x: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u128::sqrt` instead */ -export function sqrtU128(options: SqrtU128Options) { - const packageAddress = options.package; - const argumentsTypes = ['u128'] satisfies (string | null)[]; - const parameterNames = ['x']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'sqrt_u128', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DivideAndRoundUpArguments { - x: RawTransactionArgument; - y: RawTransactionArgument; -} -export interface DivideAndRoundUpOptions { - package: string; - arguments: - | DivideAndRoundUpArguments - | [x: RawTransactionArgument, y: RawTransactionArgument]; -} -/** DEPRECATED, use `std::u64::divide_and_round_up` instead */ -export function divideAndRoundUp(options: DivideAndRoundUpOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['x', 'y']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'math', - function: 'divide_and_round_up', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts b/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts deleted file mode 100644 index 865f6d334..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/nitro_attestation.ts +++ /dev/null @@ -1,247 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::nitro_attestation'; -export const PCREntry = new MoveStruct({ - name: `${$moduleName}::PCREntry`, - fields: { - index: bcs.u8(), - value: bcs.vector(bcs.u8()), - }, -}); -export const NitroAttestationDocument = new MoveStruct({ - name: `${$moduleName}::NitroAttestationDocument`, - fields: { - /** Issuing Nitro hypervisor module ID. */ - module_id: bcs.vector(bcs.u8()), - /** UTC time when document was created, in milliseconds since UNIX epoch. */ - timestamp: bcs.u64(), - /** The digest function used for calculating the register values. */ - digest: bcs.vector(bcs.u8()), - /** - * A list of PCREntry containing the index and the PCR bytes. - * . - */ - pcrs: bcs.vector(PCREntry), - /** - * An optional DER-encoded key the attestation, consumer can use to encrypt data - * with. - */ - public_key: bcs.option(bcs.vector(bcs.u8())), - /** Additional signed user data, defined by protocol. */ - user_data: bcs.option(bcs.vector(bcs.u8())), - /** - * An optional cryptographic nonce provided by the attestation consumer as a proof - * of authenticity. - */ - nonce: bcs.option(bcs.vector(bcs.u8())), - }, -}); -export interface LoadNitroAttestationArguments { - attestation: RawTransactionArgument; -} -export interface LoadNitroAttestationOptions { - package: string; - arguments: LoadNitroAttestationArguments | [attestation: RawTransactionArgument]; -} -/** - * @param attestation: attesttaion documents bytes data. @param clock: the clock - * object. - * - * Returns the parsed NitroAttestationDocument after verifying the attestation, may - * abort with errors described above. - */ -export function loadNitroAttestation(options: LoadNitroAttestationOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'load_nitro_attestation', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ModuleIdArguments { - attestation: RawTransactionArgument; -} -export interface ModuleIdOptions { - package: string; - arguments: ModuleIdArguments | [attestation: RawTransactionArgument]; -} -export function moduleId(options: ModuleIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'module_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TimestampArguments { - attestation: RawTransactionArgument; -} -export interface TimestampOptions { - package: string; - arguments: TimestampArguments | [attestation: RawTransactionArgument]; -} -export function timestamp(options: TimestampOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'timestamp', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DigestArguments { - attestation: RawTransactionArgument; -} -export interface DigestOptions { - package: string; - arguments: DigestArguments | [attestation: RawTransactionArgument]; -} -export function digest(options: DigestOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'digest', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PcrsArguments { - attestation: RawTransactionArgument; -} -export interface PcrsOptions { - package: string; - arguments: PcrsArguments | [attestation: RawTransactionArgument]; -} -/** - * Returns a list of mapping PCREntry containg the index and the PCR bytes. AWS - * supports PCR0-31. All-zero PCR values are excluded. - */ -export function pcrs(options: PcrsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'pcrs', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PublicKeyArguments { - attestation: RawTransactionArgument; -} -export interface PublicKeyOptions { - package: string; - arguments: PublicKeyArguments | [attestation: RawTransactionArgument]; -} -export function publicKey(options: PublicKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'public_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UserDataArguments { - attestation: RawTransactionArgument; -} -export interface UserDataOptions { - package: string; - arguments: UserDataArguments | [attestation: RawTransactionArgument]; -} -export function userData(options: UserDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'user_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NonceArguments { - attestation: RawTransactionArgument; -} -export interface NonceOptions { - package: string; - arguments: NonceArguments | [attestation: RawTransactionArgument]; -} -export function nonce(options: NonceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['attestation']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'nonce', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IndexArguments { - entry: RawTransactionArgument; -} -export interface IndexOptions { - package: string; - arguments: IndexArguments | [entry: RawTransactionArgument]; -} -export function index(options: IndexOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['entry']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'index', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValueArguments { - entry: RawTransactionArgument; -} -export interface ValueOptions { - package: string; - arguments: ValueArguments | [entry: RawTransactionArgument]; -} -export function value(options: ValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['entry']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'nitro_attestation', - function: 'value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object.ts deleted file mode 100644 index afdf8f2c6..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/object.ts +++ /dev/null @@ -1,317 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** Sui object identifiers */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::object'; -export const ID = new MoveStruct({ - name: `${$moduleName}::ID`, - fields: { - bytes: bcs.Address, - }, -}); -export const UID = new MoveStruct({ - name: `${$moduleName}::UID`, - fields: { - id: bcs.Address, - }, -}); -export interface IdToBytesArguments { - id: RawTransactionArgument; -} -export interface IdToBytesOptions { - package: string; - arguments: IdToBytesArguments | [id: RawTransactionArgument]; -} -/** Get the raw bytes of a `ID` */ -export function idToBytes(options: IdToBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_to_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdToAddressArguments { - id: RawTransactionArgument; -} -export interface IdToAddressOptions { - package: string; - arguments: IdToAddressArguments | [id: RawTransactionArgument]; -} -/** Get the inner bytes of `id` as an address. */ -export function idToAddress(options: IdToAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_to_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdFromBytesArguments { - bytes: RawTransactionArgument; -} -export interface IdFromBytesOptions { - package: string; - arguments: IdFromBytesArguments | [bytes: RawTransactionArgument]; -} -/** Make an `ID` from raw bytes. */ -export function idFromBytes(options: IdFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdFromAddressArguments { - bytes: RawTransactionArgument; -} -export interface IdFromAddressOptions { - package: string; - arguments: IdFromAddressArguments | [bytes: RawTransactionArgument]; -} -/** Make an `ID` from an address. */ -export function idFromAddress(options: IdFromAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_from_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidAsInnerArguments { - uid: RawTransactionArgument; -} -export interface UidAsInnerOptions { - package: string; - arguments: UidAsInnerArguments | [uid: RawTransactionArgument]; -} -/** Get the inner `ID` of `uid` */ -export function uidAsInner(options: UidAsInnerOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['uid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'uid_as_inner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidToInnerArguments { - uid: RawTransactionArgument; -} -export interface UidToInnerOptions { - package: string; - arguments: UidToInnerArguments | [uid: RawTransactionArgument]; -} -/** Get the raw bytes of a `uid`'s inner `ID` */ -export function uidToInner(options: UidToInnerOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['uid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'uid_to_inner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidToBytesArguments { - uid: RawTransactionArgument; -} -export interface UidToBytesOptions { - package: string; - arguments: UidToBytesArguments | [uid: RawTransactionArgument]; -} -/** Get the raw bytes of a `UID` */ -export function uidToBytes(options: UidToBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['uid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'uid_to_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidToAddressArguments { - uid: RawTransactionArgument; -} -export interface UidToAddressOptions { - package: string; - arguments: UidToAddressArguments | [uid: RawTransactionArgument]; -} -/** Get the inner bytes of `id` as an address. */ -export function uidToAddress(options: UidToAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['uid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'uid_to_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewOptions { - package: string; - arguments?: []; -} -/** - * Create a new object. Returns the `UID` that must be stored in a Sui object. This - * is the only way to create `UID`s. - */ -export function _new(options: NewOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'new', - }); -} -export interface DeleteArguments { - id: RawTransactionArgument; -} -export interface DeleteOptions { - package: string; - arguments: DeleteArguments | [id: RawTransactionArgument]; -} -/** - * Delete the object and its `UID`. This is the only way to eliminate a `UID`. This - * exists to inform Sui of object deletions. When an object gets unpacked, the - * programmer will have to do something with its `UID`. The implementation of this - * function emits a deleted system event so Sui knows to process the object - * deletion - */ -export function _delete(options: DeleteOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['id']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'delete', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IdArguments> { - obj: RawTransactionArgument; -} -export interface IdOptions> { - package: string; - arguments: IdArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the underlying `ID` of `obj` */ -export function id>(options: IdOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowIdArguments> { - obj: RawTransactionArgument; -} -export interface BorrowIdOptions> { - package: string; - arguments: BorrowIdArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** Borrow the underlying `ID` of `obj` */ -export function borrowId>(options: BorrowIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'borrow_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IdBytesArguments> { - obj: RawTransactionArgument; -} -export interface IdBytesOptions> { - package: string; - arguments: IdBytesArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the raw bytes for the underlying `ID` of `obj` */ -export function idBytes>(options: IdBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IdAddressArguments> { - obj: RawTransactionArgument; -} -export interface IdAddressOptions> { - package: string; - arguments: IdAddressArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the inner bytes for the underlying `ID` of `obj` */ -export function idAddress>(options: IdAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object', - function: 'id_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts index 8615c84bb..8e7d56db1 100644 --- a/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts +++ b/packages/suins/src/contracts/suins_auction/deps/sui/object_bag.ts @@ -10,13 +10,8 @@ * from within Move. */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; const $moduleName = '0x2::object_bag'; export const ObjectBag = new MoveStruct({ name: `${$moduleName}::ObjectBag`, @@ -27,295 +22,3 @@ export const ObjectBag = new MoveStruct({ size: bcs.u64(), }, }); -export interface NewOptions { - package: string; - arguments?: []; -} -/** Creates a new, empty bag */ -export function _new(options: NewOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'new', - }); -} -export interface AddArguments, V extends BcsType> { - bag: RawTransactionArgument; - k: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface AddOptions, V extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - bag: RawTransactionArgument, - k: RawTransactionArgument, - v: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a key-value pair to the bag `bag: &mut ObjectBag` Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with - * that key `k: K`. - */ -export function add, V extends BcsType>(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['bag', 'k', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutably borrows the value associated with the key in the bag - * `bag: &ObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the - * bag does not have an entry with that key `k: K`. Aborts with - * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, - * but the value does not have the specified type. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the value associated with the key in the bag - * `bag: &mut ObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if - * the bag does not have an entry with that key `k: K`. Aborts with - * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, - * but the value does not have the specified type. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the key-value pair in the bag `bag: &mut ObjectBag` and returns - * the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the bag does - * not have an entry with that key `k: K`. Aborts with - * `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key, - * but the value does not have the specified type. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns true iff there is an value associated with the key `k: K` in the bag - * `bag: &ObjectBag` - */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsWithTypeArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsWithTypeOptions> { - package: string; - arguments: - | ContainsWithTypeArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true iff there is an value associated with the key `k: K` in the bag - * `bag: &ObjectBag` with an assigned value of type `V` - */ -export function containsWithType>(options: ContainsWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'contains_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - bag: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [bag: RawTransactionArgument]; -} -/** Returns the size of the bag, the number of key-value pairs */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsEmptyArguments { - bag: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [bag: RawTransactionArgument]; -} -/** Returns true iff the bag is empty (if `length` returns `0`) */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DestroyEmptyArguments { - bag: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [bag: RawTransactionArgument]; -} -/** - * Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains - * values - */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['bag']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValueIdArguments> { - bag: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ValueIdOptions> { - package: string; - arguments: - | ValueIdArguments - | [bag: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Returns the ID of the object associated with the key if the bag has an entry - * with key `k: K` Returns none otherwise - */ -export function valueId>(options: ValueIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['bag', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_bag', - function: 'value_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts deleted file mode 100644 index a427e804e..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/object_table.ts +++ /dev/null @@ -1,297 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Similar to `sui::table`, an `ObjectTable` is a map-like collection. But - * unlike `sui::table`, the values bound to these dynamic fields _must_ be objects - * themselves. This allows for the objects to still exist within in storage, which - * may be important for external tools. The difference is otherwise not observable - * from within Move. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::object_table'; -export const ObjectTable = new MoveStruct({ - name: `${$moduleName}::ObjectTable`, - fields: { - /** the ID of this table */ - id: bcs.Address, - /** the number of key-value pairs in the table */ - size: bcs.u64(), - }, -}); -export interface NewOptions { - package: string; - arguments?: []; - typeArguments: [string, string]; -} -/** Creates a new, empty table */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'new', - typeArguments: options.typeArguments, - }); -} -export interface AddArguments, V extends BcsType> { - table: RawTransactionArgument; - k: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface AddOptions, V extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - table: RawTransactionArgument, - k: RawTransactionArgument, - v: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a key-value pair to the table `table: &mut ObjectTable` Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with - * that key `k: K`. - */ -export function add, V extends BcsType>(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['table', 'k', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutable borrows the value associated with the key in the table - * `table: &ObjectTable`. Aborts with - * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry - * with that key `k: K`. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the value associated with the key in the table - * `table: &mut ObjectTable`. Aborts with - * `sui::dynamic_field::EFieldDoesNotExist` if the table does not have an entry - * with that key `k: K`. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the key-value pair in the table `table: &mut ObjectTable` and - * returns the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the - * table does not have an entry with that key `k: K`. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true if there is a value associated with the key `k: K` in table - * `table: &ObjectTable` - */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - table: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns the size of the table, the number of key-value pairs */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - table: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns true if the table is empty (if `length` returns `0`) */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyEmptyArguments { - table: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains - * values - */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ValueIdArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ValueIdOptions> { - package: string; - arguments: - | ValueIdArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns the ID of the object associated with the key if the table has an entry - * with key `k: K` Returns none otherwise - */ -export function valueId>(options: ValueIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'object_table', - function: 'value_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/package.ts b/packages/suins/src/contracts/suins_auction/deps/sui/package.ts deleted file mode 100644 index 24a37c8c2..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/package.ts +++ /dev/null @@ -1,572 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Functions for operating on Move packages from within Move: - * - * - Creating proof-of-publish objects from one-time witnesses - * - Administering package upgrades through upgrade policies. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::package'; -export const UpgradeCap = new MoveStruct({ - name: `${$moduleName}::UpgradeCap`, - fields: { - id: bcs.Address, - /** (Mutable) ID of the package that can be upgraded. */ - package: bcs.Address, - /** - * (Mutable) The number of upgrades that have been applied successively to the - * original package. Initially 0. - */ - version: bcs.u64(), - /** What kind of upgrades are allowed. */ - policy: bcs.u8(), - }, -}); -export const Publisher = new MoveStruct({ - name: `${$moduleName}::Publisher`, - fields: { - id: bcs.Address, - package: bcs.string(), - module_name: bcs.string(), - }, -}); -export const UpgradeTicket = new MoveStruct({ - name: `${$moduleName}::UpgradeTicket`, - fields: { - /** (Immutable) ID of the `UpgradeCap` this originated from. */ - cap: bcs.Address, - /** (Immutable) ID of the package that can be upgraded. */ - package: bcs.Address, - /** (Immutable) The policy regarding what kind of upgrade this ticket permits. */ - policy: bcs.u8(), - /** - * (Immutable) SHA256 digest of the bytecode and transitive dependencies that will - * be used in the upgrade. - */ - digest: bcs.vector(bcs.u8()), - }, -}); -export const UpgradeReceipt = new MoveStruct({ - name: `${$moduleName}::UpgradeReceipt`, - fields: { - /** (Immutable) ID of the `UpgradeCap` this originated from. */ - cap: bcs.Address, - /** (Immutable) ID of the package after it was upgraded. */ - package: bcs.Address, - }, -}); -export interface ClaimArguments> { - otw: RawTransactionArgument; -} -export interface ClaimOptions> { - package: string; - arguments: ClaimArguments | [otw: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Claim a Publisher object. Requires a One-Time-Witness to prove ownership. Due to - * this constraint there can be only one Publisher object per module but multiple - * per package (!). - */ -export function claim>(options: ClaimOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['otw']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'claim', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ClaimAndKeepArguments> { - otw: RawTransactionArgument; -} -export interface ClaimAndKeepOptions> { - package: string; - arguments: ClaimAndKeepArguments | [otw: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Claim a Publisher object and send it to transaction sender. Since this function - * can only be called in the module initializer, the sender is the publisher. - */ -export function claimAndKeep>(options: ClaimAndKeepOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['otw']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'claim_and_keep', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BurnPublisherArguments { - self: RawTransactionArgument; -} -export interface BurnPublisherOptions { - package: string; - arguments: BurnPublisherArguments | [self: RawTransactionArgument]; -} -/** - * Destroy a Publisher object effectively removing all privileges associated with - * it. - */ -export function burnPublisher(options: BurnPublisherOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'burn_publisher', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FromPackageArguments { - self: RawTransactionArgument; -} -export interface FromPackageOptions { - package: string; - arguments: FromPackageArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether type belongs to the same package as the publisher object. */ -export function fromPackage(options: FromPackageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'from_package', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromModuleArguments { - self: RawTransactionArgument; -} -export interface FromModuleOptions { - package: string; - arguments: FromModuleArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether a type belongs to the same module as the publisher object. */ -export function fromModule(options: FromModuleOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'from_module', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublishedModuleArguments { - self: RawTransactionArgument; -} -export interface PublishedModuleOptions { - package: string; - arguments: PublishedModuleArguments | [self: RawTransactionArgument]; -} -/** Read the name of the module. */ -export function publishedModule(options: PublishedModuleOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'published_module', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PublishedPackageArguments { - self: RawTransactionArgument; -} -export interface PublishedPackageOptions { - package: string; - arguments: PublishedPackageArguments | [self: RawTransactionArgument]; -} -/** Read the package address string. */ -export function publishedPackage(options: PublishedPackageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'published_package', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpgradePackageArguments { - cap: RawTransactionArgument; -} -export interface UpgradePackageOptions { - package: string; - arguments: UpgradePackageArguments | [cap: RawTransactionArgument]; -} -/** - * The ID of the package that this cap authorizes upgrades for. Can be `0x0` if the - * cap cannot currently authorize an upgrade because there is already a pending - * upgrade in the transaction. Otherwise guaranteed to be the latest version of any - * given package. - */ -export function upgradePackage(options: UpgradePackageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'upgrade_package', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VersionArguments { - cap: RawTransactionArgument; -} -export interface VersionOptions { - package: string; - arguments: VersionArguments | [cap: RawTransactionArgument]; -} -/** - * The most recent version of the package, increments by one for each successfully - * applied upgrade. - */ -export function version(options: VersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpgradePolicyArguments { - cap: RawTransactionArgument; -} -export interface UpgradePolicyOptions { - package: string; - arguments: UpgradePolicyArguments | [cap: RawTransactionArgument]; -} -/** The most permissive kind of upgrade currently supported by this `cap`. */ -export function upgradePolicy(options: UpgradePolicyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'upgrade_policy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TicketPackageArguments { - ticket: RawTransactionArgument; -} -export interface TicketPackageOptions { - package: string; - arguments: TicketPackageArguments | [ticket: RawTransactionArgument]; -} -/** The package that this ticket is authorized to upgrade */ -export function ticketPackage(options: TicketPackageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['ticket']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'ticket_package', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TicketPolicyArguments { - ticket: RawTransactionArgument; -} -export interface TicketPolicyOptions { - package: string; - arguments: TicketPolicyArguments | [ticket: RawTransactionArgument]; -} -/** The kind of upgrade that this ticket authorizes. */ -export function ticketPolicy(options: TicketPolicyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['ticket']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'ticket_policy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReceiptCapArguments { - receipt: RawTransactionArgument; -} -export interface ReceiptCapOptions { - package: string; - arguments: ReceiptCapArguments | [receipt: RawTransactionArgument]; -} -/** ID of the `UpgradeCap` that this `receipt` should be used to update. */ -export function receiptCap(options: ReceiptCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['receipt']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'receipt_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReceiptPackageArguments { - receipt: RawTransactionArgument; -} -export interface ReceiptPackageOptions { - package: string; - arguments: ReceiptPackageArguments | [receipt: RawTransactionArgument]; -} -/** - * ID of the package that was upgraded to: the latest version of the package, as of - * the upgrade represented by this `receipt`. - */ -export function receiptPackage(options: ReceiptPackageOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['receipt']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'receipt_package', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TicketDigestArguments { - ticket: RawTransactionArgument; -} -export interface TicketDigestOptions { - package: string; - arguments: TicketDigestArguments | [ticket: RawTransactionArgument]; -} -/** - * A hash of the package contents for the new version of the package. This ticket - * only authorizes an upgrade to a package that matches this digest. A package's - * contents are identified by two things: - * - * - modules: [[u8]] a list of the package's module contents - * - deps: [[u8; 32]] a list of 32 byte ObjectIDs of the package's transitive - * dependencies - * - * A package's digest is calculated as: - * - * sha3_256(sort(modules ++ deps)) - */ -export function ticketDigest(options: TicketDigestOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['ticket']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'ticket_digest', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CompatiblePolicyOptions { - package: string; - arguments?: []; -} -/** Expose the constants representing various upgrade policies */ -export function compatiblePolicy(options: CompatiblePolicyOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'compatible_policy', - }); -} -export interface AdditivePolicyOptions { - package: string; - arguments?: []; -} -export function additivePolicy(options: AdditivePolicyOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'additive_policy', - }); -} -export interface DepOnlyPolicyOptions { - package: string; - arguments?: []; -} -export function depOnlyPolicy(options: DepOnlyPolicyOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'dep_only_policy', - }); -} -export interface OnlyAdditiveUpgradesArguments { - cap: RawTransactionArgument; -} -export interface OnlyAdditiveUpgradesOptions { - package: string; - arguments: OnlyAdditiveUpgradesArguments | [cap: RawTransactionArgument]; -} -/** - * Restrict upgrades through this upgrade `cap` to just add code, or change - * dependencies. - */ -export function onlyAdditiveUpgrades(options: OnlyAdditiveUpgradesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'only_additive_upgrades', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface OnlyDepUpgradesArguments { - cap: RawTransactionArgument; -} -export interface OnlyDepUpgradesOptions { - package: string; - arguments: OnlyDepUpgradesArguments | [cap: RawTransactionArgument]; -} -/** Restrict upgrades through this upgrade `cap` to just change dependencies. */ -export function onlyDepUpgrades(options: OnlyDepUpgradesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'only_dep_upgrades', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MakeImmutableArguments { - cap: RawTransactionArgument; -} -export interface MakeImmutableOptions { - package: string; - arguments: MakeImmutableArguments | [cap: RawTransactionArgument]; -} -/** Discard the `UpgradeCap` to make a package immutable. */ -export function makeImmutable(options: MakeImmutableOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'make_immutable', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AuthorizeUpgradeArguments { - cap: RawTransactionArgument; - policy: RawTransactionArgument; - digest: RawTransactionArgument; -} -export interface AuthorizeUpgradeOptions { - package: string; - arguments: - | AuthorizeUpgradeArguments - | [ - cap: RawTransactionArgument, - policy: RawTransactionArgument, - digest: RawTransactionArgument, - ]; -} -/** - * Issue a ticket authorizing an upgrade to a particular new bytecode (identified - * by its digest). A ticket will only be issued if one has not already been issued, - * and if the `policy` requested is at least as restrictive as the policy set out - * by the `cap`. - * - * The `digest` supplied and the `policy` will both be checked by validators when - * running the upgrade. I.e. the bytecode supplied in the upgrade must have a - * matching digest, and the changes relative to the parent package must be - * compatible with the policy in the ticket for the upgrade to succeed. - */ -export function authorizeUpgrade(options: AuthorizeUpgradeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8', 'vector'] satisfies (string | null)[]; - const parameterNames = ['cap', 'policy', 'digest']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'authorize_upgrade', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CommitUpgradeArguments { - cap: RawTransactionArgument; - receipt: RawTransactionArgument; -} -export interface CommitUpgradeOptions { - package: string; - arguments: - | CommitUpgradeArguments - | [cap: RawTransactionArgument, receipt: RawTransactionArgument]; -} -/** Consume an `UpgradeReceipt` to update its `UpgradeCap`, finalizing the upgrade. */ -export function commitUpgrade(options: CommitUpgradeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['cap', 'receipt']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'package', - function: 'commit_upgrade', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/party.ts b/packages/suins/src/contracts/suins_auction/deps/sui/party.ts deleted file mode 100644 index d843c915b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/party.ts +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveTuple, - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from './vec_map.js'; -const $moduleName = '0x2::party'; -export const Permissions = new MoveTuple({ - name: `${$moduleName}::Permissions`, - fields: [bcs.u64()], -}); -export const Party = new MoveStruct({ - name: `${$moduleName}::Party`, - fields: { - /** - * The permissions that apply if no specific permissions are set in the `members` - * map. - */ - default: Permissions, - /** The permissions per transaction sender. */ - members: vec_map.VecMap(bcs.Address, Permissions), - }, -}); -export interface SingleOwnerArguments { - owner: RawTransactionArgument; -} -export interface SingleOwnerOptions { - package: string; - arguments: SingleOwnerArguments | [owner: RawTransactionArgument]; -} -/** - * Creates a `Party` value with a single "owner" that has all permissions. No other - * party has any permissions. And there are no default permissions. - */ -export function singleOwner(options: SingleOwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address'] satisfies (string | null)[]; - const parameterNames = ['owner']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'party', - function: 'single_owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts b/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts deleted file mode 100644 index 56dd478dc..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/pay.ts +++ /dev/null @@ -1,228 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** This module provides handy functionality for wallets and `sui::Coin` management. */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface KeepArguments { - c: RawTransactionArgument; -} -export interface KeepOptions { - package: string; - arguments: KeepArguments | [c: RawTransactionArgument]; - typeArguments: [string]; -} -/** Transfer `c` to the sender of the current transaction */ -export function keep(options: KeepOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['c']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'keep', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitArguments { - coin: RawTransactionArgument; - splitAmount: RawTransactionArgument; -} -export interface SplitOptions { - package: string; - arguments: - | SplitArguments - | [coin: RawTransactionArgument, splitAmount: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Split `coin` to two coins, one with balance `split_amount`, and the remaining - * balance is left in `coin`. - */ -export function split(options: SplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['coin', 'splitAmount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitVecArguments { - self: RawTransactionArgument; - splitAmounts: RawTransactionArgument; -} -export interface SplitVecOptions { - package: string; - arguments: - | SplitVecArguments - | [ - self: RawTransactionArgument, - splitAmounts: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Split coin `self` into multiple coins, each with balance specified in - * `split_amounts`. Remaining balance is left in `self`. - */ -export function splitVec(options: SplitVecOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; - const parameterNames = ['self', 'splitAmounts']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'split_vec', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitAndTransferArguments { - c: RawTransactionArgument; - amount: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface SplitAndTransferOptions { - package: string; - arguments: - | SplitAndTransferArguments - | [ - c: RawTransactionArgument, - amount: RawTransactionArgument, - recipient: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Send `amount` units of `c` to `recipient` Aborts with `sui::balance::ENotEnough` - * if `amount` is greater than the balance in `c` - */ -export function splitAndTransfer(options: SplitAndTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', 'address'] satisfies (string | null)[]; - const parameterNames = ['c', 'amount', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'split_and_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DivideAndKeepArguments { - self: RawTransactionArgument; - n: RawTransactionArgument; -} -export interface DivideAndKeepOptions { - package: string; - arguments: - | DivideAndKeepArguments - | [self: RawTransactionArgument, n: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Divide coin `self` into `n - 1` coins with equal balances. If the balance is not - * evenly divisible by `n`, the remainder is left in `self`. - */ -export function divideAndKeep(options: DivideAndKeepOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'n']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'divide_and_keep', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface JoinArguments { - self: RawTransactionArgument; - coin: RawTransactionArgument; -} -export interface JoinOptions { - package: string; - arguments: - | JoinArguments - | [self: RawTransactionArgument, coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Join `coin` into `self`. Re-exports `coin::join` function. Deprecated: you - * should call `coin.join(other)` directly. - */ -export function join(options: JoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'join', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface JoinVecArguments { - self: RawTransactionArgument; - coins: RawTransactionArgument; -} -export interface JoinVecOptions { - package: string; - arguments: - | JoinVecArguments - | [self: RawTransactionArgument, coins: RawTransactionArgument]; - typeArguments: [string]; -} -/** Join everything in `coins` with `self` */ -export function joinVec(options: JoinVecOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; - const parameterNames = ['self', 'coins']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'join_vec', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface JoinVecAndTransferArguments { - coins: RawTransactionArgument; - receiver: RawTransactionArgument; -} -export interface JoinVecAndTransferOptions { - package: string; - arguments: - | JoinVecAndTransferArguments - | [coins: RawTransactionArgument, receiver: RawTransactionArgument]; - typeArguments: [string]; -} -/** Join a vector of `Coin` into a single object and transfer it to `receiver`. */ -export function joinVecAndTransfer(options: JoinVecAndTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'address'] satisfies (string | null)[]; - const parameterNames = ['coins', 'receiver']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pay', - function: 'join_vec_and_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts b/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts deleted file mode 100644 index 19acdc208..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/poseidon.ts +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Module which defines instances of the poseidon hash functions. Available in - * Devnet and Testnet. - */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface PoseidonBn254Arguments { - data: RawTransactionArgument; -} -export interface PoseidonBn254Options { - package: string; - arguments: PoseidonBn254Arguments | [data: RawTransactionArgument]; -} -/** - * @param data: Vector of BN254 field elements to hash. - * - * Hash the inputs using poseidon_bn254 and returns a BN254 field element. - * - * Each element has to be a BN254 field element in canonical representation so it - * must be smaller than the BN254 scalar field size which - * is 21888242871839275222246405745257275088548364400416034343698204186575808495617. - * - * This function supports between 1 and 16 inputs. If you need to hash more than 16 - * inputs, some implementations instead returns the root of a k-ary Merkle tree - * with the inputs as leafs, but since this is not standardized, we leave that to - * the caller to implement if needed. - * - * If the input is empty, the function will abort with EEmptyInput. If more than 16 - * inputs are provided, the function will abort with ETooManyInputs. - */ -export function poseidonBn254(options: PoseidonBn254Options) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['data']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'poseidon', - function: 'poseidon_bn254', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts b/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts deleted file mode 100644 index ffd4d21eb..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/priority_queue.ts +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** Priority queue implemented using a max heap. */ - -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::priority_queue'; -export function Entry>(...typeParameters: [T]) { - return new MoveStruct({ - name: `${$moduleName}::Entry<${typeParameters[0].name as T['name']}>`, - fields: { - priority: bcs.u64(), - value: typeParameters[0], - }, - }); -} -/** - * Struct representing a priority queue. The `entries` vector represents a max heap - * structure, where entries[0] is the root, entries[1] and entries[2] are the left - * child and right child of the root, etc. More generally, the children of - * entries[i] are at i _ 2 + 1 and i _ 2 + 2. The max heap should have the - * invariant that the parent node's priority is always higher than its child nodes' - * priorities. - */ -export function PriorityQueue>(...typeParameters: [T]) { - return new MoveStruct({ - name: `${$moduleName}::PriorityQueue<${typeParameters[0].name as T['name']}>`, - fields: { - entries: bcs.vector(Entry(typeParameters[0])), - }, - }); -} -export interface NewArguments { - entries: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [entries: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a new priority queue from the input entry vectors. */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['entries']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PopMaxArguments { - pq: RawTransactionArgument; -} -export interface PopMaxOptions { - package: string; - arguments: PopMaxArguments | [pq: RawTransactionArgument]; - typeArguments: [string]; -} -/** Pop the entry with the highest priority value. */ -export function popMax(options: PopMaxOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pq']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'pop_max', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface InsertArguments> { - pq: RawTransactionArgument; - priority: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface InsertOptions> { - package: string; - arguments: - | InsertArguments - | [ - pq: RawTransactionArgument, - priority: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Insert a new entry into the queue. */ -export function insert>(options: InsertOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['pq', 'priority', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'insert', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewEntryArguments> { - priority: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface NewEntryOptions> { - package: string; - arguments: - | NewEntryArguments - | [priority: RawTransactionArgument, value: RawTransactionArgument]; - typeArguments: [string]; -} -export function newEntry>(options: NewEntryOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['priority', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'new_entry', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface CreateEntriesArguments> { - p: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface CreateEntriesOptions> { - package: string; - arguments: - | CreateEntriesArguments - | [p: RawTransactionArgument, v: RawTransactionArgument]; - typeArguments: [string]; -} -export function createEntries>(options: CreateEntriesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', `vector<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; - const parameterNames = ['p', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'create_entries', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PrioritiesArguments { - pq: RawTransactionArgument; -} -export interface PrioritiesOptions { - package: string; - arguments: PrioritiesArguments | [pq: RawTransactionArgument]; - typeArguments: [string]; -} -export function priorities(options: PrioritiesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pq']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'priority_queue', - function: 'priorities', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/random.ts b/packages/suins/src/contracts/suins_auction/deps/sui/random.ts deleted file mode 100644 index 94b3b9ffc..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/random.ts +++ /dev/null @@ -1,392 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** This module provides functionality for generating secure randomness. */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as versioned from './versioned.js'; -const $moduleName = '0x2::random'; -export const Random = new MoveStruct({ - name: `${$moduleName}::Random`, - fields: { - id: bcs.Address, - inner: versioned.Versioned, - }, -}); -export const RandomInner = new MoveStruct({ - name: `${$moduleName}::RandomInner`, - fields: { - version: bcs.u64(), - epoch: bcs.u64(), - randomness_round: bcs.u64(), - random_bytes: bcs.vector(bcs.u8()), - }, -}); -export const RandomGenerator = new MoveStruct({ - name: `${$moduleName}::RandomGenerator`, - fields: { - seed: bcs.vector(bcs.u8()), - counter: bcs.u16(), - buffer: bcs.vector(bcs.u8()), - }, -}); -export interface NewGeneratorArguments {} -export interface NewGeneratorOptions { - package: string; - arguments?: NewGeneratorArguments | []; -} -/** - * Create a generator. Can be used to derive up to MAX_U16 \* 32 random bytes. - * - * Using randomness can be error-prone if you don't observe the subtleties in its - * correct use, for example, randomness dependent code might be exploitable to - * attacks that carefully set the gas budget in a way that breaks security. For - * more information, see: - * https://docs.sui.io/guides/developer/advanced/randomness-onchain - */ -export function newGenerator(options: NewGeneratorOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::random::Random'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'new_generator', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface GenerateBytesArguments { - g: RawTransactionArgument; - numOfBytes: RawTransactionArgument; -} -export interface GenerateBytesOptions { - package: string; - arguments: - | GenerateBytesArguments - | [g: RawTransactionArgument, numOfBytes: RawTransactionArgument]; -} -/** Generate n random bytes. */ -export function generateBytes(options: GenerateBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u16'] satisfies (string | null)[]; - const parameterNames = ['g', 'numOfBytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU256Arguments { - g: RawTransactionArgument; -} -export interface GenerateU256Options { - package: string; - arguments: GenerateU256Arguments | [g: RawTransactionArgument]; -} -/** Generate a u256. */ -export function generateU256(options: GenerateU256Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u256', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU128Arguments { - g: RawTransactionArgument; -} -export interface GenerateU128Options { - package: string; - arguments: GenerateU128Arguments | [g: RawTransactionArgument]; -} -/** Generate a u128. */ -export function generateU128(options: GenerateU128Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u128', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU64Arguments { - g: RawTransactionArgument; -} -export interface GenerateU64Options { - package: string; - arguments: GenerateU64Arguments | [g: RawTransactionArgument]; -} -/** Generate a u64. */ -export function generateU64(options: GenerateU64Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u64', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU32Arguments { - g: RawTransactionArgument; -} -export interface GenerateU32Options { - package: string; - arguments: GenerateU32Arguments | [g: RawTransactionArgument]; -} -/** Generate a u32. */ -export function generateU32(options: GenerateU32Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u32', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU16Arguments { - g: RawTransactionArgument; -} -export interface GenerateU16Options { - package: string; - arguments: GenerateU16Arguments | [g: RawTransactionArgument]; -} -/** Generate a u16. */ -export function generateU16(options: GenerateU16Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u16', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU8Arguments { - g: RawTransactionArgument; -} -export interface GenerateU8Options { - package: string; - arguments: GenerateU8Arguments | [g: RawTransactionArgument]; -} -/** Generate a u8. */ -export function generateU8(options: GenerateU8Options) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u8', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateBoolArguments { - g: RawTransactionArgument; -} -export interface GenerateBoolOptions { - package: string; - arguments: GenerateBoolArguments | [g: RawTransactionArgument]; -} -/** Generate a boolean. */ -export function generateBool(options: GenerateBoolOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['g']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_bool', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU128InRangeArguments { - g: RawTransactionArgument; - min: RawTransactionArgument; - max: RawTransactionArgument; -} -export interface GenerateU128InRangeOptions { - package: string; - arguments: - | GenerateU128InRangeArguments - | [ - g: RawTransactionArgument, - min: RawTransactionArgument, - max: RawTransactionArgument, - ]; -} -/** Generate a random u128 in [min, max] (with a bias of 2^{-64}). */ -export function generateU128InRange(options: GenerateU128InRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u128', 'u128'] satisfies (string | null)[]; - const parameterNames = ['g', 'min', 'max']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u128_in_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU64InRangeArguments { - g: RawTransactionArgument; - min: RawTransactionArgument; - max: RawTransactionArgument; -} -export interface GenerateU64InRangeOptions { - package: string; - arguments: - | GenerateU64InRangeArguments - | [ - g: RawTransactionArgument, - min: RawTransactionArgument, - max: RawTransactionArgument, - ]; -} -export function generateU64InRange(options: GenerateU64InRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['g', 'min', 'max']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u64_in_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU32InRangeArguments { - g: RawTransactionArgument; - min: RawTransactionArgument; - max: RawTransactionArgument; -} -export interface GenerateU32InRangeOptions { - package: string; - arguments: - | GenerateU32InRangeArguments - | [ - g: RawTransactionArgument, - min: RawTransactionArgument, - max: RawTransactionArgument, - ]; -} -/** Generate a random u32 in [min, max] (with a bias of 2^{-64}). */ -export function generateU32InRange(options: GenerateU32InRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u32', 'u32'] satisfies (string | null)[]; - const parameterNames = ['g', 'min', 'max']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u32_in_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU16InRangeArguments { - g: RawTransactionArgument; - min: RawTransactionArgument; - max: RawTransactionArgument; -} -export interface GenerateU16InRangeOptions { - package: string; - arguments: - | GenerateU16InRangeArguments - | [ - g: RawTransactionArgument, - min: RawTransactionArgument, - max: RawTransactionArgument, - ]; -} -/** Generate a random u16 in [min, max] (with a bias of 2^{-64}). */ -export function generateU16InRange(options: GenerateU16InRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u16', 'u16'] satisfies (string | null)[]; - const parameterNames = ['g', 'min', 'max']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u16_in_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GenerateU8InRangeArguments { - g: RawTransactionArgument; - min: RawTransactionArgument; - max: RawTransactionArgument; -} -export interface GenerateU8InRangeOptions { - package: string; - arguments: - | GenerateU8InRangeArguments - | [ - g: RawTransactionArgument, - min: RawTransactionArgument, - max: RawTransactionArgument, - ]; -} -/** Generate a random u8 in [min, max] (with a bias of 2^{-64}). */ -export function generateU8InRange(options: GenerateU8InRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8', 'u8'] satisfies (string | null)[]; - const parameterNames = ['g', 'min', 'max']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'generate_u8_in_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ShuffleArguments> { - g: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface ShuffleOptions> { - package: string; - arguments: - | ShuffleArguments - | [g: RawTransactionArgument, v: RawTransactionArgument]; - typeArguments: [string]; -} -/** Shuffle a vector using the random generator (Fisher–Yates/Knuth shuffle). */ -export function shuffle>(options: ShuffleOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; - const parameterNames = ['g', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'random', - function: 'shuffle', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts b/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts deleted file mode 100644 index f56f00136..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/sui.ts +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Coin is the token used to pay for gas in Sui. It has 9 decimals, and the - * smallest unit (10^-9) is called "mist". - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::sui'; -export const SUI = new MoveStruct({ - name: `${$moduleName}::SUI`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface TransferArguments { - c: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface TransferOptions { - package: string; - arguments: - | TransferArguments - | [c: RawTransactionArgument, recipient: RawTransactionArgument]; -} -export function transfer(options: TransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['c', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui', - function: 'transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/table.ts b/packages/suins/src/contracts/suins_auction/deps/sui/table.ts index 41d9fc4db..41e18b1d1 100644 --- a/packages/suins/src/contracts/suins_auction/deps/sui/table.ts +++ b/packages/suins/src/contracts/suins_auction/deps/sui/table.ts @@ -22,13 +22,8 @@ * ``` */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; +import { MoveStruct } from '../../../utils/index.js'; +import { bcs } from '@mysten/sui/bcs'; const $moduleName = '0x2::table'; export const Table = new MoveStruct({ name: `${$moduleName}::Table`, @@ -39,266 +34,3 @@ export const Table = new MoveStruct({ size: bcs.u64(), }, }); -export interface NewOptions { - package: string; - arguments?: []; - typeArguments: [string, string]; -} -/** Creates a new, empty table */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'new', - typeArguments: options.typeArguments, - }); -} -export interface AddArguments, V extends BcsType> { - table: RawTransactionArgument; - k: RawTransactionArgument; - v: RawTransactionArgument; -} -export interface AddOptions, V extends BcsType> { - package: string; - arguments: - | AddArguments - | [ - table: RawTransactionArgument, - k: RawTransactionArgument, - v: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a key-value pair to the table `table: &mut Table` Aborts with - * `sui::dynamic_field::EFieldAlreadyExists` if the table already has an entry with - * that key `k: K`. - */ -export function add, V extends BcsType>(options: AddOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['table', 'k', 'v']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'add', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowOptions> { - package: string; - arguments: - | BorrowArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Immutable borrows the value associated with the key in the table - * `table: &Table`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if - * the table does not have an entry with that key `k: K`. - */ -export function borrow>(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface BorrowMutOptions> { - package: string; - arguments: - | BorrowMutArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Mutably borrows the value associated with the key in the table - * `table: &mut Table`. Aborts with `sui::dynamic_field::EFieldDoesNotExist` - * if the table does not have an entry with that key `k: K`. - */ -export function borrowMut>(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Removes the key-value pair in the table `table: &mut Table` and returns - * the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the table - * does not have an entry with that key `k: K`. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - table: RawTransactionArgument; - k: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [table: RawTransactionArgument, k: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Returns true if there is a value associated with the key `k: K` in table - * `table: &Table` - */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['table', 'k']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - table: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns the size of the table, the number of key-value pairs */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - table: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns true if the table is empty (if `length` returns `0`) */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyEmptyArguments { - table: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Destroys an empty table Aborts with `ETableNotEmpty` if the table still contains - * values - */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DropArguments { - table: RawTransactionArgument; -} -export interface DropOptions { - package: string; - arguments: DropArguments | [table: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Drop a possibly non-empty table. Usable only if the value type `V` has the - * `drop` ability - */ -export function drop(options: DropOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['table']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table', - function: 'drop', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts b/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts deleted file mode 100644 index 7456af234..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/table_vec.ts +++ /dev/null @@ -1,316 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** A basic scalable vector library implemented using `Table`. */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -import { type BcsType } from '@mysten/sui/bcs'; -import * as table from './table.js'; -const $moduleName = '0x2::table_vec'; -export const TableVec = new MoveStruct({ - name: `${$moduleName}::TableVec`, - fields: { - /** The contents of the table vector. */ - contents: table.Table, - }, -}); -export interface EmptyOptions { - package: string; - arguments?: []; - typeArguments: [string]; -} -/** Create an empty TableVec. */ -export function empty(options: EmptyOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'empty', - typeArguments: options.typeArguments, - }); -} -export interface SingletonArguments> { - e: RawTransactionArgument; -} -export interface SingletonOptions> { - package: string; - arguments: SingletonArguments | [e: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return a TableVec of size one containing element `e`. */ -export function singleton>(options: SingletonOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'singleton', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - t: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return the length of the TableVec. */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - t: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return if the TableVec is empty or not. */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowArguments { - t: RawTransactionArgument; - i: RawTransactionArgument; -} -export interface BorrowOptions { - package: string; - arguments: - | BorrowArguments - | [t: RawTransactionArgument, i: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Acquire an immutable reference to the `i`th element of the TableVec `t`. Aborts - * if `i` is out of bounds. - */ -export function borrow(options: BorrowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['t', 'i']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'borrow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PushBackArguments> { - t: RawTransactionArgument; - e: RawTransactionArgument; -} -export interface PushBackOptions> { - package: string; - arguments: - | PushBackArguments - | [t: RawTransactionArgument, e: RawTransactionArgument]; - typeArguments: [string]; -} -/** Add element `e` to the end of the TableVec `t`. */ -export function pushBack>(options: PushBackOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['t', 'e']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'push_back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BorrowMutArguments { - t: RawTransactionArgument; - i: RawTransactionArgument; -} -export interface BorrowMutOptions { - package: string; - arguments: - | BorrowMutArguments - | [t: RawTransactionArgument, i: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Return a mutable reference to the `i`th element in the TableVec `t`. Aborts if - * `i` is out of bounds. - */ -export function borrowMut(options: BorrowMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['t', 'i']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'borrow_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PopBackArguments { - t: RawTransactionArgument; -} -export interface PopBackOptions { - package: string; - arguments: PopBackArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** Pop an element from the end of TableVec `t`. Aborts if `t` is empty. */ -export function popBack(options: PopBackOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'pop_back', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyEmptyArguments { - t: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destroy the TableVec `t`. Aborts if `t` is not empty. */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DropArguments { - t: RawTransactionArgument; -} -export interface DropOptions { - package: string; - arguments: DropArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Drop a possibly non-empty TableVec `t`. Usable only if the value type `Element` - * has the `drop` ability - */ -export function drop(options: DropOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'drop', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SwapArguments { - t: RawTransactionArgument; - i: RawTransactionArgument; - j: RawTransactionArgument; -} -export interface SwapOptions { - package: string; - arguments: - | SwapArguments - | [ - t: RawTransactionArgument, - i: RawTransactionArgument, - j: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Swaps the elements at the `i`th and `j`th indices in the TableVec `t`. Aborts if - * `i` or `j` is out of bounds. - */ -export function swap(options: SwapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['t', 'i', 'j']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'swap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SwapRemoveArguments { - t: RawTransactionArgument; - i: RawTransactionArgument; -} -export interface SwapRemoveOptions { - package: string; - arguments: - | SwapRemoveArguments - | [t: RawTransactionArgument, i: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Swap the `i`th element of the TableVec `t` with the last element and then pop - * the TableVec. This is O(1), but does not preserve ordering of elements in the - * TableVec. Aborts if `i` is out of bounds. - */ -export function swapRemove(options: SwapRemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['t', 'i']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'table_vec', - function: 'swap_remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/token.ts b/packages/suins/src/contracts/suins_auction/deps/sui/token.ts deleted file mode 100644 index 643820e32..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/token.ts +++ /dev/null @@ -1,1302 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * The Token module which implements a Closed Loop Token with a configurable - * policy. The policy is defined by a set of rules that must be satisfied for an - * action to be performed on the token. - * - * The module is designed to be used with a `TreasuryCap` to allow for minting and - * burning of the `Token`s. And can act as a replacement / extension or a companion - * to existing open-loop (`Coin`) systems. - * - * ``` - * Module: sui::balance sui::coin sui::token - * Main type: Balance Coin Token - * Capability: Supply <----> TreasuryCap <----> TreasuryCap - * Abilities: store key + store key - * ``` - * - * The Token system allows for fine-grained control over the actions performed on - * the token. And hence it is highly suitable for applications that require control - * over the currency which a simple open-loop system can't provide. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from './balance.js'; -import * as vec_map from './vec_map.js'; -import * as vec_set from './vec_set.js'; -import * as type_name from '../suins_auction/type_name.js'; -const $moduleName = '0x2::token'; -export const Token = new MoveStruct({ - name: `${$moduleName}::Token`, - fields: { - id: bcs.Address, - /** The Balance of the `Token`. */ - balance: balance.Balance, - }, -}); -export const TokenPolicyCap = new MoveStruct({ - name: `${$moduleName}::TokenPolicyCap`, - fields: { - id: bcs.Address, - for: bcs.Address, - }, -}); -export const TokenPolicy = new MoveStruct({ - name: `${$moduleName}::TokenPolicy`, - fields: { - id: bcs.Address, - /** - * The balance that is effectively spent by the user on the "spend" action. - * However, actual decrease of the supply can only be done by the `TreasuryCap` - * owner when `flush` is called. - * - * This balance is effectively spent and cannot be accessed by anyone but the - * `TreasuryCap` owner. - */ - spent_balance: balance.Balance, - /** - * The set of rules that define what actions can be performed on the token. For - * each "action" there's a set of Rules that must be satisfied for the - * `ActionRequest` to be confirmed. - */ - rules: vec_map.VecMap(bcs.string(), vec_set.VecSet(type_name.TypeName)), - }, -}); -export const ActionRequest = new MoveStruct({ - name: `${$moduleName}::ActionRequest`, - fields: { - /** - * Name of the Action to look up in the Policy. Name can be one of the default - * actions: `transfer`, `spend`, `to_coin`, `from_coin` or a custom action. - */ - name: bcs.string(), - /** Amount is present in all of the txs */ - amount: bcs.u64(), - /** Sender is a permanent field always */ - sender: bcs.Address, - /** Recipient is only available in `transfer` action. */ - recipient: bcs.option(bcs.Address), - /** - * The balance to be "spent" in the `TokenPolicy`, only available in the `spend` - * action. - */ - spent_balance: bcs.option(balance.Balance), - /** - * Collected approvals (stamps) from completed `Rules`. They're matched against - * `TokenPolicy.rules` to determine if the request can be confirmed. - */ - approvals: vec_set.VecSet(type_name.TypeName), - }, -}); -export const RuleKey = new MoveStruct({ - name: `${$moduleName}::RuleKey`, - fields: { - is_protected: bcs.bool(), - }, -}); -export const TokenPolicyCreated = new MoveStruct({ - name: `${$moduleName}::TokenPolicyCreated`, - fields: { - /** ID of the `TokenPolicy` that was created. */ - id: bcs.Address, - /** Whether the `TokenPolicy` is "shared" (mutable) or "frozen" (immutable) - TBD. */ - is_mutable: bcs.bool(), - }, -}); -export interface NewPolicyArguments { - TreasuryCap: RawTransactionArgument; -} -export interface NewPolicyOptions { - package: string; - arguments: NewPolicyArguments | [TreasuryCap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Create a new `TokenPolicy` and a matching `TokenPolicyCap`. The `TokenPolicy` - * must then be shared using the `share_policy` method. - * - * `TreasuryCap` guarantees full ownership over the currency, and is unique, hence - * it is safe to use it for authorization. - */ -export function newPolicy(options: NewPolicyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['TreasuryCap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'new_policy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SharePolicyArguments { - policy: RawTransactionArgument; -} -export interface SharePolicyOptions { - package: string; - arguments: SharePolicyArguments | [policy: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Share the `TokenPolicy`. Due to `key`-only restriction, it must be shared after - * initialization. - */ -export function sharePolicy(options: SharePolicyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['policy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'share_policy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TransferArguments { - t: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface TransferOptions { - package: string; - arguments: - | TransferArguments - | [t: RawTransactionArgument, recipient: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Transfer a `Token` to a `recipient`. Creates an `ActionRequest` for the - * "transfer" action. The `ActionRequest` contains the `recipient` field to be used - * in verification. - */ -export function transfer(options: TransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['t', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SpendArguments { - t: RawTransactionArgument; -} -export interface SpendOptions { - package: string; - arguments: SpendArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Spend a `Token` by unwrapping it and storing the `Balance` in the - * `ActionRequest` for the "spend" action. The `ActionRequest` contains the - * `spent_balance` field to be used in verification. - * - * Spend action requires `confirm_request_mut` to be called to confirm the request - * and join the spent balance with the `TokenPolicy.spent_balance`. - */ -export function spend(options: SpendOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'spend', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ToCoinArguments { - t: RawTransactionArgument; -} -export interface ToCoinOptions { - package: string; - arguments: ToCoinArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Convert `Token` into an open `Coin`. Creates an `ActionRequest` for the - * "to_coin" action. - */ -export function toCoin(options: ToCoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'to_coin', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromCoinArguments { - coin: RawTransactionArgument; -} -export interface FromCoinOptions { - package: string; - arguments: FromCoinArguments | [coin: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Convert an open `Coin` into a `Token`. Creates an `ActionRequest` for the - * "from_coin" action. - */ -export function fromCoin(options: FromCoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'from_coin', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface JoinArguments { - token: RawTransactionArgument; - another: RawTransactionArgument; -} -export interface JoinOptions { - package: string; - arguments: - | JoinArguments - | [token: RawTransactionArgument, another: RawTransactionArgument]; - typeArguments: [string]; -} -/** Join two `Token`s into one, always available. */ -export function join(options: JoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['token', 'another']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'join', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SplitArguments { - token: RawTransactionArgument; - amount: RawTransactionArgument; -} -export interface SplitOptions { - package: string; - arguments: - | SplitArguments - | [token: RawTransactionArgument, amount: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Split a `Token` with `amount`. Aborts if the `Token.balance` is lower than - * `amount`. - */ -export function split(options: SplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['token', 'amount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ZeroOptions { - package: string; - arguments?: []; - typeArguments: [string]; -} -/** Create a zero `Token`. */ -export function zero(options: ZeroOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'zero', - typeArguments: options.typeArguments, - }); -} -export interface DestroyZeroArguments { - token: RawTransactionArgument; -} -export interface DestroyZeroOptions { - package: string; - arguments: DestroyZeroArguments | [token: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Destroy an empty `Token`, fails if the balance is non-zero. Aborts if the - * `Token.balance` is not zero. - */ -export function destroyZero(options: DestroyZeroOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['token']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'destroy_zero', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface KeepArguments { - token: RawTransactionArgument; -} -export interface KeepOptions { - package: string; - arguments: KeepArguments | [token: RawTransactionArgument]; - typeArguments: [string]; -} -/** Transfer the `Token` to the transaction sender. */ -export function keep(options: KeepOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['token']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'keep', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewRequestArguments { - name: RawTransactionArgument; - amount: RawTransactionArgument; - recipient: RawTransactionArgument; - spentBalance: RawTransactionArgument; -} -export interface NewRequestOptions { - package: string; - arguments: - | NewRequestArguments - | [ - name: RawTransactionArgument, - amount: RawTransactionArgument, - recipient: RawTransactionArgument, - spentBalance: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Create a new `ActionRequest`. Publicly available method to allow for custom - * actions. - */ -export function newRequest(options: NewRequestOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x1::string::String', - 'u64', - '0x1::option::Option
', - '0x1::option::Option', - ] satisfies (string | null)[]; - const parameterNames = ['name', 'amount', 'recipient', 'spentBalance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'new_request', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ConfirmRequestArguments { - policy: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface ConfirmRequestOptions { - package: string; - arguments: - | ConfirmRequestArguments - | [policy: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Confirm the request against the `TokenPolicy` and return the parameters of the - * request: (Name, Amount, Sender, Recipient). - * - * Cannot be used for `spend` and similar actions that deliver `spent_balance` to - * the `TokenPolicy`. For those actions use `confirm_request_mut`. - * - * Aborts if: - * - * - the action is not allowed (missing record in `rules`) - * - action contains `spent_balance` (use `confirm_request_mut`) - * - the `ActionRequest` does not meet the `TokenPolicy` rules for the action - */ -export function confirmRequest(options: ConfirmRequestOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['policy', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'confirm_request', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ConfirmRequestMutArguments { - policy: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface ConfirmRequestMutOptions { - package: string; - arguments: - | ConfirmRequestMutArguments - | [policy: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Confirm the request against the `TokenPolicy` and return the parameters of the - * request: (Name, Amount, Sender, Recipient). - * - * Unlike `confirm_request` this function requires mutable access to the - * `TokenPolicy` and must be used on `spend` action. After dealing with the spent - * balance it calls `confirm_request` internally. - * - * See `confirm_request` for the list of abort conditions. - */ -export function confirmRequestMut(options: ConfirmRequestMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['policy', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'confirm_request_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ConfirmWithPolicyCapArguments { - PolicyCap: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface ConfirmWithPolicyCapOptions { - package: string; - arguments: - | ConfirmWithPolicyCapArguments - | [PolicyCap: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Confirm an `ActionRequest` as the `TokenPolicyCap` owner. This function allows - * `TokenPolicy` owner to perform Capability-gated actions ignoring the ruleset - * specified in the `TokenPolicy`. - * - * Aborts if request contains `spent_balance` due to inability of the - * `TokenPolicyCap` to decrease supply. For scenarios like this a `TreasuryCap` is - * required (see `confirm_with_treasury_cap`). - */ -export function confirmWithPolicyCap(options: ConfirmWithPolicyCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['PolicyCap', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'confirm_with_policy_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ConfirmWithTreasuryCapArguments { - treasuryCap: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface ConfirmWithTreasuryCapOptions { - package: string; - arguments: - | ConfirmWithTreasuryCapArguments - | [treasuryCap: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Confirm an `ActionRequest` as the `TreasuryCap` owner. This function allows - * `TreasuryCap` owner to perform Capability-gated actions ignoring the ruleset - * specified in the `TokenPolicy`. - * - * Unlike `confirm_with_policy_cap` this function allows `spent_balance` to be - * consumed, decreasing the `total_supply` of the `Token`. - */ -export function confirmWithTreasuryCap(options: ConfirmWithTreasuryCapOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['treasuryCap', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'confirm_with_treasury_cap', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddApprovalArguments> { - T: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface AddApprovalOptions> { - package: string; - arguments: - | AddApprovalArguments - | [T: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Add an "approval" to the `ActionRequest` by providing a Witness. Intended to be - * used by Rules to add their own approvals, however, can be used to add arbitrary - * approvals to the request (not only the ones required by the `TokenPolicy`). - */ -export function addApproval>(options: AddApprovalOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; - const parameterNames = ['T', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'add_approval', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddRuleConfigArguments, Config extends BcsType> { - Rule: RawTransactionArgument; - self: RawTransactionArgument; - cap: RawTransactionArgument; - config: RawTransactionArgument; -} -export interface AddRuleConfigOptions, Config extends BcsType> { - package: string; - arguments: - | AddRuleConfigArguments - | [ - Rule: RawTransactionArgument, - self: RawTransactionArgument, - cap: RawTransactionArgument, - config: RawTransactionArgument, - ]; - typeArguments: [string, string, string]; -} -/** - * Add a `Config` for a `Rule` in the `TokenPolicy`. Rule configuration is - * independent from the `TokenPolicy.rules` and needs to be managed by the Rule - * itself. Configuration is stored per `Rule` and not per `Rule` per `Action` to - * allow reuse in different actions. - * - * - Rule witness guarantees that the `Config` is approved by the Rule. - * - `TokenPolicyCap` guarantees that the `Config` setup is initiated by the - * `TokenPolicy` owner. - */ -export function addRuleConfig, Config extends BcsType>( - options: AddRuleConfigOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[1]}`, - null, - null, - `${options.typeArguments[2]}`, - ] satisfies (string | null)[]; - const parameterNames = ['Rule', 'self', 'cap', 'config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'add_rule_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RuleConfigArguments> { - Rule: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface RuleConfigOptions> { - package: string; - arguments: - | RuleConfigArguments - | [Rule: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string, string, string]; -} -/** - * Get a `Config` for a `Rule` in the `TokenPolicy`. Requires `Rule` witness, hence - * can only be read by the `Rule` itself. This requirement guarantees safety of the - * stored `Config` and allows for simpler dynamic field management inside the Rule - * Config (custom type keys are not needed for access gating). - * - * Aborts if the Config is not present. - */ -export function ruleConfig>(options: RuleConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; - const parameterNames = ['Rule', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'rule_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RuleConfigMutArguments> { - Rule: RawTransactionArgument; - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface RuleConfigMutOptions> { - package: string; - arguments: - | RuleConfigMutArguments - | [ - Rule: RawTransactionArgument, - self: RawTransactionArgument, - cap: RawTransactionArgument, - ]; - typeArguments: [string, string, string]; -} -/** - * Get mutable access to the `Config` for a `Rule` in the `TokenPolicy`. Requires - * `Rule` witness, hence can only be read by the `Rule` itself, as well as - * `TokenPolicyCap` to guarantee that the `TokenPolicy` owner is the one who - * initiated the `Config` modification. - * - * Aborts if: - * - * - the Config is not present - * - `TokenPolicyCap` is not matching the `TokenPolicy` - */ -export function ruleConfigMut>(options: RuleConfigMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null, null] satisfies (string | null)[]; - const parameterNames = ['Rule', 'self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'rule_config_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveRuleConfigArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface RemoveRuleConfigOptions { - package: string; - arguments: - | RemoveRuleConfigArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string, string, string]; -} -/** - * Remove a `Config` for a `Rule` in the `TokenPolicy`. Unlike the - * `add_rule_config`, this function does not require a `Rule` witness, hence can be - * performed by the `TokenPolicy` owner on their own. - * - * Rules need to make sure that the `Config` is present when performing - * verification of the `ActionRequest`. - * - * Aborts if: - * - * - the Config is not present - * - `TokenPolicyCap` is not matching the `TokenPolicy` - */ -export function removeRuleConfig(options: RemoveRuleConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'remove_rule_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface HasRuleConfigArguments { - self: RawTransactionArgument; -} -export interface HasRuleConfigOptions { - package: string; - arguments: HasRuleConfigArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Check if a config for a `Rule` is set in the `TokenPolicy` without checking the - * type of the `Config`. - */ -export function hasRuleConfig(options: HasRuleConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'has_rule_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface HasRuleConfigWithTypeArguments { - self: RawTransactionArgument; -} -export interface HasRuleConfigWithTypeOptions { - package: string; - arguments: HasRuleConfigWithTypeArguments | [self: RawTransactionArgument]; - typeArguments: [string, string, string]; -} -/** - * Check if a `Config` for a `Rule` is set in the `TokenPolicy` and that it matches - * the type provided. - */ -export function hasRuleConfigWithType(options: HasRuleConfigWithTypeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'has_rule_config_with_type', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AllowArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface AllowOptions { - package: string; - arguments: - | AllowArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - action: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Allows an `action` to be performed on the `Token` freely by adding an empty set - * of `Rules` for the `action`. - * - * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. - */ -export function allow(options: AllowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'allow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DisallowArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface DisallowOptions { - package: string; - arguments: - | DisallowArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - action: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Completely disallows an `action` on the `Token` by removing the record from the - * `TokenPolicy.rules`. - * - * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. - */ -export function disallow(options: DisallowOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'disallow', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddRuleForActionArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface AddRuleForActionOptions { - package: string; - arguments: - | AddRuleForActionArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - action: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Adds a Rule for an action with `name` in the `TokenPolicy`. - * - * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. - */ -export function addRuleForAction(options: AddRuleForActionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'add_rule_for_action', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveRuleForActionArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface RemoveRuleForActionOptions { - package: string; - arguments: - | RemoveRuleForActionArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - action: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Removes a rule for an action with `name` in the `TokenPolicy`. Returns the - * config object to be handled by the sender (or a Rule itself). - * - * Aborts if the `TokenPolicyCap` is not matching the `TokenPolicy`. - */ -export function removeRuleForAction(options: RemoveRuleForActionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'remove_rule_for_action', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface MintArguments { - cap: RawTransactionArgument; - amount: RawTransactionArgument; -} -export interface MintOptions { - package: string; - arguments: - | MintArguments - | [cap: RawTransactionArgument, amount: RawTransactionArgument]; - typeArguments: [string]; -} -/** Mint a `Token` with a given `amount` using the `TreasuryCap`. */ -export function mint(options: MintOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['cap', 'amount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'mint', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface BurnArguments { - cap: RawTransactionArgument; - token: RawTransactionArgument; -} -export interface BurnOptions { - package: string; - arguments: - | BurnArguments - | [cap: RawTransactionArgument, token: RawTransactionArgument]; - typeArguments: [string]; -} -/** Burn a `Token` using the `TreasuryCap`. */ -export function burn(options: BurnOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['cap', 'token']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'burn', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FlushArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface FlushOptions { - package: string; - arguments: - | FlushArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Flush the `TokenPolicy.spent_balance` into the `TreasuryCap`. This action is - * only available to the `TreasuryCap` owner. - */ -export function flush(options: FlushOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'flush', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsAllowedArguments { - self: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface IsAllowedOptions { - package: string; - arguments: - | IsAllowedArguments - | [self: RawTransactionArgument, action: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check whether an action is present in the rules VecMap. */ -export function isAllowed(options: IsAllowedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'is_allowed', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RulesArguments { - self: RawTransactionArgument; - action: RawTransactionArgument; -} -export interface RulesOptions { - package: string; - arguments: - | RulesArguments - | [self: RawTransactionArgument, action: RawTransactionArgument]; - typeArguments: [string]; -} -/** Returns the rules required for a specific action. */ -export function rules(options: RulesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'action']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'rules', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SpentBalanceArguments { - self: RawTransactionArgument; -} -export interface SpentBalanceOptions { - package: string; - arguments: SpentBalanceArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Returns the `spent_balance` of the `TokenPolicy`. */ -export function spentBalance(options: SpentBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'spent_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ValueArguments { - t: RawTransactionArgument; -} -export interface ValueOptions { - package: string; - arguments: ValueArguments | [t: RawTransactionArgument]; - typeArguments: [string]; -} -/** Returns the `balance` of the `Token`. */ -export function value(options: ValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['t']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TransferActionOptions { - package: string; - arguments?: []; -} -/** Name of the Transfer action. */ -export function transferAction(options: TransferActionOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'transfer_action', - }); -} -export interface SpendActionOptions { - package: string; - arguments?: []; -} -/** Name of the `Spend` action. */ -export function spendAction(options: SpendActionOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'spend_action', - }); -} -export interface ToCoinActionOptions { - package: string; - arguments?: []; -} -/** Name of the `ToCoin` action. */ -export function toCoinAction(options: ToCoinActionOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'to_coin_action', - }); -} -export interface FromCoinActionOptions { - package: string; - arguments?: []; -} -/** Name of the `FromCoin` action. */ -export function fromCoinAction(options: FromCoinActionOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'from_coin_action', - }); -} -export interface ActionArguments { - self: RawTransactionArgument; -} -export interface ActionOptions { - package: string; - arguments: ActionArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** The Action in the `ActionRequest`. */ -export function action(options: ActionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'action', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AmountArguments { - self: RawTransactionArgument; -} -export interface AmountOptions { - package: string; - arguments: AmountArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Amount of the `ActionRequest`. */ -export function amount(options: AmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SenderArguments { - self: RawTransactionArgument; -} -export interface SenderOptions { - package: string; - arguments: SenderArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Sender of the `ActionRequest`. */ -export function sender(options: SenderOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'sender', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RecipientArguments { - self: RawTransactionArgument; -} -export interface RecipientOptions { - package: string; - arguments: RecipientArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Recipient of the `ActionRequest`. */ -export function recipient(options: RecipientOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'recipient', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ApprovalsArguments { - self: RawTransactionArgument; -} -export interface ApprovalsOptions { - package: string; - arguments: ApprovalsArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Approvals of the `ActionRequest`. */ -export function approvals(options: ApprovalsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'approvals', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SpentArguments { - self: RawTransactionArgument; -} -export interface SpentOptions { - package: string; - arguments: SpentArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Burned balance of the `ActionRequest`. */ -export function spent(options: SpentOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'token', - function: 'spent', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts b/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts deleted file mode 100644 index 3c9fcf515..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/transfer.ts +++ /dev/null @@ -1,358 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::transfer'; -export const Receiving = new MoveStruct({ - name: `${$moduleName}::Receiving`, - fields: { - id: bcs.Address, - version: bcs.u64(), - }, -}); -export interface TransferArguments> { - obj: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface TransferOptions> { - package: string; - arguments: - | TransferArguments - | [obj: RawTransactionArgument, recipient: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Transfer ownership of `obj` to `recipient`. `obj` must have the `key` attribute, - * which (in turn) ensures that `obj` has a globally unique ID. Note that if the - * recipient address represents an object ID, the `obj` sent will be inaccessible - * after the transfer (though they will be retrievable at a future date once new - * features are added). This function has custom rules performed by the Sui Move - * bytecode verifier that ensures that `T` is an object defined in the module where - * `transfer` is invoked. Use `public_transfer` to transfer an object with `store` - * outside of its module. - */ -export function transfer>(options: TransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, 'address'] satisfies (string | null)[]; - const parameterNames = ['obj', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublicTransferArguments> { - obj: RawTransactionArgument; - recipient: RawTransactionArgument; -} -export interface PublicTransferOptions> { - package: string; - arguments: - | PublicTransferArguments - | [obj: RawTransactionArgument, recipient: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Transfer ownership of `obj` to `recipient`. `obj` must have the `key` attribute, - * which (in turn) ensures that `obj` has a globally unique ID. Note that if the - * recipient address represents an object ID, the `obj` sent will be inaccessible - * after the transfer (though they will be retrievable at a future date once new - * features are added). The object must have `store` to be transferred outside of - * its module. - */ -export function publicTransfer>(options: PublicTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, 'address'] satisfies (string | null)[]; - const parameterNames = ['obj', 'recipient']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'public_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PartyTransferArguments> { - obj: RawTransactionArgument; - party: RawTransactionArgument; -} -export interface PartyTransferOptions> { - package: string; - arguments: - | PartyTransferArguments - | [obj: RawTransactionArgument, party: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * NOT YET SUPPORTED ON MAINNET. The function will abort with `ENotSupported` if - * used on a network where party objects are not yet supported. Transfer ownership - * of `obj` to the `party`. This transfer behaves similar to both `transfer` and - * `share_object`. It is similar to `transfer` in that the object is authorized for - * use only by the recipient(s), in this case the `party`. This means that only the - * members can use the object as an input to a transaction. It is similar to - * `share_object` two ways. One in that the object can potentially be used by - * anyone, as defined by the `default` permissions of the `Party` value. The other - * in that the object must be used in consensus and cannot be used in the fast - * path. This function has custom rules performed by the Sui Move bytecode verifier - * that ensures that `T` is an object defined in the module where `transfer` is - * invoked. Use `public_party_transfer` to transfer an object with `store` outside - * of its module. - */ -export function partyTransfer>(options: PartyTransferOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['obj', 'party']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'party_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublicPartyTransferArguments> { - obj: RawTransactionArgument; - party: RawTransactionArgument; -} -export interface PublicPartyTransferOptions> { - package: string; - arguments: - | PublicPartyTransferArguments - | [obj: RawTransactionArgument, party: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * NOT YET SUPPORTED ON MAINNET. The function will abort with `ENotSupported` if - * used on a network where party objects are not yet supported. Transfer ownership - * of `obj` to the `party`. This transfer behaves similar to both `transfer` and - * `share_object`. It is similar to `transfer` in that the object is authorized for - * use only by the recipient(s), in this case the `party`. This means that only the - * members can use the object as an input to a transaction. It is similar to - * `share_object` two ways. One in that the object can potentially be used by - * anyone, as defined by the `default` permissions of the `Party` value. The other - * in that the object must be used in consensus and cannot be used in the fast - * path. The object must have `store` to be transferred outside of its module. - */ -export function publicPartyTransfer>( - options: PublicPartyTransferOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['obj', 'party']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'public_party_transfer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FreezeObjectArguments> { - obj: RawTransactionArgument; -} -export interface FreezeObjectOptions> { - package: string; - arguments: FreezeObjectArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Freeze `obj`. After freezing `obj` becomes immutable and can no longer be - * transferred or mutated. This function has custom rules performed by the Sui Move - * bytecode verifier that ensures that `T` is an object defined in the module where - * `freeze_object` is invoked. Use `public_freeze_object` to freeze an object with - * `store` outside of its module. - */ -export function freezeObject>(options: FreezeObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'freeze_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublicFreezeObjectArguments> { - obj: RawTransactionArgument; -} -export interface PublicFreezeObjectOptions> { - package: string; - arguments: PublicFreezeObjectArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Freeze `obj`. After freezing `obj` becomes immutable and can no longer be - * transferred or mutated. The object must have `store` to be frozen outside of its - * module. - */ -export function publicFreezeObject>(options: PublicFreezeObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'public_freeze_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ShareObjectArguments> { - obj: RawTransactionArgument; -} -export interface ShareObjectOptions> { - package: string; - arguments: ShareObjectArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Turn the given object into a mutable shared object that everyone can access and - * mutate. This is irreversible, i.e. once an object is shared, it will stay shared - * forever. Aborts with `ESharedNonNewObject` of the object being shared was not - * created in this transaction. This restriction may be relaxed in the future. This - * function has custom rules performed by the Sui Move bytecode verifier that - * ensures that `T` is an object defined in the module where `share_object` is - * invoked. Use `public_share_object` to share an object with `store` outside of - * its module. - */ -export function shareObject>(options: ShareObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'share_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublicShareObjectArguments> { - obj: RawTransactionArgument; -} -export interface PublicShareObjectOptions> { - package: string; - arguments: PublicShareObjectArguments | [obj: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Turn the given object into a mutable shared object that everyone can access and - * mutate. This is irreversible, i.e. once an object is shared, it will stay shared - * forever. Aborts with `ESharedNonNewObject` of the object being shared was not - * created in this transaction. This restriction may be relaxed in the future. The - * object must have `store` to be shared outside of its module. - */ -export function publicShareObject>(options: PublicShareObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'public_share_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ReceiveArguments { - parent: RawTransactionArgument; - toReceive: RawTransactionArgument; -} -export interface ReceiveOptions { - package: string; - arguments: - | ReceiveArguments - | [parent: RawTransactionArgument, toReceive: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Given mutable (i.e., locked) access to the `parent` and a `Receiving` argument - * referencing an object of type `T` owned by `parent` use the `to_receive` - * argument to receive and return the referenced owned object of type `T`. This - * function has custom rules performed by the Sui Move bytecode verifier that - * ensures that `T` is an object defined in the module where `receive` is invoked. - * Use `public_receive` to receivne an object with `store` outside of its module. - */ -export function receive(options: ReceiveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', null] satisfies (string | null)[]; - const parameterNames = ['parent', 'toReceive']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'receive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PublicReceiveArguments { - parent: RawTransactionArgument; - toReceive: RawTransactionArgument; -} -export interface PublicReceiveOptions { - package: string; - arguments: - | PublicReceiveArguments - | [parent: RawTransactionArgument, toReceive: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Given mutable (i.e., locked) access to the `parent` and a `Receiving` argument - * referencing an object of type `T` owned by `parent` use the `to_receive` - * argument to receive and return the referenced owned object of type `T`. The - * object must have `store` to be received outside of its defining module. - */ -export function publicReceive(options: PublicReceiveOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', null] satisfies (string | null)[]; - const parameterNames = ['parent', 'toReceive']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'public_receive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ReceivingObjectIdArguments { - receiving: RawTransactionArgument; -} -export interface ReceivingObjectIdOptions { - package: string; - arguments: ReceivingObjectIdArguments | [receiving: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return the object ID that the given `Receiving` argument references. */ -export function receivingObjectId(options: ReceivingObjectIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['receiving']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer', - function: 'receiving_object_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts b/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts deleted file mode 100644 index 42da5d702..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/transfer_policy.ts +++ /dev/null @@ -1,602 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Defines the `TransferPolicy` type and the logic to approve `TransferRequest`s. - * - * - TransferPolicy - is a highly customizable primitive, which provides an - * interface for the type owner to set custom transfer rules for every deal - * performed in the `Kiosk` or a similar system that integrates with TP. - * - * - Once a `TransferPolicy` is created for and shared (or frozen), the type `T` - * becomes tradable in `Kiosk`s. On every purchase operation, a `TransferRequest` - * is created and needs to be confirmed by the `TransferPolicy` hot potato or - * transaction will fail. - * - * - Type owner (creator) can set any Rules as long as the ecosystem supports them. - * All of the Rules need to be resolved within a single transaction (eg pay - * royalty and pay fixed commission). Once required actions are performed, the - * `TransferRequest` can be "confirmed" via `confirm_request` call. - * - * - `TransferPolicy` aims to be the main interface for creators to control trades - * of their types and collect profits if a fee is required on sales. Custom - * policies can be removed at any moment, and the change will affect all - * instances of the type at once. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_set from './vec_set.js'; -import * as type_name from '../suins_auction/type_name.js'; -import * as balance from './balance.js'; -const $moduleName = '0x2::transfer_policy'; -export const TransferRequest = new MoveStruct({ - name: `${$moduleName}::TransferRequest`, - fields: { - /** - * The ID of the transferred item. Although the `T` has no constraints, the main - * use case for this module is to work with Objects. - */ - item: bcs.Address, - /** - * Amount of SUI paid for the item. Can be used to calculate the fee / transfer - * policy enforcement. - */ - paid: bcs.u64(), - /** - * The ID of the Kiosk / Safe the object is being sold from. Can be used by the - * TransferPolicy implementors. - */ - from: bcs.Address, - /** - * Collected Receipts. Used to verify that all of the rules were followed and - * `TransferRequest` can be confirmed. - */ - receipts: vec_set.VecSet(type_name.TypeName), - }, -}); -export const TransferPolicy = new MoveStruct({ - name: `${$moduleName}::TransferPolicy`, - fields: { - id: bcs.Address, - /** - * The Balance of the `TransferPolicy` which collects `SUI`. By default, transfer - * policy does not collect anything , and it's a matter of an implementation of a - * specific rule - whether to add to balance and how much. - */ - balance: balance.Balance, - /** - * Set of types of attached rules - used to verify `receipts` when a - * `TransferRequest` is received in `confirm_request` function. - * - * Additionally provides a way to look up currently attached Rules. - */ - rules: vec_set.VecSet(type_name.TypeName), - }, -}); -export const TransferPolicyCap = new MoveStruct({ - name: `${$moduleName}::TransferPolicyCap`, - fields: { - id: bcs.Address, - policy_id: bcs.Address, - }, -}); -export const TransferPolicyCreated = new MoveStruct({ - name: `${$moduleName}::TransferPolicyCreated`, - fields: { - id: bcs.Address, - }, -}); -export const TransferPolicyDestroyed = new MoveStruct({ - name: `${$moduleName}::TransferPolicyDestroyed`, - fields: { - id: bcs.Address, - }, -}); -export const RuleKey = new MoveStruct({ - name: `${$moduleName}::RuleKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface NewRequestArguments { - item: RawTransactionArgument; - paid: RawTransactionArgument; - from: RawTransactionArgument; -} -export interface NewRequestOptions { - package: string; - arguments: - | NewRequestArguments - | [ - item: RawTransactionArgument, - paid: RawTransactionArgument, - from: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Construct a new `TransferRequest` hot potato which requires an approving action - * from the creator to be destroyed / resolved. Once created, it must be confirmed - * in the `confirm_request` call otherwise the transaction will fail. - */ -export function newRequest(options: NewRequestOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', 'u64', '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['item', 'paid', 'from']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'new_request', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface NewArguments { - pub: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [pub: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Register a type in the Kiosk system and receive a `TransferPolicy` and a - * `TransferPolicyCap` for the type. The `TransferPolicy` is required to confirm - * kiosk deals for the `T`. If there's no `TransferPolicy` available for use, the - * type can not be traded in kiosks. - */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pub']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DefaultArguments { - pub: RawTransactionArgument; -} -export interface DefaultOptions { - package: string; - arguments: DefaultArguments | [pub: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Initialize the Transfer Policy in the default scenario: Create and share the - * `TransferPolicy`, transfer `TransferPolicyCap` to the transaction sender. - */ -export function _default(options: DefaultOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pub']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'default', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface WithdrawArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; - amount: RawTransactionArgument; -} -export interface WithdrawOptions { - package: string; - arguments: - | WithdrawArguments - | [ - self: RawTransactionArgument, - cap: RawTransactionArgument, - amount: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Withdraw some amount of profits from the `TransferPolicy`. If amount is not - * specified, all profits are withdrawn. - */ -export function withdraw(options: WithdrawOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::option::Option'] satisfies (string | null)[]; - const parameterNames = ['self', 'cap', 'amount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'withdraw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyAndWithdrawArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface DestroyAndWithdrawOptions { - package: string; - arguments: - | DestroyAndWithdrawArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Destroy a TransferPolicyCap. Can be performed by any party as long as they own - * it. - */ -export function destroyAndWithdraw(options: DestroyAndWithdrawOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'destroy_and_withdraw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ConfirmRequestArguments { - self: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface ConfirmRequestOptions { - package: string; - arguments: - | ConfirmRequestArguments - | [self: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Allow a `TransferRequest` for the type `T`. The call is protected by the type - * constraint, as only the publisher of the `T` can get `TransferPolicy`. - * - * Note: unless there's a policy for `T` to allow transfers, Kiosk trades will not - * be possible. - */ -export function confirmRequest(options: ConfirmRequestOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'confirm_request', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddRuleArguments, Config extends BcsType> { - _: RawTransactionArgument; - policy: RawTransactionArgument; - cap: RawTransactionArgument; - cfg: RawTransactionArgument; -} -export interface AddRuleOptions, Config extends BcsType> { - package: string; - arguments: - | AddRuleArguments - | [ - _: RawTransactionArgument, - policy: RawTransactionArgument, - cap: RawTransactionArgument, - cfg: RawTransactionArgument, - ]; - typeArguments: [string, string, string]; -} -/** - * Add a custom Rule to the `TransferPolicy`. Once set, `TransferRequest` must - * receive a confirmation of the rule executed so the hot potato can be unpacked. - * - * - T: the type to which TransferPolicy is applied. - * - Rule: the witness type for the Custom rule - * - Config: a custom configuration for the rule - * - * Config requires `drop` to allow creators to remove any policy at any moment, - * even if graceful unpacking has not been implemented in a "rule module". - */ -export function addRule, Config extends BcsType>( - options: AddRuleOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `${options.typeArguments[1]}`, - null, - null, - `${options.typeArguments[2]}`, - ] satisfies (string | null)[]; - const parameterNames = ['_', 'policy', 'cap', 'cfg']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'add_rule', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetRuleArguments> { - _: RawTransactionArgument; - policy: RawTransactionArgument; -} -export interface GetRuleOptions> { - package: string; - arguments: - | GetRuleArguments - | [_: RawTransactionArgument, policy: RawTransactionArgument]; - typeArguments: [string, string, string]; -} -/** Get the custom Config for the Rule (can be only one per "Rule" type). */ -export function getRule>(options: GetRuleOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; - const parameterNames = ['_', 'policy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'get_rule', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddToBalanceArguments> { - _: RawTransactionArgument; - policy: RawTransactionArgument; - coin: RawTransactionArgument; -} -export interface AddToBalanceOptions> { - package: string; - arguments: - | AddToBalanceArguments - | [ - _: RawTransactionArgument, - policy: RawTransactionArgument, - coin: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** Add some `SUI` to the balance of a `TransferPolicy`. */ -export function addToBalance>(options: AddToBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'policy', 'coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'add_to_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddReceiptArguments> { - _: RawTransactionArgument; - request: RawTransactionArgument; -} -export interface AddReceiptOptions> { - package: string; - arguments: - | AddReceiptArguments - | [_: RawTransactionArgument, request: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Adds a `Receipt` to the `TransferRequest`, unblocking the request and confirming - * that the policy requirements are satisfied. - */ -export function addReceipt>(options: AddReceiptOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[1]}`, null] satisfies (string | null)[]; - const parameterNames = ['_', 'request']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'add_receipt', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface HasRuleArguments { - policy: RawTransactionArgument; -} -export interface HasRuleOptions { - package: string; - arguments: HasRuleArguments | [policy: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Check whether a custom rule has been added to the `TransferPolicy`. */ -export function hasRule(options: HasRuleOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['policy']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'has_rule', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveRuleArguments { - policy: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface RemoveRuleOptions { - package: string; - arguments: - | RemoveRuleArguments - | [policy: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string, string, string]; -} -/** Remove the Rule from the `TransferPolicy`. */ -export function removeRule(options: RemoveRuleOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['policy', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'remove_rule', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UidArguments { - self: RawTransactionArgument; -} -export interface UidOptions { - package: string; - arguments: UidArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Allows reading custom attachments to the `TransferPolicy` if there are any. */ -export function uid(options: UidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'uid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UidMutAsOwnerArguments { - self: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface UidMutAsOwnerOptions { - package: string; - arguments: - | UidMutAsOwnerArguments - | [self: RawTransactionArgument, cap: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get a mutable reference to the `self.id` to enable custom attachments to the - * `TransferPolicy`. - */ -export function uidMutAsOwner(options: UidMutAsOwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'uid_mut_as_owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RulesArguments { - self: RawTransactionArgument; -} -export interface RulesOptions { - package: string; - arguments: RulesArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Read the `rules` field from the `TransferPolicy`. */ -export function rules(options: RulesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'rules', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ItemArguments { - self: RawTransactionArgument; -} -export interface ItemOptions { - package: string; - arguments: ItemArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `item` field of the `TransferRequest`. */ -export function item(options: ItemOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'item', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PaidArguments { - self: RawTransactionArgument; -} -export interface PaidOptions { - package: string; - arguments: PaidArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `paid` field of the `TransferRequest`. */ -export function paid(options: PaidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'paid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromArguments { - self: RawTransactionArgument; -} -export interface FromOptions { - package: string; - arguments: FromArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get the `from` field of the `TransferRequest`. */ -export function _from(options: FromOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'transfer_policy', - function: 'from', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts b/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts deleted file mode 100644 index f77dd4b1d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/tx_context.ts +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::tx_context'; -export const TxContext = new MoveStruct({ - name: `${$moduleName}::TxContext`, - fields: { - /** The address of the user that signed the current transaction */ - sender: bcs.Address, - /** Hash of the current transaction */ - tx_hash: bcs.vector(bcs.u8()), - /** The current epoch number */ - epoch: bcs.u64(), - /** Timestamp that the epoch started at */ - epoch_timestamp_ms: bcs.u64(), - /** - * Counter recording the number of fresh id's created while executing this - * transaction. Always 0 at the start of a transaction - */ - ids_created: bcs.u64(), - }, -}); -export interface SenderOptions { - package: string; - arguments?: []; -} -/** Return the address of the user that signed the current transaction */ -export function sender(options: SenderOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'sender', - }); -} -export interface DigestOptions { - package: string; - arguments?: []; -} -/** - * Return the transaction digest (hash of transaction inputs). Please do not use as - * a source of randomness. - */ -export function digest(options: DigestOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'digest', - }); -} -export interface EpochOptions { - package: string; - arguments?: []; -} -/** Return the current epoch */ -export function epoch(options: EpochOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'epoch', - }); -} -export interface EpochTimestampMsOptions { - package: string; - arguments?: []; -} -/** Return the epoch start time as a unix timestamp in milliseconds. */ -export function epochTimestampMs(options: EpochTimestampMsOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'epoch_timestamp_ms', - }); -} -export interface SponsorOptions { - package: string; - arguments?: []; -} -/** Return the adress of the transaction sponsor or `None` if there was no sponsor. */ -export function sponsor(options: SponsorOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'sponsor', - }); -} -export interface FreshObjectAddressOptions { - package: string; - arguments?: []; -} -/** - * Create an `address` that has not been used. As it is an object address, it will - * never occur as the address for a user. In other words, the generated address is - * a globally unique object ID. - */ -export function freshObjectAddress(options: FreshObjectAddressOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'fresh_object_address', - }); -} -export interface ReferenceGasPriceOptions { - package: string; - arguments?: []; -} -/** - * Return the reference gas price in effect for the epoch the transaction is being - * executed in. - */ -export function referenceGasPrice(options: ReferenceGasPriceOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'reference_gas_price', - }); -} -export interface GasPriceOptions { - package: string; - arguments?: []; -} -/** - * Return the gas price submitted for the current transaction. That is the value - * the user submitted with the transaction data. - */ -export function gasPrice(options: GasPriceOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'tx_context', - function: 'gas_price', - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/types.ts b/packages/suins/src/contracts/suins_auction/deps/sui/types.ts deleted file mode 100644 index ee85b81a9..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/types.ts +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** Sui types helpers and utilities */ - -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -import { type BcsType } from '@mysten/sui/bcs'; -export interface IsOneTimeWitnessArguments> { - _: RawTransactionArgument; -} -export interface IsOneTimeWitnessOptions> { - package: string; - arguments: IsOneTimeWitnessArguments | [_: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Tests if the argument type is a one-time witness, that is a type with only one - * instantiation across the entire code base. - */ -export function isOneTimeWitness>(options: IsOneTimeWitnessOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'types', - function: 'is_one_time_witness', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/url.ts b/packages/suins/src/contracts/suins_auction/deps/sui/url.ts deleted file mode 100644 index e41774d90..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/url.ts +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** URL: standard Uniform Resource Locator string */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::url'; -export const Url = new MoveStruct({ - name: `${$moduleName}::Url`, - fields: { - url: bcs.string(), - }, -}); -export interface NewUnsafeArguments { - url: RawTransactionArgument; -} -export interface NewUnsafeOptions { - package: string; - arguments: NewUnsafeArguments | [url: RawTransactionArgument]; -} -/** Create a `Url`, with no validation */ -export function newUnsafe(options: NewUnsafeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['url']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'url', - function: 'new_unsafe', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewUnsafeFromBytesArguments { - bytes: RawTransactionArgument; -} -export interface NewUnsafeFromBytesOptions { - package: string; - arguments: NewUnsafeFromBytesArguments | [bytes: RawTransactionArgument]; -} -/** - * Create a `Url` with no validation from bytes Note: this will abort if `bytes` is - * not valid ASCII - */ -export function newUnsafeFromBytes(options: NewUnsafeFromBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['bytes']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'url', - function: 'new_unsafe_from_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface InnerUrlArguments { - self: RawTransactionArgument; -} -export interface InnerUrlOptions { - package: string; - arguments: InnerUrlArguments | [self: RawTransactionArgument]; -} -/** Get inner URL */ -export function innerUrl(options: InnerUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'url', - function: 'inner_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateArguments { - self: RawTransactionArgument; - url: RawTransactionArgument; -} -export interface UpdateOptions { - package: string; - arguments: - | UpdateArguments - | [self: RawTransactionArgument, url: RawTransactionArgument]; -} -/** Update the inner URL */ -export function update(options: UpdateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'url']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'url', - function: 'update', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts deleted file mode 100644 index 5589dbfdf..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/vdf.ts +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type Transaction } from '@mysten/sui/transactions'; -import { normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; -export interface HashToInputArguments { - message: RawTransactionArgument; -} -export interface HashToInputOptions { - package: string; - arguments: HashToInputArguments | [message: RawTransactionArgument]; -} -/** - * Hash an arbitrary binary `message` to a class group element to be used as input - * for `vdf_verify`. - * - * This function is currently only enabled on Devnet. - */ -export function hashToInput(options: HashToInputOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['message']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vdf', - function: 'hash_to_input', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VdfVerifyArguments { - input: RawTransactionArgument; - output: RawTransactionArgument; - proof: RawTransactionArgument; - iterations: RawTransactionArgument; -} -export interface VdfVerifyOptions { - package: string; - arguments: - | VdfVerifyArguments - | [ - input: RawTransactionArgument, - output: RawTransactionArgument, - proof: RawTransactionArgument, - iterations: RawTransactionArgument, - ]; -} -/** - * Verify the output and proof of a VDF with the given number of iterations. The - * `input`, `output` and `proof` are all class group elements represented by - * triples `(a,b,c)` such that `b^2 - 4ac = discriminant`. The are expected to be - * encoded as a BCS encoding of a triple of byte arrays, each being the big-endian - * twos-complement encoding of a, b and c in that order. - * - * This uses Wesolowski's VDF construction over imaginary class groups as described - * in Wesolowski (2020), 'Efficient Verifiable Delay Functions.', J. Cryptol. 33, - * and is compatible with the VDF implementation in fastcrypto. - * - * The discriminant for the class group is pre-computed and fixed. See how this was - * generated in the fastcrypto-vdf crate. The final selection of the discriminant - * for Mainnet will be computed and announced under a nothing-up-my-sleeve process. - * - * This function is currently only enabled on Devnet. - */ -export function vdfVerify(options: VdfVerifyOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector', 'vector', 'u64'] satisfies ( - | string - | null - )[]; - const parameterNames = ['input', 'output', 'proof', 'iterations']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vdf', - function: 'vdf_verify', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts deleted file mode 100644 index 2708c145f..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/vec_map.ts +++ /dev/null @@ -1,568 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::vec_map'; -/** An entry in the map */ -export function Entry, V extends BcsType>(...typeParameters: [K, V]) { - return new MoveStruct({ - name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, - fields: { - key: typeParameters[0], - value: typeParameters[1], - }, - }); -} -/** - * A map data structure backed by a vector. The map is guaranteed not to contain - * duplicate keys, but entries are _not_ sorted by key--entries are included in - * insertion order. All operations are O(N) in the size of the map--the intention - * of this data structure is only to provide the convenience of programming against - * a map API. Large maps should use handwritten parent/child relationships instead. - * Maps that need sorted iteration rather than insertion order iteration should - * also be handwritten. - */ -export function VecMap, V extends BcsType>(...typeParameters: [K, V]) { - return new MoveStruct({ - name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, - fields: { - contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])), - }, - }); -} -export interface EmptyOptions { - package: string; - arguments?: []; - typeArguments: [string, string]; -} -/** Create an empty `VecMap` */ -export function empty(options: EmptyOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'empty', - typeArguments: options.typeArguments, - }); -} -export interface InsertArguments, V extends BcsType> { - self: RawTransactionArgument; - key: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface InsertOptions, V extends BcsType> { - package: string; - arguments: - | InsertArguments - | [ - self: RawTransactionArgument, - key: RawTransactionArgument, - value: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Insert the entry `key` |-> `value` into `self`. Aborts if `key` is already bound - * in `self`. - */ -export function insert, V extends BcsType>( - options: InsertOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - `${options.typeArguments[0]}`, - `${options.typeArguments[1]}`, - ] satisfies (string | null)[]; - const parameterNames = ['self', 'key', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'insert', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in - * `self`. - */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface PopArguments { - self: RawTransactionArgument; -} -export interface PopOptions { - package: string; - arguments: PopArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Pop the most recently inserted entry from the map. Aborts if the map is empty. */ -export function pop(options: PopOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'pop', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetMutArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface GetMutOptions> { - package: string; - arguments: - | GetMutArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Get a mutable reference to the value bound to `key` in `self`. Aborts if `key` - * is not bound in `self`. - */ -export function getMut>(options: GetMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface GetOptions> { - package: string; - arguments: - | GetArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Get a reference to the value bound to `key` in `self`. Aborts if `key` is not - * bound in `self`. - */ -export function get>(options: GetOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface TryGetArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface TryGetOptions> { - package: string; - arguments: - | TryGetArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Safely try borrow a value bound to `key` in `self`. Return Some(V) if the value - * exists, None otherwise. Only works for a "copyable" value as references cannot - * be stored in `vector`. - */ -export function tryGet>(options: TryGetOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'try_get', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Return true if `self` contains an entry for `key`, false otherwise */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - self: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Return the number of entries in `self` */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - self: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Return true if `self` has 0 elements, false otherwise */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyEmptyArguments { - self: RawTransactionArgument; -} -export interface DestroyEmptyOptions { - package: string; - arguments: DestroyEmptyArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Destroy an empty map. Aborts if `self` is not empty */ -export function destroyEmpty(options: DestroyEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'destroy_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IntoKeysValuesArguments { - self: RawTransactionArgument; -} -export interface IntoKeysValuesOptions { - package: string; - arguments: IntoKeysValuesArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Unpack `self` into vectors of its keys and values. The output keys and values - * are stored in insertion order, _not_ sorted by key. - */ -export function intoKeysValues(options: IntoKeysValuesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'into_keys_values', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromKeysValuesArguments, V extends BcsType> { - keys: RawTransactionArgument; - values: RawTransactionArgument; -} -export interface FromKeysValuesOptions, V extends BcsType> { - package: string; - arguments: - | FromKeysValuesArguments - | [keys: RawTransactionArgument, values: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Construct a new `VecMap` from two vectors, one for keys and one for values. The - * key value pairs are associated via their indices in the vectors, e.g. the key at - * index i in `keys` is associated with the value at index i in `values`. The key - * value pairs are stored in insertion order (the original vectors ordering) and - * are _not_ sorted. - */ -export function fromKeysValues, V extends BcsType>( - options: FromKeysValuesOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - `vector<${options.typeArguments[0]}>`, - `vector<${options.typeArguments[1]}>`, - ] satisfies (string | null)[]; - const parameterNames = ['keys', 'values']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'from_keys_values', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface KeysArguments { - self: RawTransactionArgument; -} -export interface KeysOptions { - package: string; - arguments: KeysArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Returns a list of keys in the map. Do not assume any particular ordering. */ -export function keys(options: KeysOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'keys', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetIdxOptArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface GetIdxOptOptions> { - package: string; - arguments: - | GetIdxOptArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Find the index of `key` in `self`. Return `None` if `key` is not in `self`. Note - * that map entries are stored in insertion order, _not_ sorted by key. - */ -export function getIdxOpt>(options: GetIdxOptOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get_idx_opt', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetIdxArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface GetIdxOptions> { - package: string; - arguments: - | GetIdxArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Find the index of `key` in `self`. Aborts if `key` is not in `self`. Note that - * map entries are stored in insertion order, _not_ sorted by key. - */ -export function getIdx>(options: GetIdxOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get_idx', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetEntryByIdxArguments { - self: RawTransactionArgument; - idx: RawTransactionArgument; -} -export interface GetEntryByIdxOptions { - package: string; - arguments: - | GetEntryByIdxArguments - | [self: RawTransactionArgument, idx: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Return a reference to the `idx`th entry of `self`. This gives direct access into - * the backing array of the map--use with caution. Note that map entries are stored - * in insertion order, _not_ sorted by key. Aborts if `idx` is greater than or - * equal to `self.length()` - */ -export function getEntryByIdx(options: GetEntryByIdxOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'idx']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get_entry_by_idx', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetEntryByIdxMutArguments { - self: RawTransactionArgument; - idx: RawTransactionArgument; -} -export interface GetEntryByIdxMutOptions { - package: string; - arguments: - | GetEntryByIdxMutArguments - | [self: RawTransactionArgument, idx: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Return a mutable reference to the `idx`th entry of `self`. This gives direct - * access into the backing array of the map--use with caution. Note that map - * entries are stored in insertion order, _not_ sorted by key. Aborts if `idx` is - * greater than or equal to `self.length()` - */ -export function getEntryByIdxMut(options: GetEntryByIdxMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'idx']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'get_entry_by_idx_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveEntryByIdxArguments { - self: RawTransactionArgument; - idx: RawTransactionArgument; -} -export interface RemoveEntryByIdxOptions { - package: string; - arguments: - | RemoveEntryByIdxArguments - | [self: RawTransactionArgument, idx: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Remove the entry at index `idx` from self. Aborts if `idx` is greater than or - * equal to `self.length()` - */ -export function removeEntryByIdx(options: RemoveEntryByIdxOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'idx']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'remove_entry_by_idx', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SizeArguments { - self: RawTransactionArgument; -} -export interface SizeOptions { - package: string; - arguments: SizeArguments | [self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** Return the number of entries in `self` */ -export function size(options: SizeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_map', - function: 'size', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts b/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts deleted file mode 100644 index 22a4bf8e2..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/vec_set.ts +++ /dev/null @@ -1,281 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { type BcsType, bcs } from '@mysten/sui/bcs'; -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::vec_set'; -/** - * A set data structure backed by a vector. The set is guaranteed not to contain - * duplicate keys. All operations are O(N) in the size of the set - * - * - the intention of this data structure is only to provide the convenience of - * programming against a set API. Sets that need sorted iteration rather than - * insertion order iteration should be handwritten. - */ -export function VecSet>(...typeParameters: [K]) { - return new MoveStruct({ - name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, - fields: { - contents: bcs.vector(typeParameters[0]), - }, - }); -} -export interface EmptyOptions { - package: string; - arguments?: []; - typeArguments: [string]; -} -/** Create an empty `VecSet` */ -export function empty(options: EmptyOptions) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'empty', - typeArguments: options.typeArguments, - }); -} -export interface SingletonArguments> { - key: RawTransactionArgument; -} -export interface SingletonOptions> { - package: string; - arguments: SingletonArguments | [key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Create a singleton `VecSet` that only contains one element. */ -export function singleton>(options: SingletonOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'singleton', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface InsertArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface InsertOptions> { - package: string; - arguments: - | InsertArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Insert a `key` into self. Aborts if `key` is already present in `self`. */ -export function insert>(options: InsertOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'insert', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface RemoveOptions> { - package: string; - arguments: - | RemoveArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Remove the entry `key` from self. Aborts if `key` is not present in `self`. */ -export function remove>(options: RemoveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'remove', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface ContainsArguments> { - self: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface ContainsOptions> { - package: string; - arguments: - | ContainsArguments - | [self: RawTransactionArgument, key: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return true if `self` contains an entry for `key`, false otherwise */ -export function contains>(options: ContainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['self', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'contains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LengthArguments { - self: RawTransactionArgument; -} -export interface LengthOptions { - package: string; - arguments: LengthArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return the number of entries in `self` */ -export function length(options: LengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsEmptyArguments { - self: RawTransactionArgument; -} -export interface IsEmptyOptions { - package: string; - arguments: IsEmptyArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return true if `self` has 0 elements, false otherwise */ -export function isEmpty(options: IsEmptyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'is_empty', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IntoKeysArguments { - self: RawTransactionArgument; -} -export interface IntoKeysOptions { - package: string; - arguments: IntoKeysArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Unpack `self` into vectors of keys. The output keys are stored in insertion - * order, _not_ sorted. - */ -export function intoKeys(options: IntoKeysOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'into_keys', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FromKeysArguments> { - keys: RawTransactionArgument; -} -export interface FromKeysOptions> { - package: string; - arguments: FromKeysArguments | [keys: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Construct a new `VecSet` from a vector of keys. The keys are stored in insertion - * order (the original `keys` ordering) and are _not_ sorted. - */ -export function fromKeys>(options: FromKeysOptions) { - const packageAddress = options.package; - const argumentsTypes = [`vector<${options.typeArguments[0]}>`] satisfies (string | null)[]; - const parameterNames = ['keys']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'from_keys', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface KeysArguments { - self: RawTransactionArgument; -} -export interface KeysOptions { - package: string; - arguments: KeysArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Borrow the `contents` of the `VecSet` to access content by index without - * unpacking. The contents are stored in insertion order, _not_ sorted. - */ -export function keys(options: KeysOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'keys', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface SizeArguments { - self: RawTransactionArgument; -} -export interface SizeOptions { - package: string; - arguments: SizeArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Return the number of entries in `self` */ -export function size(options: SizeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'vec_set', - function: 'size', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts b/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts deleted file mode 100644 index 9e520c16c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/versioned.ts +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::versioned'; -export const Versioned = new MoveStruct({ - name: `${$moduleName}::Versioned`, - fields: { - id: bcs.Address, - version: bcs.u64(), - }, -}); -export const VersionChangeCap = new MoveStruct({ - name: `${$moduleName}::VersionChangeCap`, - fields: { - versioned_id: bcs.Address, - old_version: bcs.u64(), - }, -}); -export interface CreateArguments> { - initVersion: RawTransactionArgument; - initValue: RawTransactionArgument; -} -export interface CreateOptions> { - package: string; - arguments: - | CreateArguments - | [initVersion: RawTransactionArgument, initValue: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Create a new Versioned object that contains a initial value of type `T` with an - * initial version. - */ -export function create>(options: CreateOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u64', `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['initVersion', 'initValue']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'create', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface VersionArguments { - self: RawTransactionArgument; -} -export interface VersionOptions { - package: string; - arguments: VersionArguments | [self: RawTransactionArgument]; -} -/** Get the current version of the inner type. */ -export function version(options: VersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface LoadValueArguments { - self: RawTransactionArgument; -} -export interface LoadValueOptions { - package: string; - arguments: LoadValueArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Load the inner value based on the current version. Caller specifies an expected - * type T. If the type mismatch, the load will fail. - */ -export function loadValue(options: LoadValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'load_value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface LoadValueMutArguments { - self: RawTransactionArgument; -} -export interface LoadValueMutOptions { - package: string; - arguments: LoadValueMutArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Similar to load_value, but return a mutable reference. */ -export function loadValueMut(options: LoadValueMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'load_value_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveValueForUpgradeArguments { - self: RawTransactionArgument; -} -export interface RemoveValueForUpgradeOptions { - package: string; - arguments: RemoveValueForUpgradeArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Take the inner object out for upgrade. To ensure we always upgrade properly, a - * capability object is returned and must be used when we upgrade. - */ -export function removeValueForUpgrade(options: RemoveValueForUpgradeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'remove_value_for_upgrade', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface UpgradeArguments> { - self: RawTransactionArgument; - newVersion: RawTransactionArgument; - newValue: RawTransactionArgument; - cap: RawTransactionArgument; -} -export interface UpgradeOptions> { - package: string; - arguments: - | UpgradeArguments - | [ - self: RawTransactionArgument, - newVersion: RawTransactionArgument, - newValue: RawTransactionArgument, - cap: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Upgrade the inner object with a new version and new value. Must use the - * capability returned by calling remove_value_for_upgrade. - */ -export function upgrade>(options: UpgradeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64', `${options.typeArguments[0]}`, null] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'newVersion', 'newValue', 'cap']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'upgrade', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DestroyArguments { - self: RawTransactionArgument; -} -export interface DestroyOptions { - package: string; - arguments: DestroyArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Destroy this Versioned container, and return the inner object. */ -export function destroy(options: DestroyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'versioned', - function: 'destroy', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts deleted file mode 100644 index ed625bde0..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_id.ts +++ /dev/null @@ -1,234 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::zklogin_verified_id'; -export const VerifiedID = new MoveStruct({ - name: `${$moduleName}::VerifiedID`, - fields: { - /** The ID of this VerifiedID */ - id: bcs.Address, - /** The address this VerifiedID is associated with */ - owner: bcs.Address, - /** The name of the key claim */ - key_claim_name: bcs.string(), - /** The value of the key claim */ - key_claim_value: bcs.string(), - /** The issuer */ - issuer: bcs.string(), - /** The audience (wallet) */ - audience: bcs.string(), - }, -}); -export interface OwnerArguments { - verifiedId: RawTransactionArgument; -} -export interface OwnerOptions { - package: string; - arguments: OwnerArguments | [verifiedId: RawTransactionArgument]; -} -/** Returns the address associated with the given VerifiedID */ -export function owner(options: OwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface KeyClaimNameArguments { - verifiedId: RawTransactionArgument; -} -export interface KeyClaimNameOptions { - package: string; - arguments: KeyClaimNameArguments | [verifiedId: RawTransactionArgument]; -} -/** Returns the name of the key claim associated with the given VerifiedID */ -export function keyClaimName(options: KeyClaimNameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'key_claim_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface KeyClaimValueArguments { - verifiedId: RawTransactionArgument; -} -export interface KeyClaimValueOptions { - package: string; - arguments: KeyClaimValueArguments | [verifiedId: RawTransactionArgument]; -} -/** Returns the value of the key claim associated with the given VerifiedID */ -export function keyClaimValue(options: KeyClaimValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'key_claim_value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IssuerArguments { - verifiedId: RawTransactionArgument; -} -export interface IssuerOptions { - package: string; - arguments: IssuerArguments | [verifiedId: RawTransactionArgument]; -} -/** Returns the issuer associated with the given VerifiedID */ -export function issuer(options: IssuerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'issuer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AudienceArguments { - verifiedId: RawTransactionArgument; -} -export interface AudienceOptions { - package: string; - arguments: AudienceArguments | [verifiedId: RawTransactionArgument]; -} -/** Returns the audience (wallet) associated with the given VerifiedID */ -export function audience(options: AudienceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'audience', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DeleteArguments { - verifiedId: RawTransactionArgument; -} -export interface DeleteOptions { - package: string; - arguments: DeleteArguments | [verifiedId: RawTransactionArgument]; -} -/** Delete a VerifiedID */ -export function _delete(options: DeleteOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'delete', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VerifyZkloginIdArguments { - KeyClaimName: RawTransactionArgument; - KeyClaimValue: RawTransactionArgument; - Issuer: RawTransactionArgument; - Audience: RawTransactionArgument; - PinHash: RawTransactionArgument; -} -export interface VerifyZkloginIdOptions { - package: string; - arguments: - | VerifyZkloginIdArguments - | [ - KeyClaimName: RawTransactionArgument, - KeyClaimValue: RawTransactionArgument, - Issuer: RawTransactionArgument, - Audience: RawTransactionArgument, - PinHash: RawTransactionArgument, - ]; -} -/** This function has been disabled. */ -export function verifyZkloginId(options: VerifyZkloginIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - 'u256', - ] satisfies (string | null)[]; - const parameterNames = ['KeyClaimName', 'KeyClaimValue', 'Issuer', 'Audience', 'PinHash']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'verify_zklogin_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CheckZkloginIdArguments { - Address: RawTransactionArgument; - KeyClaimName: RawTransactionArgument; - KeyClaimValue: RawTransactionArgument; - Issuer: RawTransactionArgument; - Audience: RawTransactionArgument; - PinHash: RawTransactionArgument; -} -export interface CheckZkloginIdOptions { - package: string; - arguments: - | CheckZkloginIdArguments - | [ - Address: RawTransactionArgument, - KeyClaimName: RawTransactionArgument, - KeyClaimValue: RawTransactionArgument, - Issuer: RawTransactionArgument, - Audience: RawTransactionArgument, - PinHash: RawTransactionArgument, - ]; -} -/** This function has been disabled. */ -export function checkZkloginId(options: CheckZkloginIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - 'address', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - '0x1::string::String', - 'u256', - ] satisfies (string | null)[]; - const parameterNames = [ - 'Address', - 'KeyClaimName', - 'KeyClaimValue', - 'Issuer', - 'Audience', - 'PinHash', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_id', - function: 'check_zklogin_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts b/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts deleted file mode 100644 index 12b8bd4de..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui/zklogin_verified_issuer.ts +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x2::zklogin_verified_issuer'; -export const VerifiedIssuer = new MoveStruct({ - name: `${$moduleName}::VerifiedIssuer`, - fields: { - /** The ID of this VerifiedIssuer */ - id: bcs.Address, - /** The address this VerifiedID is associated with */ - owner: bcs.Address, - /** The issuer */ - issuer: bcs.string(), - }, -}); -export interface OwnerArguments { - verifiedIssuer: RawTransactionArgument; -} -export interface OwnerOptions { - package: string; - arguments: OwnerArguments | [verifiedIssuer: RawTransactionArgument]; -} -/** Returns the address associated with the given VerifiedIssuer */ -export function owner(options: OwnerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedIssuer']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_issuer', - function: 'owner', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IssuerArguments { - verifiedIssuer: RawTransactionArgument; -} -export interface IssuerOptions { - package: string; - arguments: IssuerArguments | [verifiedIssuer: RawTransactionArgument]; -} -/** Returns the issuer associated with the given VerifiedIssuer */ -export function issuer(options: IssuerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedIssuer']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_issuer', - function: 'issuer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DeleteArguments { - verifiedIssuer: RawTransactionArgument; -} -export interface DeleteOptions { - package: string; - arguments: DeleteArguments | [verifiedIssuer: RawTransactionArgument]; -} -/** Delete a VerifiedIssuer */ -export function _delete(options: DeleteOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['verifiedIssuer']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_issuer', - function: 'delete', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VerifyZkloginIssuerArguments { - addressSeed: RawTransactionArgument; - issuer: RawTransactionArgument; -} -export interface VerifyZkloginIssuerOptions { - package: string; - arguments: - | VerifyZkloginIssuerArguments - | [ - addressSeed: RawTransactionArgument, - issuer: RawTransactionArgument, - ]; -} -/** - * Verify that the caller's address was created using zklogin with the given - * issuer. If so, a VerifiedIssuer object with the issuers id transferred to the - * caller. - * - * Aborts with `EInvalidProof` if the verification fails. - */ -export function verifyZkloginIssuer(options: VerifyZkloginIssuerOptions) { - const packageAddress = options.package; - const argumentsTypes = ['u256', '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['addressSeed', 'issuer']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_issuer', - function: 'verify_zklogin_issuer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CheckZkloginIssuerArguments { - address: RawTransactionArgument; - addressSeed: RawTransactionArgument; - issuer: RawTransactionArgument; -} -export interface CheckZkloginIssuerOptions { - package: string; - arguments: - | CheckZkloginIssuerArguments - | [ - address: RawTransactionArgument, - addressSeed: RawTransactionArgument, - issuer: RawTransactionArgument, - ]; -} -/** - * Returns true if `address` was created using zklogin with the given issuer and - * address seed. - */ -export function checkZkloginIssuer(options: CheckZkloginIssuerOptions) { - const packageAddress = options.package; - const argumentsTypes = ['address', 'u256', '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['address', 'addressSeed', 'issuer']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'zklogin_verified_issuer', - function: 'check_zklogin_issuer', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts deleted file mode 100644 index ae3a6919b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/genesis.ts +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = '0x3::genesis'; -export const GenesisValidatorMetadata = new MoveStruct({ - name: `${$moduleName}::GenesisValidatorMetadata`, - fields: { - name: bcs.vector(bcs.u8()), - description: bcs.vector(bcs.u8()), - image_url: bcs.vector(bcs.u8()), - project_url: bcs.vector(bcs.u8()), - sui_address: bcs.Address, - gas_price: bcs.u64(), - commission_rate: bcs.u64(), - protocol_public_key: bcs.vector(bcs.u8()), - proof_of_possession: bcs.vector(bcs.u8()), - network_public_key: bcs.vector(bcs.u8()), - worker_public_key: bcs.vector(bcs.u8()), - network_address: bcs.vector(bcs.u8()), - p2p_address: bcs.vector(bcs.u8()), - primary_address: bcs.vector(bcs.u8()), - worker_address: bcs.vector(bcs.u8()), - }, -}); -export const GenesisChainParameters = new MoveStruct({ - name: `${$moduleName}::GenesisChainParameters`, - fields: { - protocol_version: bcs.u64(), - chain_start_timestamp_ms: bcs.u64(), - epoch_duration_ms: bcs.u64(), - /** Stake Subsidy parameters */ - stake_subsidy_start_epoch: bcs.u64(), - stake_subsidy_initial_distribution_amount: bcs.u64(), - stake_subsidy_period_length: bcs.u64(), - stake_subsidy_decrease_rate: bcs.u16(), - /** Validator committee parameters */ - max_validator_count: bcs.u64(), - min_validator_joining_stake: bcs.u64(), - validator_low_stake_threshold: bcs.u64(), - validator_very_low_stake_threshold: bcs.u64(), - validator_low_stake_grace_period: bcs.u64(), - }, -}); -export const TokenAllocation = new MoveStruct({ - name: `${$moduleName}::TokenAllocation`, - fields: { - recipient_address: bcs.Address, - amount_mist: bcs.u64(), - /** - * Indicates if this allocation should be staked at genesis and with which - * validator - */ - staked_with_validator: bcs.option(bcs.Address), - }, -}); -export const TokenDistributionSchedule = new MoveStruct({ - name: `${$moduleName}::TokenDistributionSchedule`, - fields: { - stake_subsidy_fund_mist: bcs.u64(), - allocations: bcs.vector(TokenAllocation), - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts deleted file mode 100644 index 2b0607035..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/stake_subsidy.ts +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from '../sui/balance.js'; -import * as bag from '../sui/bag.js'; -const $moduleName = '0x3::stake_subsidy'; -export const StakeSubsidy = new MoveStruct({ - name: `${$moduleName}::StakeSubsidy`, - fields: { - /** Balance of SUI set aside for stake subsidies that will be drawn down over time. */ - balance: balance.Balance, - /** Count of the number of times stake subsidies have been distributed. */ - distribution_counter: bcs.u64(), - /** - * The amount of stake subsidy to be drawn down per distribution. This amount - * decays and decreases over time. - */ - current_distribution_amount: bcs.u64(), - /** Number of distributions to occur before the distribution amount decays. */ - stake_subsidy_period_length: bcs.u64(), - /** - * The rate at which the distribution amount decays at the end of each period. - * Expressed in basis points. - */ - stake_subsidy_decrease_rate: bcs.u16(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export interface CurrentEpochSubsidyAmountArguments { - self: RawTransactionArgument; -} -export interface CurrentEpochSubsidyAmountOptions { - package: string; - arguments: CurrentEpochSubsidyAmountArguments | [self: RawTransactionArgument]; -} -/** Returns the amount of stake subsidy to be added at the end of the current epoch. */ -export function currentEpochSubsidyAmount(options: CurrentEpochSubsidyAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'stake_subsidy', - function: 'current_epoch_subsidy_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts deleted file mode 100644 index 46b2061fa..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/staking_pool.ts +++ /dev/null @@ -1,521 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from '../sui/balance.js'; -import * as table from '../sui/table.js'; -import * as bag from '../sui/bag.js'; -const $moduleName = '0x3::staking_pool'; -export const StakingPool = new MoveStruct({ - name: `${$moduleName}::StakingPool`, - fields: { - id: bcs.Address, - /** - * The epoch at which this pool became active. The value is `None` if the pool is - * pre-active and `Some()` if active or inactive. - */ - activation_epoch: bcs.option(bcs.u64()), - /** - * The epoch at which this staking pool ceased to be active. `None` = {pre-active, - * active}, `Some()` if in-active, and it was de-activated at epoch - * ``. - */ - deactivation_epoch: bcs.option(bcs.u64()), - /** - * The total number of SUI tokens in this pool, including the SUI in the - * rewards_pool, as well as in all the principal in the `StakedSui` object, updated - * at epoch boundaries. - */ - sui_balance: bcs.u64(), - /** The epoch stake rewards will be added here at the end of each epoch. */ - rewards_pool: balance.Balance, - /** Total number of pool tokens issued by the pool. */ - pool_token_balance: bcs.u64(), - /** - * Exchange rate history of previous epochs. Key is the epoch number. The entries - * start from the `activation_epoch` of this pool and contains exchange rates at - * the beginning of each epoch, i.e., right after the rewards for the previous - * epoch have been deposited into the pool. - */ - exchange_rates: table.Table, - /** Pending stake amount for this epoch, emptied at epoch boundaries. */ - pending_stake: bcs.u64(), - /** - * Pending stake withdrawn during the current epoch, emptied at epoch boundaries. - * This includes both the principal and rewards SUI withdrawn. - */ - pending_total_sui_withdraw: bcs.u64(), - /** - * Pending pool token withdrawn during the current epoch, emptied at epoch - * boundaries. - */ - pending_pool_token_withdraw: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const PoolTokenExchangeRate = new MoveStruct({ - name: `${$moduleName}::PoolTokenExchangeRate`, - fields: { - sui_amount: bcs.u64(), - pool_token_amount: bcs.u64(), - }, -}); -export const StakedSui = new MoveStruct({ - name: `${$moduleName}::StakedSui`, - fields: { - id: bcs.Address, - /** ID of the staking pool we are staking with. */ - pool_id: bcs.Address, - /** The epoch at which the stake becomes active. */ - stake_activation_epoch: bcs.u64(), - /** The staked SUI tokens. */ - principal: balance.Balance, - }, -}); -export const FungibleStakedSui = new MoveStruct({ - name: `${$moduleName}::FungibleStakedSui`, - fields: { - id: bcs.Address, - /** ID of the staking pool we are staking with. */ - pool_id: bcs.Address, - /** The pool token amount. */ - value: bcs.u64(), - }, -}); -export const FungibleStakedSuiData = new MoveStruct({ - name: `${$moduleName}::FungibleStakedSuiData`, - fields: { - id: bcs.Address, - /** fungible_staked_sui supply */ - total_supply: bcs.u64(), - /** principal balance. Rewards are withdrawn from the reward pool */ - principal: balance.Balance, - }, -}); -export const FungibleStakedSuiDataKey = new MoveStruct({ - name: `${$moduleName}::FungibleStakedSuiDataKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const UnderflowSuiBalance = new MoveStruct({ - name: `${$moduleName}::UnderflowSuiBalance`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface SuiBalanceArguments { - pool: RawTransactionArgument; -} -export interface SuiBalanceOptions { - package: string; - arguments: SuiBalanceArguments | [pool: RawTransactionArgument]; -} -export function suiBalance(options: SuiBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pool']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'sui_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PoolIdArguments { - stakedSui: RawTransactionArgument; -} -export interface PoolIdOptions { - package: string; - arguments: PoolIdArguments | [stakedSui: RawTransactionArgument]; -} -export function poolId(options: PoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FungibleStakedSuiPoolIdArguments { - fungibleStakedSui: RawTransactionArgument; -} -export interface FungibleStakedSuiPoolIdOptions { - package: string; - arguments: FungibleStakedSuiPoolIdArguments | [fungibleStakedSui: RawTransactionArgument]; -} -export function fungibleStakedSuiPoolId(options: FungibleStakedSuiPoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['fungibleStakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'fungible_staked_sui_pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface StakedSuiAmountArguments { - stakedSui: RawTransactionArgument; -} -export interface StakedSuiAmountOptions { - package: string; - arguments: StakedSuiAmountArguments | [stakedSui: RawTransactionArgument]; -} -/** Returns the principal amount of `StakedSui`. */ -export function stakedSuiAmount(options: StakedSuiAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'staked_sui_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface StakeActivationEpochArguments { - stakedSui: RawTransactionArgument; -} -export interface StakeActivationEpochOptions { - package: string; - arguments: StakeActivationEpochArguments | [stakedSui: RawTransactionArgument]; -} -/** Returns the activation epoch of `StakedSui`. */ -export function stakeActivationEpoch(options: StakeActivationEpochOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'stake_activation_epoch', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsPreactiveArguments { - pool: RawTransactionArgument; -} -export interface IsPreactiveOptions { - package: string; - arguments: IsPreactiveArguments | [pool: RawTransactionArgument]; -} -/** Returns true if the input staking pool is preactive. */ -export function isPreactive(options: IsPreactiveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pool']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'is_preactive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsInactiveArguments { - pool: RawTransactionArgument; -} -export interface IsInactiveOptions { - package: string; - arguments: IsInactiveArguments | [pool: RawTransactionArgument]; -} -/** Returns true if the input staking pool is inactive. */ -export function isInactive(options: IsInactiveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['pool']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'is_inactive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FungibleStakedSuiValueArguments { - fungibleStakedSui: RawTransactionArgument; -} -export interface FungibleStakedSuiValueOptions { - package: string; - arguments: FungibleStakedSuiValueArguments | [fungibleStakedSui: RawTransactionArgument]; -} -export function fungibleStakedSuiValue(options: FungibleStakedSuiValueOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['fungibleStakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'fungible_staked_sui_value', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SplitFungibleStakedSuiArguments { - fungibleStakedSui: RawTransactionArgument; - splitAmount: RawTransactionArgument; -} -export interface SplitFungibleStakedSuiOptions { - package: string; - arguments: - | SplitFungibleStakedSuiArguments - | [ - fungibleStakedSui: RawTransactionArgument, - splitAmount: RawTransactionArgument, - ]; -} -export function splitFungibleStakedSui(options: SplitFungibleStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['fungibleStakedSui', 'splitAmount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'split_fungible_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface JoinFungibleStakedSuiArguments { - self: RawTransactionArgument; - other: RawTransactionArgument; -} -export interface JoinFungibleStakedSuiOptions { - package: string; - arguments: - | JoinFungibleStakedSuiArguments - | [self: RawTransactionArgument, other: RawTransactionArgument]; -} -export function joinFungibleStakedSui(options: JoinFungibleStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'other']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'join_fungible_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SplitArguments { - self: RawTransactionArgument; - splitAmount: RawTransactionArgument; -} -export interface SplitOptions { - package: string; - arguments: - | SplitArguments - | [self: RawTransactionArgument, splitAmount: RawTransactionArgument]; -} -/** - * Split StakedSui `self` to two parts, one with principal `split_amount`, and the - * remaining principal is left in `self`. All the other parameters of the StakedSui - * like `stake_activation_epoch` or `pool_id` remain the same. - */ -export function split(options: SplitOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'splitAmount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'split', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SplitStakedSuiArguments { - stake: RawTransactionArgument; - splitAmount: RawTransactionArgument; -} -export interface SplitStakedSuiOptions { - package: string; - arguments: - | SplitStakedSuiArguments - | [stake: RawTransactionArgument, splitAmount: RawTransactionArgument]; -} -/** - * Split the given StakedSui to the two parts, one with principal `split_amount`, - * transfer the newly split part to the sender address. - */ -export function splitStakedSui(options: SplitStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['stake', 'splitAmount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'split_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface JoinStakedSuiArguments { - self: RawTransactionArgument; - other: RawTransactionArgument; -} -export interface JoinStakedSuiOptions { - package: string; - arguments: - | JoinStakedSuiArguments - | [self: RawTransactionArgument, other: RawTransactionArgument]; -} -/** - * Consume the staked sui `other` and add its value to `self`. Aborts if some of - * the staking parameters are incompatible (pool id, stake activation epoch, etc.) - */ -export function joinStakedSui(options: JoinStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'other']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'join_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsEqualStakingMetadataArguments { - self: RawTransactionArgument; - other: RawTransactionArgument; -} -export interface IsEqualStakingMetadataOptions { - package: string; - arguments: - | IsEqualStakingMetadataArguments - | [self: RawTransactionArgument, other: RawTransactionArgument]; -} -/** - * Returns true if all the staking parameters of the staked sui except the - * principal are identical - */ -export function isEqualStakingMetadata(options: IsEqualStakingMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'other']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'is_equal_staking_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PoolTokenExchangeRateAtEpochArguments { - pool: RawTransactionArgument; - epoch: RawTransactionArgument; -} -export interface PoolTokenExchangeRateAtEpochOptions { - package: string; - arguments: - | PoolTokenExchangeRateAtEpochArguments - | [pool: RawTransactionArgument, epoch: RawTransactionArgument]; -} -export function poolTokenExchangeRateAtEpoch(options: PoolTokenExchangeRateAtEpochOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['pool', 'epoch']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'pool_token_exchange_rate_at_epoch', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PendingStakeAmountArguments { - stakingPool: RawTransactionArgument; -} -export interface PendingStakeAmountOptions { - package: string; - arguments: PendingStakeAmountArguments | [stakingPool: RawTransactionArgument]; -} -/** Returns the total value of the pending staking requests for this staking pool. */ -export function pendingStakeAmount(options: PendingStakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['stakingPool']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'pending_stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PendingStakeWithdrawAmountArguments { - stakingPool: RawTransactionArgument; -} -export interface PendingStakeWithdrawAmountOptions { - package: string; - arguments: PendingStakeWithdrawAmountArguments | [stakingPool: RawTransactionArgument]; -} -/** Returns the total withdrawal from the staking pool this epoch. */ -export function pendingStakeWithdrawAmount(options: PendingStakeWithdrawAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['stakingPool']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'pending_stake_withdraw_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SuiAmountArguments { - exchangeRate: RawTransactionArgument; -} -export interface SuiAmountOptions { - package: string; - arguments: SuiAmountArguments | [exchangeRate: RawTransactionArgument]; -} -export function suiAmount(options: SuiAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['exchangeRate']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'sui_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PoolTokenAmountArguments { - exchangeRate: RawTransactionArgument; -} -export interface PoolTokenAmountOptions { - package: string; - arguments: PoolTokenAmountArguments | [exchangeRate: RawTransactionArgument]; -} -export function poolTokenAmount(options: PoolTokenAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['exchangeRate']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'staking_pool', - function: 'pool_token_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts deleted file mode 100644 index 27ddf932c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/storage_fund.ts +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from '../sui/balance.js'; -const $moduleName = '0x3::storage_fund'; -export const StorageFund = new MoveStruct({ - name: `${$moduleName}::StorageFund`, - fields: { - total_object_storage_rebates: balance.Balance, - non_refundable_balance: balance.Balance, - }, -}); -export interface TotalObjectStorageRebatesArguments { - self: RawTransactionArgument; -} -export interface TotalObjectStorageRebatesOptions { - package: string; - arguments: TotalObjectStorageRebatesArguments | [self: RawTransactionArgument]; -} -export function totalObjectStorageRebates(options: TotalObjectStorageRebatesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'storage_fund', - function: 'total_object_storage_rebates', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TotalBalanceArguments { - self: RawTransactionArgument; -} -export interface TotalBalanceOptions { - package: string; - arguments: TotalBalanceArguments | [self: RawTransactionArgument]; -} -export function totalBalance(options: TotalBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'storage_fund', - function: 'total_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts deleted file mode 100644 index 53208b44f..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system.ts +++ /dev/null @@ -1,1204 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Sui System State Type Upgrade Guide `SuiSystemState` is a thin wrapper around - * `SuiSystemStateInner` that provides a versioned interface. The `SuiSystemState` - * object has a fixed ID 0x5, and the `SuiSystemStateInner` object is stored as a - * dynamic field. There are a few different ways to upgrade the - * `SuiSystemStateInner` type: - * - * The simplest and one that doesn't involve a real upgrade is to just add dynamic - * fields to the `extra_fields` field of `SuiSystemStateInner` or any of its sub - * type. This is useful when we are in a rush, or making a small change, or still - * experimenting a new field. - * - * To properly upgrade the `SuiSystemStateInner` type, we need to ship a new - * framework that does the following: - * - * 1. Define a new `SuiSystemStateInner`type (e.g. `SuiSystemStateInnerV2`). - * 2. Define a data migration function that migrates the old `SuiSystemStateInner` - * to the new one (i.e. SuiSystemStateInnerV2). - * 3. Replace all uses of `SuiSystemStateInner` with `SuiSystemStateInnerV2` in - * both sui_system.move and sui_system_state_inner.move, with the exception of - * the `sui_system_state_inner::create` function, which should always return - * the genesis type. - * 4. Inside `load_inner_maybe_upgrade` function, check the current version in the - * wrapper, and if it's not the latest version, call the data migration - * function to upgrade the inner object. Make sure to also update the version - * in the wrapper. A detailed example can be found in - * sui/tests/framework_upgrades/mock_sui_systems/shallow_upgrade. Along with - * the Move change, we also need to update the Rust code to support the new - * type. This includes: - * 5. Define a new `SuiSystemStateInner` struct type that matches the new Move - * type, and implement the SuiSystemStateTrait. - * 6. Update the `SuiSystemState` struct to include the new version as a new enum - * variant. - * 7. Update the `get_sui_system_state` function to handle the new version. To - * test that the upgrade will be successful, we need to modify - * `sui_system_state_production_upgrade_test` test in protocol_version_tests - * and trigger a real upgrade using the new framework. We will need to keep - * this directory as old version, put the new framework in a new directory, and - * run the test to exercise the upgrade. - * - * To upgrade Validator type, besides everything above, we also need to: - * - * 1. Define a new Validator type (e.g. ValidatorV2). - * 2. Define a data migration function that migrates the old Validator to the new - * one (i.e. ValidatorV2). - * 3. Replace all uses of Validator with ValidatorV2 except the genesis creation - * function. - * 4. In validator_wrapper::upgrade_to_latest, check the current version in the - * wrapper, and if it's not the latest version, call the data migration - * function to upgrade it. In Rust, we also need to add a new case in - * `get_validator_from_table`. Note that it is possible to upgrade - * SuiSystemStateInner without upgrading Validator, but not the other way - * around. And when we only upgrade SuiSystemStateInner, the version of - * Validator in the wrapper will not be updated, and hence may become - * inconsistent with the version of SuiSystemStateInner. This is fine as long - * as we don't use the Validator version to determine the SuiSystemStateInner - * version, or vice versa. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x3::sui_system'; -export const SuiSystemState = new MoveStruct({ - name: `${$moduleName}::SuiSystemState`, - fields: { - id: bcs.Address, - version: bcs.u64(), - }, -}); -export interface RequestAddValidatorCandidateArguments { - pubkeyBytes: RawTransactionArgument; - networkPubkeyBytes: RawTransactionArgument; - workerPubkeyBytes: RawTransactionArgument; - proofOfPossession: RawTransactionArgument; - name: RawTransactionArgument; - description: RawTransactionArgument; - imageUrl: RawTransactionArgument; - projectUrl: RawTransactionArgument; - netAddress: RawTransactionArgument; - p2pAddress: RawTransactionArgument; - primaryAddress: RawTransactionArgument; - workerAddress: RawTransactionArgument; - gasPrice: RawTransactionArgument; - commissionRate: RawTransactionArgument; -} -export interface RequestAddValidatorCandidateOptions { - package: string; - arguments: - | RequestAddValidatorCandidateArguments - | [ - pubkeyBytes: RawTransactionArgument, - networkPubkeyBytes: RawTransactionArgument, - workerPubkeyBytes: RawTransactionArgument, - proofOfPossession: RawTransactionArgument, - name: RawTransactionArgument, - description: RawTransactionArgument, - imageUrl: RawTransactionArgument, - projectUrl: RawTransactionArgument, - netAddress: RawTransactionArgument, - p2pAddress: RawTransactionArgument, - primaryAddress: RawTransactionArgument, - workerAddress: RawTransactionArgument, - gasPrice: RawTransactionArgument, - commissionRate: RawTransactionArgument, - ]; -} -/** - * Can be called by anyone who wishes to become a validator candidate and starts - * accruing delegated stakes in their staking pool. Once they have at least - * `MIN_VALIDATOR_JOINING_STAKE` amount of stake they can call - * `request_add_validator` to officially become an active validator at the next - * epoch. Aborts if the caller is already a pending or active validator, or a - * validator candidate. Note: `proof_of_possession` MUST be a valid signature using - * sui_address and protocol_pubkey_bytes. To produce a valid PoP, run [fn - * test_proof_of_possession]. - */ -export function requestAddValidatorCandidate(options: RequestAddValidatorCandidateOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x3::sui_system::SuiSystemState', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'vector', - 'u64', - 'u64', - ] satisfies (string | null)[]; - const parameterNames = [ - 'pubkeyBytes', - 'networkPubkeyBytes', - 'workerPubkeyBytes', - 'proofOfPossession', - 'name', - 'description', - 'imageUrl', - 'projectUrl', - 'netAddress', - 'p2pAddress', - 'primaryAddress', - 'workerAddress', - 'gasPrice', - 'commissionRate', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_add_validator_candidate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestRemoveValidatorCandidateArguments {} -export interface RequestRemoveValidatorCandidateOptions { - package: string; - arguments?: RequestRemoveValidatorCandidateArguments | []; -} -/** - * Called by a validator candidate to remove themselves from the candidacy. After - * this call their staking pool becomes deactivate. - */ -export function requestRemoveValidatorCandidate( - options: RequestRemoveValidatorCandidateOptions = {}, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_remove_validator_candidate', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface RequestAddValidatorArguments {} -export interface RequestAddValidatorOptions { - package: string; - arguments?: RequestAddValidatorArguments | []; -} -/** - * Called by a validator candidate to add themselves to the active validator set - * beginning next epoch. Aborts if the validator is a duplicate with one of the - * pending or active validators, or if the amount of stake the validator has - * doesn't meet the min threshold, or if the number of new validators for the next - * epoch has already reached the maximum. - */ -export function requestAddValidator(options: RequestAddValidatorOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_add_validator', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface RequestRemoveValidatorArguments {} -export interface RequestRemoveValidatorOptions { - package: string; - arguments?: RequestRemoveValidatorArguments | []; -} -/** - * A validator can call this function to request a removal in the next epoch. We - * use the sender of `ctx` to look up the validator (i.e. sender must match the - * sui_address in the validator). At the end of the epoch, the `validator` object - * will be returned to the sui_address of the validator. - */ -export function requestRemoveValidator(options: RequestRemoveValidatorOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_remove_validator', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface RequestSetGasPriceArguments { - cap: RawTransactionArgument; - newGasPrice: RawTransactionArgument; -} -export interface RequestSetGasPriceOptions { - package: string; - arguments: - | RequestSetGasPriceArguments - | [cap: RawTransactionArgument, newGasPrice: RawTransactionArgument]; -} -/** - * A validator can call this entry function to submit a new gas price quote, to be - * used for the reference gas price calculation at the end of the epoch. - */ -export function requestSetGasPrice(options: RequestSetGasPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'u64'] satisfies ( - | string - | null - )[]; - const parameterNames = ['cap', 'newGasPrice']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_set_gas_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetCandidateValidatorGasPriceArguments { - cap: RawTransactionArgument; - newGasPrice: RawTransactionArgument; -} -export interface SetCandidateValidatorGasPriceOptions { - package: string; - arguments: - | SetCandidateValidatorGasPriceArguments - | [cap: RawTransactionArgument, newGasPrice: RawTransactionArgument]; -} -/** This entry function is used to set new gas price for candidate validators */ -export function setCandidateValidatorGasPrice(options: SetCandidateValidatorGasPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'u64'] satisfies ( - | string - | null - )[]; - const parameterNames = ['cap', 'newGasPrice']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'set_candidate_validator_gas_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestSetCommissionRateArguments { - newCommissionRate: RawTransactionArgument; -} -export interface RequestSetCommissionRateOptions { - package: string; - arguments: - | RequestSetCommissionRateArguments - | [newCommissionRate: RawTransactionArgument]; -} -/** - * A validator can call this entry function to set a new commission rate, updated - * at the end of the epoch. - */ -export function requestSetCommissionRate(options: RequestSetCommissionRateOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'u64'] satisfies (string | null)[]; - const parameterNames = ['newCommissionRate']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_set_commission_rate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetCandidateValidatorCommissionRateArguments { - newCommissionRate: RawTransactionArgument; -} -export interface SetCandidateValidatorCommissionRateOptions { - package: string; - arguments: - | SetCandidateValidatorCommissionRateArguments - | [newCommissionRate: RawTransactionArgument]; -} -/** This entry function is used to set new commission rate for candidate validators */ -export function setCandidateValidatorCommissionRate( - options: SetCandidateValidatorCommissionRateOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'u64'] satisfies (string | null)[]; - const parameterNames = ['newCommissionRate']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'set_candidate_validator_commission_rate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestAddStakeArguments { - stake: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface RequestAddStakeOptions { - package: string; - arguments: - | RequestAddStakeArguments - | [stake: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -/** Add stake to a validator's staking pool. */ -export function requestAddStake(options: RequestAddStakeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( - | string - | null - )[]; - const parameterNames = ['stake', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_add_stake', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestAddStakeNonEntryArguments { - stake: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface RequestAddStakeNonEntryOptions { - package: string; - arguments: - | RequestAddStakeNonEntryArguments - | [stake: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -/** - * The non-entry version of `request_add_stake`, which returns the staked SUI - * instead of transferring it to the sender. - */ -export function requestAddStakeNonEntry(options: RequestAddStakeNonEntryOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( - | string - | null - )[]; - const parameterNames = ['stake', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_add_stake_non_entry', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestAddStakeMulCoinArguments { - stakes: RawTransactionArgument; - stakeAmount: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface RequestAddStakeMulCoinOptions { - package: string; - arguments: - | RequestAddStakeMulCoinArguments - | [ - stakes: RawTransactionArgument, - stakeAmount: RawTransactionArgument, - validatorAddress: RawTransactionArgument, - ]; -} -/** Add stake to a validator's staking pool using multiple coins. */ -export function requestAddStakeMulCoin(options: RequestAddStakeMulCoinOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - '0x3::sui_system::SuiSystemState', - 'vector', - '0x1::option::Option', - 'address', - ] satisfies (string | null)[]; - const parameterNames = ['stakes', 'stakeAmount', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_add_stake_mul_coin', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestWithdrawStakeArguments { - stakedSui: RawTransactionArgument; -} -export interface RequestWithdrawStakeOptions { - package: string; - arguments: RequestWithdrawStakeArguments | [stakedSui: RawTransactionArgument]; -} -/** Withdraw stake from a validator's staking pool. */ -export function requestWithdrawStake(options: RequestWithdrawStakeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_withdraw_stake', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ConvertToFungibleStakedSuiArguments { - stakedSui: RawTransactionArgument; -} -export interface ConvertToFungibleStakedSuiOptions { - package: string; - arguments: ConvertToFungibleStakedSuiArguments | [stakedSui: RawTransactionArgument]; -} -/** Convert StakedSui into a FungibleStakedSui object. */ -export function convertToFungibleStakedSui(options: ConvertToFungibleStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'convert_to_fungible_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RedeemFungibleStakedSuiArguments { - fungibleStakedSui: RawTransactionArgument; -} -export interface RedeemFungibleStakedSuiOptions { - package: string; - arguments: RedeemFungibleStakedSuiArguments | [fungibleStakedSui: RawTransactionArgument]; -} -/** Convert FungibleStakedSui into a StakedSui object. */ -export function redeemFungibleStakedSui(options: RedeemFungibleStakedSuiOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; - const parameterNames = ['fungibleStakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'redeem_fungible_staked_sui', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestWithdrawStakeNonEntryArguments { - stakedSui: RawTransactionArgument; -} -export interface RequestWithdrawStakeNonEntryOptions { - package: string; - arguments: RequestWithdrawStakeNonEntryArguments | [stakedSui: RawTransactionArgument]; -} -/** - * Non-entry version of `request_withdraw_stake` that returns the withdrawn SUI - * instead of transferring it to the sender. - */ -export function requestWithdrawStakeNonEntry(options: RequestWithdrawStakeNonEntryOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null] satisfies (string | null)[]; - const parameterNames = ['stakedSui']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'request_withdraw_stake_non_entry', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReportValidatorArguments { - cap: RawTransactionArgument; - reporteeAddr: RawTransactionArgument; -} -export interface ReportValidatorOptions { - package: string; - arguments: - | ReportValidatorArguments - | [cap: RawTransactionArgument, reporteeAddr: RawTransactionArgument]; -} -/** - * Report a validator as a bad or non-performant actor in the system. Succeeds if - * all the following are satisfied: - * - * 1. both the reporter in `cap` and the input `reportee_addr` are active - * validators. - * 2. reporter and reportee not the same address. - * 3. the cap object is still valid. This function is idempotent. - */ -export function reportValidator(options: ReportValidatorOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( - | string - | null - )[]; - const parameterNames = ['cap', 'reporteeAddr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'report_validator', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UndoReportValidatorArguments { - cap: RawTransactionArgument; - reporteeAddr: RawTransactionArgument; -} -export interface UndoReportValidatorOptions { - package: string; - arguments: - | UndoReportValidatorArguments - | [cap: RawTransactionArgument, reporteeAddr: RawTransactionArgument]; -} -/** - * Undo a `report_validator` action. Aborts if - * - * 1. the reportee is not a currently active validator or - * 2. the sender has not previously reported the `reportee_addr`, or - * 3. the cap is not valid - */ -export function undoReportValidator(options: UndoReportValidatorOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', null, 'address'] satisfies ( - | string - | null - )[]; - const parameterNames = ['cap', 'reporteeAddr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'undo_report_validator', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RotateOperationCapArguments {} -export interface RotateOperationCapOptions { - package: string; - arguments?: RotateOperationCapArguments | []; -} -/** - * Create a new `UnverifiedValidatorOperationCap`, transfer it to the validator and - * registers it. The original object is thus revoked. - */ -export function rotateOperationCap(options: RotateOperationCapOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'rotate_operation_cap', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNameArguments { - name: RawTransactionArgument; -} -export interface UpdateValidatorNameOptions { - package: string; - arguments: UpdateValidatorNameArguments | [name: RawTransactionArgument]; -} -/** Update a validator's name. */ -export function updateValidatorName(options: UpdateValidatorNameOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorDescriptionArguments { - description: RawTransactionArgument; -} -export interface UpdateValidatorDescriptionOptions { - package: string; - arguments: UpdateValidatorDescriptionArguments | [description: RawTransactionArgument]; -} -/** Update a validator's description */ -export function updateValidatorDescription(options: UpdateValidatorDescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['description']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorImageUrlArguments { - imageUrl: RawTransactionArgument; -} -export interface UpdateValidatorImageUrlOptions { - package: string; - arguments: UpdateValidatorImageUrlArguments | [imageUrl: RawTransactionArgument]; -} -/** Update a validator's image url */ -export function updateValidatorImageUrl(options: UpdateValidatorImageUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['imageUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_image_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorProjectUrlArguments { - projectUrl: RawTransactionArgument; -} -export interface UpdateValidatorProjectUrlOptions { - package: string; - arguments: UpdateValidatorProjectUrlArguments | [projectUrl: RawTransactionArgument]; -} -/** Update a validator's project url */ -export function updateValidatorProjectUrl(options: UpdateValidatorProjectUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['projectUrl']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_project_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochNetworkAddressArguments { - networkAddress: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochNetworkAddressOptions { - package: string; - arguments: - | UpdateValidatorNextEpochNetworkAddressArguments - | [networkAddress: RawTransactionArgument]; -} -/** - * Update a validator's network address. The change will only take effects starting - * from the next epoch. - */ -export function updateValidatorNextEpochNetworkAddress( - options: UpdateValidatorNextEpochNetworkAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['networkAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_network_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorNetworkAddressArguments { - networkAddress: RawTransactionArgument; -} -export interface UpdateCandidateValidatorNetworkAddressOptions { - package: string; - arguments: - | UpdateCandidateValidatorNetworkAddressArguments - | [networkAddress: RawTransactionArgument]; -} -/** Update candidate validator's network address. */ -export function updateCandidateValidatorNetworkAddress( - options: UpdateCandidateValidatorNetworkAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['networkAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_network_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochP2pAddressArguments { - p2pAddress: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochP2pAddressOptions { - package: string; - arguments: - | UpdateValidatorNextEpochP2pAddressArguments - | [p2pAddress: RawTransactionArgument]; -} -/** - * Update a validator's p2p address. The change will only take effects starting - * from the next epoch. - */ -export function updateValidatorNextEpochP2pAddress( - options: UpdateValidatorNextEpochP2pAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['p2pAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_p2p_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorP2pAddressArguments { - p2pAddress: RawTransactionArgument; -} -export interface UpdateCandidateValidatorP2pAddressOptions { - package: string; - arguments: - | UpdateCandidateValidatorP2pAddressArguments - | [p2pAddress: RawTransactionArgument]; -} -/** Update candidate validator's p2p address. */ -export function updateCandidateValidatorP2pAddress( - options: UpdateCandidateValidatorP2pAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['p2pAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_p2p_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochPrimaryAddressArguments { - primaryAddress: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochPrimaryAddressOptions { - package: string; - arguments: - | UpdateValidatorNextEpochPrimaryAddressArguments - | [primaryAddress: RawTransactionArgument]; -} -/** - * Update a validator's narwhal primary address. The change will only take effects - * starting from the next epoch. - */ -export function updateValidatorNextEpochPrimaryAddress( - options: UpdateValidatorNextEpochPrimaryAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['primaryAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_primary_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorPrimaryAddressArguments { - primaryAddress: RawTransactionArgument; -} -export interface UpdateCandidateValidatorPrimaryAddressOptions { - package: string; - arguments: - | UpdateCandidateValidatorPrimaryAddressArguments - | [primaryAddress: RawTransactionArgument]; -} -/** Update candidate validator's narwhal primary address. */ -export function updateCandidateValidatorPrimaryAddress( - options: UpdateCandidateValidatorPrimaryAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['primaryAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_primary_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochWorkerAddressArguments { - workerAddress: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochWorkerAddressOptions { - package: string; - arguments: - | UpdateValidatorNextEpochWorkerAddressArguments - | [workerAddress: RawTransactionArgument]; -} -/** - * Update a validator's narwhal worker address. The change will only take effects - * starting from the next epoch. - */ -export function updateValidatorNextEpochWorkerAddress( - options: UpdateValidatorNextEpochWorkerAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['workerAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_worker_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorWorkerAddressArguments { - workerAddress: RawTransactionArgument; -} -export interface UpdateCandidateValidatorWorkerAddressOptions { - package: string; - arguments: - | UpdateCandidateValidatorWorkerAddressArguments - | [workerAddress: RawTransactionArgument]; -} -/** Update candidate validator's narwhal worker address. */ -export function updateCandidateValidatorWorkerAddress( - options: UpdateCandidateValidatorWorkerAddressOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['workerAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_worker_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochProtocolPubkeyArguments { - protocolPubkey: RawTransactionArgument; - proofOfPossession: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochProtocolPubkeyOptions { - package: string; - arguments: - | UpdateValidatorNextEpochProtocolPubkeyArguments - | [ - protocolPubkey: RawTransactionArgument, - proofOfPossession: RawTransactionArgument, - ]; -} -/** - * Update a validator's public key of protocol key and proof of possession. The - * change will only take effects starting from the next epoch. - */ -export function updateValidatorNextEpochProtocolPubkey( - options: UpdateValidatorNextEpochProtocolPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['protocolPubkey', 'proofOfPossession']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_protocol_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorProtocolPubkeyArguments { - protocolPubkey: RawTransactionArgument; - proofOfPossession: RawTransactionArgument; -} -export interface UpdateCandidateValidatorProtocolPubkeyOptions { - package: string; - arguments: - | UpdateCandidateValidatorProtocolPubkeyArguments - | [ - protocolPubkey: RawTransactionArgument, - proofOfPossession: RawTransactionArgument, - ]; -} -/** Update candidate validator's public key of protocol key and proof of possession. */ -export function updateCandidateValidatorProtocolPubkey( - options: UpdateCandidateValidatorProtocolPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['protocolPubkey', 'proofOfPossession']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_protocol_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochWorkerPubkeyArguments { - workerPubkey: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochWorkerPubkeyOptions { - package: string; - arguments: - | UpdateValidatorNextEpochWorkerPubkeyArguments - | [workerPubkey: RawTransactionArgument]; -} -/** - * Update a validator's public key of worker key. The change will only take effects - * starting from the next epoch. - */ -export function updateValidatorNextEpochWorkerPubkey( - options: UpdateValidatorNextEpochWorkerPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['workerPubkey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_worker_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorWorkerPubkeyArguments { - workerPubkey: RawTransactionArgument; -} -export interface UpdateCandidateValidatorWorkerPubkeyOptions { - package: string; - arguments: - | UpdateCandidateValidatorWorkerPubkeyArguments - | [workerPubkey: RawTransactionArgument]; -} -/** Update candidate validator's public key of worker key. */ -export function updateCandidateValidatorWorkerPubkey( - options: UpdateCandidateValidatorWorkerPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['workerPubkey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_worker_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateValidatorNextEpochNetworkPubkeyArguments { - networkPubkey: RawTransactionArgument; -} -export interface UpdateValidatorNextEpochNetworkPubkeyOptions { - package: string; - arguments: - | UpdateValidatorNextEpochNetworkPubkeyArguments - | [networkPubkey: RawTransactionArgument]; -} -/** - * Update a validator's public key of network key. The change will only take - * effects starting from the next epoch. - */ -export function updateValidatorNextEpochNetworkPubkey( - options: UpdateValidatorNextEpochNetworkPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['networkPubkey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_validator_next_epoch_network_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UpdateCandidateValidatorNetworkPubkeyArguments { - networkPubkey: RawTransactionArgument; -} -export interface UpdateCandidateValidatorNetworkPubkeyOptions { - package: string; - arguments: - | UpdateCandidateValidatorNetworkPubkeyArguments - | [networkPubkey: RawTransactionArgument]; -} -/** Update candidate validator's public key of network key. */ -export function updateCandidateValidatorNetworkPubkey( - options: UpdateCandidateValidatorNetworkPubkeyOptions, -) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', 'vector'] satisfies ( - | string - | null - )[]; - const parameterNames = ['networkPubkey']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'update_candidate_validator_network_pubkey', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorAddressByPoolIdArguments { - poolId: RawTransactionArgument; -} -export interface ValidatorAddressByPoolIdOptions { - package: string; - arguments: ValidatorAddressByPoolIdArguments | [poolId: RawTransactionArgument]; -} -export function validatorAddressByPoolId(options: ValidatorAddressByPoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', '0x2::object::ID'] satisfies ( - | string - | null - )[]; - const parameterNames = ['poolId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'validator_address_by_pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PoolExchangeRatesArguments { - poolId: RawTransactionArgument; -} -export interface PoolExchangeRatesOptions { - package: string; - arguments: PoolExchangeRatesArguments | [poolId: RawTransactionArgument]; -} -/** - * Getter of the pool token exchange rate of a staking pool. Works for both active - * and inactive pools. - */ -export function poolExchangeRates(options: PoolExchangeRatesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState', '0x2::object::ID'] satisfies ( - | string - | null - )[]; - const parameterNames = ['poolId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'pool_exchange_rates', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ActiveValidatorAddressesArguments {} -export interface ActiveValidatorAddressesOptions { - package: string; - arguments?: ActiveValidatorAddressesArguments | []; -} -/** Getter returning addresses of the currently active validators. */ -export function activeValidatorAddresses(options: ActiveValidatorAddressesOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'active_validator_addresses', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface ActiveValidatorAddressesRefArguments {} -export interface ActiveValidatorAddressesRefOptions { - package: string; - arguments?: ActiveValidatorAddressesRefArguments | []; -} -/** Getter returning addresses of the currently active validators by reference. */ -export function activeValidatorAddressesRef(options: ActiveValidatorAddressesRefOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'active_validator_addresses_ref', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} -export interface ActiveValidatorVotingPowersArguments {} -export interface ActiveValidatorVotingPowersOptions { - package: string; - arguments?: ActiveValidatorVotingPowersArguments | []; -} -/** - * Getter returns the voting power of the active validators, values are voting - * power in the scale of 10000. - */ -export function activeValidatorVotingPowers(options: ActiveValidatorVotingPowersOptions = {}) { - const packageAddress = options.package; - const argumentsTypes = ['0x3::sui_system::SuiSystemState'] satisfies (string | null)[]; - const parameterNames = []; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'sui_system', - function: 'active_validator_voting_powers', - arguments: normalizeMoveArguments(options.arguments ?? [], argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts deleted file mode 100644 index f25e42053..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/sui_system_state_inner.ts +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import * as bag from '../sui/bag.js'; -import * as validator_set from './validator_set.js'; -import * as storage_fund from './storage_fund.js'; -import * as vec_map from '../sui/vec_map.js'; -import * as vec_set from '../sui/vec_set.js'; -import * as stake_subsidy from './stake_subsidy.js'; -import * as balance from '../sui/balance.js'; -const $moduleName = '0x3::sui_system_state_inner'; -export const ExecutionTimeObservationChunkKey = new MoveStruct({ - name: `${$moduleName}::ExecutionTimeObservationChunkKey`, - fields: { - chunk_index: bcs.u64(), - }, -}); -export const SystemParameters = new MoveStruct({ - name: `${$moduleName}::SystemParameters`, - fields: { - /** The duration of an epoch, in milliseconds. */ - epoch_duration_ms: bcs.u64(), - /** The starting epoch in which stake subsidies start being paid out */ - stake_subsidy_start_epoch: bcs.u64(), - /** - * Deprecated. Maximum number of active validators at any moment. We do not allow - * the number of validators in any epoch to go above this. - */ - max_validator_count: bcs.u64(), - /** Deprecated. Lower-bound on the amount of stake required to become a validator. */ - min_validator_joining_stake: bcs.u64(), - /** - * Validators with stake amount below `validator_low_stake_threshold` are - * considered to have low stake and will be escorted out of the validator set after - * being below this threshold for more than `validator_low_stake_grace_period` - * number of epochs. - */ - validator_low_stake_threshold: bcs.u64(), - /** - * Deprecated. Validators with stake below `validator_very_low_stake_threshold` - * will be removed immediately at epoch change, no grace period. - */ - validator_very_low_stake_threshold: bcs.u64(), - /** - * A validator can have stake below `validator_low_stake_threshold` for this many - * epochs before being kicked out. - */ - validator_low_stake_grace_period: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const SystemParametersV2 = new MoveStruct({ - name: `${$moduleName}::SystemParametersV2`, - fields: { - /** The duration of an epoch, in milliseconds. */ - epoch_duration_ms: bcs.u64(), - /** The starting epoch in which stake subsidies start being paid out */ - stake_subsidy_start_epoch: bcs.u64(), - /** Minimum number of active validators at any moment. */ - min_validator_count: bcs.u64(), - /** - * Maximum number of active validators at any moment. We do not allow the number of - * validators in any epoch to go above this. - */ - max_validator_count: bcs.u64(), - /** Deprecated. Lower-bound on the amount of stake required to become a validator. */ - min_validator_joining_stake: bcs.u64(), - /** - * Deprecated. Validators with stake amount below `validator_low_stake_threshold` - * are considered to have low stake and will be escorted out of the validator set - * after being below this threshold for more than - * `validator_low_stake_grace_period` number of epochs. - */ - validator_low_stake_threshold: bcs.u64(), - /** - * Deprecated. Validators with stake below `validator_very_low_stake_threshold` - * will be removed immediately at epoch change, no grace period. - */ - validator_very_low_stake_threshold: bcs.u64(), - /** - * A validator can have stake below `validator_low_stake_threshold` for this many - * epochs before being kicked out. - */ - validator_low_stake_grace_period: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const SuiSystemStateInner = new MoveStruct({ - name: `${$moduleName}::SuiSystemStateInner`, - fields: { - /** The current epoch ID, starting from 0. */ - epoch: bcs.u64(), - /** The current protocol version, starting from 1. */ - protocol_version: bcs.u64(), - /** - * The current version of the system state data structure type. This is always the - * same as SuiSystemState.version. Keeping a copy here so that we know what version - * it is by inspecting SuiSystemStateInner as well. - */ - system_state_version: bcs.u64(), - /** Contains all information about the validators. */ - validators: validator_set.ValidatorSet, - /** The storage fund. */ - storage_fund: storage_fund.StorageFund, - /** A list of system config parameters. */ - parameters: SystemParameters, - /** The reference gas price for the current epoch. */ - reference_gas_price: bcs.u64(), - /** - * A map storing the records of validator reporting each other. There is an entry - * in the map for each validator that has been reported at least once. The entry - * VecSet contains all the validators that reported them. If a validator has never - * been reported they don't have an entry in this map. This map persists across - * epoch: a peer continues being in a reported state until the reporter doesn't - * explicitly remove their report. Note that in case we want to support validator - * address change in future, the reports should be based on validator ids - */ - validator_report_records: vec_map.VecMap(bcs.Address, vec_set.VecSet(bcs.Address)), - /** Schedule of stake subsidies given out each epoch. */ - stake_subsidy: stake_subsidy.StakeSubsidy, - /** - * Whether the system is running in a downgraded safe mode due to a non-recoverable - * bug. This is set whenever we failed to execute advance*epoch, and ended up - * executing advance_epoch_safe_mode. It can be reset once we are able to - * successfully execute advance_epoch. The rest of the fields starting with - * `safe_mode*` are accumulated during safe mode when advance_epoch_safe_mode is - * executed. They will eventually be processed once we are out of safe mode. - */ - safe_mode: bcs.bool(), - safe_mode_storage_rewards: balance.Balance, - safe_mode_computation_rewards: balance.Balance, - safe_mode_storage_rebates: bcs.u64(), - safe_mode_non_refundable_storage_fee: bcs.u64(), - /** Unix timestamp of the current epoch start */ - epoch_start_timestamp_ms: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const SuiSystemStateInnerV2 = new MoveStruct({ - name: `${$moduleName}::SuiSystemStateInnerV2`, - fields: { - /** The current epoch ID, starting from 0. */ - epoch: bcs.u64(), - /** The current protocol version, starting from 1. */ - protocol_version: bcs.u64(), - /** - * The current version of the system state data structure type. This is always the - * same as SuiSystemState.version. Keeping a copy here so that we know what version - * it is by inspecting SuiSystemStateInner as well. - */ - system_state_version: bcs.u64(), - /** Contains all information about the validators. */ - validators: validator_set.ValidatorSet, - /** The storage fund. */ - storage_fund: storage_fund.StorageFund, - /** A list of system config parameters. */ - parameters: SystemParametersV2, - /** The reference gas price for the current epoch. */ - reference_gas_price: bcs.u64(), - /** - * A map storing the records of validator reporting each other. There is an entry - * in the map for each validator that has been reported at least once. The entry - * VecSet contains all the validators that reported them. If a validator has never - * been reported they don't have an entry in this map. This map persists across - * epoch: a peer continues being in a reported state until the reporter doesn't - * explicitly remove their report. Note that in case we want to support validator - * address change in future, the reports should be based on validator ids - */ - validator_report_records: vec_map.VecMap(bcs.Address, vec_set.VecSet(bcs.Address)), - /** Schedule of stake subsidies given out each epoch. */ - stake_subsidy: stake_subsidy.StakeSubsidy, - /** - * Whether the system is running in a downgraded safe mode due to a non-recoverable - * bug. This is set whenever we failed to execute advance*epoch, and ended up - * executing advance_epoch_safe_mode. It can be reset once we are able to - * successfully execute advance_epoch. The rest of the fields starting with - * `safe_mode*` are accumulated during safe mode when advance_epoch_safe_mode is - * executed. They will eventually be processed once we are out of safe mode. - */ - safe_mode: bcs.bool(), - safe_mode_storage_rewards: balance.Balance, - safe_mode_computation_rewards: balance.Balance, - safe_mode_storage_rebates: bcs.u64(), - safe_mode_non_refundable_storage_fee: bcs.u64(), - /** Unix timestamp of the current epoch start */ - epoch_start_timestamp_ms: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const SystemEpochInfoEvent = new MoveStruct({ - name: `${$moduleName}::SystemEpochInfoEvent`, - fields: { - epoch: bcs.u64(), - protocol_version: bcs.u64(), - reference_gas_price: bcs.u64(), - total_stake: bcs.u64(), - storage_fund_reinvestment: bcs.u64(), - storage_charge: bcs.u64(), - storage_rebate: bcs.u64(), - storage_fund_balance: bcs.u64(), - stake_subsidy_amount: bcs.u64(), - total_gas_fees: bcs.u64(), - total_stake_rewards_distributed: bcs.u64(), - leftover_storage_fund_inflow: bcs.u64(), - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts deleted file mode 100644 index c63e99ce7..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator.ts +++ /dev/null @@ -1,870 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as url from '../sui/url.js'; -import * as bag from '../sui/bag.js'; -import * as staking_pool from './staking_pool.js'; -const $moduleName = '0x3::validator'; -export const ValidatorMetadata = new MoveStruct({ - name: `${$moduleName}::ValidatorMetadata`, - fields: { - /** - * The Sui Address of the validator. This is the sender that created the Validator - * object, and also the address to send validator/coins to during withdraws. - */ - sui_address: bcs.Address, - /** - * The public key bytes corresponding to the private key that the validator holds - * to sign transactions. For now, this is the same as AuthorityName. - */ - protocol_pubkey_bytes: bcs.vector(bcs.u8()), - /** - * The public key bytes corresponding to the private key that the validator uses to - * establish TLS connections - */ - network_pubkey_bytes: bcs.vector(bcs.u8()), - /** The public key bytes correstponding to the Narwhal Worker */ - worker_pubkey_bytes: bcs.vector(bcs.u8()), - /** This is a proof that the validator has ownership of the private key */ - proof_of_possession: bcs.vector(bcs.u8()), - /** A unique human-readable name of this validator. */ - name: bcs.string(), - description: bcs.string(), - image_url: url.Url, - project_url: url.Url, - /** - * The network address of the validator (could also contain extra info such as - * port, DNS and etc.). - */ - net_address: bcs.string(), - /** - * The address of the validator used for p2p activities such as state sync (could - * also contain extra info such as port, DNS and etc.). - */ - p2p_address: bcs.string(), - /** The address of the narwhal primary */ - primary_address: bcs.string(), - /** The address of the narwhal worker */ - worker_address: bcs.string(), - /** - * "next_epoch" metadata only takes effects in the next epoch. If none, current - * value will stay unchanged. - */ - next_epoch_protocol_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), - next_epoch_proof_of_possession: bcs.option(bcs.vector(bcs.u8())), - next_epoch_network_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), - next_epoch_worker_pubkey_bytes: bcs.option(bcs.vector(bcs.u8())), - next_epoch_net_address: bcs.option(bcs.string()), - next_epoch_p2p_address: bcs.option(bcs.string()), - next_epoch_primary_address: bcs.option(bcs.string()), - next_epoch_worker_address: bcs.option(bcs.string()), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const Validator = new MoveStruct({ - name: `${$moduleName}::Validator`, - fields: { - /** Summary of the validator. */ - metadata: ValidatorMetadata, - /** - * The voting power of this validator, which might be different from its stake - * amount. - */ - voting_power: bcs.u64(), - /** The ID of this validator's current valid `UnverifiedValidatorOperationCap` */ - operation_cap_id: bcs.Address, - /** Gas price quote, updated only at end of epoch. */ - gas_price: bcs.u64(), - /** Staking pool for this validator. */ - staking_pool: staking_pool.StakingPool, - /** Commission rate of the validator, in basis point. */ - commission_rate: bcs.u64(), - /** Total amount of stake that would be active in the next epoch. */ - next_epoch_stake: bcs.u64(), - /** This validator's gas price quote for the next epoch. */ - next_epoch_gas_price: bcs.u64(), - /** The commission rate of the validator starting the next epoch, in basis point. */ - next_epoch_commission_rate: bcs.u64(), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const StakingRequestEvent = new MoveStruct({ - name: `${$moduleName}::StakingRequestEvent`, - fields: { - pool_id: bcs.Address, - validator_address: bcs.Address, - staker_address: bcs.Address, - epoch: bcs.u64(), - amount: bcs.u64(), - }, -}); -export const UnstakingRequestEvent = new MoveStruct({ - name: `${$moduleName}::UnstakingRequestEvent`, - fields: { - pool_id: bcs.Address, - validator_address: bcs.Address, - staker_address: bcs.Address, - stake_activation_epoch: bcs.u64(), - unstaking_epoch: bcs.u64(), - principal_amount: bcs.u64(), - reward_amount: bcs.u64(), - }, -}); -export const ConvertingToFungibleStakedSuiEvent = new MoveStruct({ - name: `${$moduleName}::ConvertingToFungibleStakedSuiEvent`, - fields: { - pool_id: bcs.Address, - stake_activation_epoch: bcs.u64(), - staked_sui_principal_amount: bcs.u64(), - fungible_staked_sui_amount: bcs.u64(), - }, -}); -export const RedeemingFungibleStakedSuiEvent = new MoveStruct({ - name: `${$moduleName}::RedeemingFungibleStakedSuiEvent`, - fields: { - pool_id: bcs.Address, - fungible_staked_sui_amount: bcs.u64(), - sui_amount: bcs.u64(), - }, -}); -export interface IsPreactiveArguments { - self: RawTransactionArgument; -} -export interface IsPreactiveOptions { - package: string; - arguments: IsPreactiveArguments | [self: RawTransactionArgument]; -} -/** Returns true if the validator is preactive. */ -export function isPreactive(options: IsPreactiveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'is_preactive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MetadataArguments { - self: RawTransactionArgument; -} -export interface MetadataOptions { - package: string; - arguments: MetadataArguments | [self: RawTransactionArgument]; -} -export function metadata(options: MetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SuiAddressArguments { - self: RawTransactionArgument; -} -export interface SuiAddressOptions { - package: string; - arguments: SuiAddressArguments | [self: RawTransactionArgument]; -} -export function suiAddress(options: SuiAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'sui_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NameArguments { - self: RawTransactionArgument; -} -export interface NameOptions { - package: string; - arguments: NameArguments | [self: RawTransactionArgument]; -} -export function name(options: NameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DescriptionArguments { - self: RawTransactionArgument; -} -export interface DescriptionOptions { - package: string; - arguments: DescriptionArguments | [self: RawTransactionArgument]; -} -export function description(options: DescriptionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'description', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ImageUrlArguments { - self: RawTransactionArgument; -} -export interface ImageUrlOptions { - package: string; - arguments: ImageUrlArguments | [self: RawTransactionArgument]; -} -export function imageUrl(options: ImageUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'image_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProjectUrlArguments { - self: RawTransactionArgument; -} -export interface ProjectUrlOptions { - package: string; - arguments: ProjectUrlArguments | [self: RawTransactionArgument]; -} -export function projectUrl(options: ProjectUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'project_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NetworkAddressArguments { - self: RawTransactionArgument; -} -export interface NetworkAddressOptions { - package: string; - arguments: NetworkAddressArguments | [self: RawTransactionArgument]; -} -export function networkAddress(options: NetworkAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'network_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface P2pAddressArguments { - self: RawTransactionArgument; -} -export interface P2pAddressOptions { - package: string; - arguments: P2pAddressArguments | [self: RawTransactionArgument]; -} -export function p2pAddress(options: P2pAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'p2p_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PrimaryAddressArguments { - self: RawTransactionArgument; -} -export interface PrimaryAddressOptions { - package: string; - arguments: PrimaryAddressArguments | [self: RawTransactionArgument]; -} -export function primaryAddress(options: PrimaryAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'primary_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface WorkerAddressArguments { - self: RawTransactionArgument; -} -export interface WorkerAddressOptions { - package: string; - arguments: WorkerAddressArguments | [self: RawTransactionArgument]; -} -export function workerAddress(options: WorkerAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'worker_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProtocolPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface ProtocolPubkeyBytesOptions { - package: string; - arguments: ProtocolPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function protocolPubkeyBytes(options: ProtocolPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'protocol_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ProofOfPossessionArguments { - self: RawTransactionArgument; -} -export interface ProofOfPossessionOptions { - package: string; - arguments: ProofOfPossessionArguments | [self: RawTransactionArgument]; -} -export function proofOfPossession(options: ProofOfPossessionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'proof_of_possession', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NetworkPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface NetworkPubkeyBytesOptions { - package: string; - arguments: NetworkPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function networkPubkeyBytes(options: NetworkPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'network_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface WorkerPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface WorkerPubkeyBytesOptions { - package: string; - arguments: WorkerPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function workerPubkeyBytes(options: WorkerPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'worker_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochNetworkAddressArguments { - self: RawTransactionArgument; -} -export interface NextEpochNetworkAddressOptions { - package: string; - arguments: NextEpochNetworkAddressArguments | [self: RawTransactionArgument]; -} -export function nextEpochNetworkAddress(options: NextEpochNetworkAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_network_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochP2pAddressArguments { - self: RawTransactionArgument; -} -export interface NextEpochP2pAddressOptions { - package: string; - arguments: NextEpochP2pAddressArguments | [self: RawTransactionArgument]; -} -export function nextEpochP2pAddress(options: NextEpochP2pAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_p2p_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochPrimaryAddressArguments { - self: RawTransactionArgument; -} -export interface NextEpochPrimaryAddressOptions { - package: string; - arguments: NextEpochPrimaryAddressArguments | [self: RawTransactionArgument]; -} -export function nextEpochPrimaryAddress(options: NextEpochPrimaryAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_primary_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochWorkerAddressArguments { - self: RawTransactionArgument; -} -export interface NextEpochWorkerAddressOptions { - package: string; - arguments: NextEpochWorkerAddressArguments | [self: RawTransactionArgument]; -} -export function nextEpochWorkerAddress(options: NextEpochWorkerAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_worker_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochProtocolPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface NextEpochProtocolPubkeyBytesOptions { - package: string; - arguments: NextEpochProtocolPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function nextEpochProtocolPubkeyBytes(options: NextEpochProtocolPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_protocol_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochProofOfPossessionArguments { - self: RawTransactionArgument; -} -export interface NextEpochProofOfPossessionOptions { - package: string; - arguments: NextEpochProofOfPossessionArguments | [self: RawTransactionArgument]; -} -export function nextEpochProofOfPossession(options: NextEpochProofOfPossessionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_proof_of_possession', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochNetworkPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface NextEpochNetworkPubkeyBytesOptions { - package: string; - arguments: NextEpochNetworkPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function nextEpochNetworkPubkeyBytes(options: NextEpochNetworkPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_network_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochWorkerPubkeyBytesArguments { - self: RawTransactionArgument; -} -export interface NextEpochWorkerPubkeyBytesOptions { - package: string; - arguments: NextEpochWorkerPubkeyBytesArguments | [self: RawTransactionArgument]; -} -export function nextEpochWorkerPubkeyBytes(options: NextEpochWorkerPubkeyBytesOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_worker_pubkey_bytes', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface OperationCapIdArguments { - self: RawTransactionArgument; -} -export interface OperationCapIdOptions { - package: string; - arguments: OperationCapIdArguments | [self: RawTransactionArgument]; -} -export function operationCapId(options: OperationCapIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'operation_cap_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NextEpochGasPriceArguments { - self: RawTransactionArgument; -} -export interface NextEpochGasPriceOptions { - package: string; - arguments: NextEpochGasPriceArguments | [self: RawTransactionArgument]; -} -export function nextEpochGasPrice(options: NextEpochGasPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'next_epoch_gas_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TotalStakeAmountArguments { - self: RawTransactionArgument; -} -export interface TotalStakeAmountOptions { - package: string; - arguments: TotalStakeAmountArguments | [self: RawTransactionArgument]; -} -export function totalStakeAmount(options: TotalStakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'total_stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface StakeAmountArguments { - self: RawTransactionArgument; -} -export interface StakeAmountOptions { - package: string; - arguments: StakeAmountArguments | [self: RawTransactionArgument]; -} -export function stakeAmount(options: StakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TotalStakeArguments { - self: RawTransactionArgument; -} -export interface TotalStakeOptions { - package: string; - arguments: TotalStakeArguments | [self: RawTransactionArgument]; -} -/** Return the total amount staked with this validator */ -export function totalStake(options: TotalStakeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'total_stake', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface VotingPowerArguments { - self: RawTransactionArgument; -} -export interface VotingPowerOptions { - package: string; - arguments: VotingPowerArguments | [self: RawTransactionArgument]; -} -/** Return the voting power of this validator. */ -export function votingPower(options: VotingPowerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'voting_power', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PendingStakeAmountArguments { - self: RawTransactionArgument; -} -export interface PendingStakeAmountOptions { - package: string; - arguments: PendingStakeAmountArguments | [self: RawTransactionArgument]; -} -export function pendingStakeAmount(options: PendingStakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'pending_stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PendingStakeWithdrawAmountArguments { - self: RawTransactionArgument; -} -export interface PendingStakeWithdrawAmountOptions { - package: string; - arguments: PendingStakeWithdrawAmountArguments | [self: RawTransactionArgument]; -} -export function pendingStakeWithdrawAmount(options: PendingStakeWithdrawAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'pending_stake_withdraw_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GasPriceArguments { - self: RawTransactionArgument; -} -export interface GasPriceOptions { - package: string; - arguments: GasPriceArguments | [self: RawTransactionArgument]; -} -export function gasPrice(options: GasPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'gas_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CommissionRateArguments { - self: RawTransactionArgument; -} -export interface CommissionRateOptions { - package: string; - arguments: CommissionRateArguments | [self: RawTransactionArgument]; -} -export function commissionRate(options: CommissionRateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'commission_rate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PoolTokenExchangeRateAtEpochArguments { - self: RawTransactionArgument; - epoch: RawTransactionArgument; -} -export interface PoolTokenExchangeRateAtEpochOptions { - package: string; - arguments: - | PoolTokenExchangeRateAtEpochArguments - | [self: RawTransactionArgument, epoch: RawTransactionArgument]; -} -export function poolTokenExchangeRateAtEpoch(options: PoolTokenExchangeRateAtEpochOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'epoch']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'pool_token_exchange_rate_at_epoch', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface StakingPoolIdArguments { - self: RawTransactionArgument; -} -export interface StakingPoolIdOptions { - package: string; - arguments: StakingPoolIdArguments | [self: RawTransactionArgument]; -} -export function stakingPoolId(options: StakingPoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'staking_pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsDuplicateArguments { - self: RawTransactionArgument; - other: RawTransactionArgument; -} -export interface IsDuplicateOptions { - package: string; - arguments: - | IsDuplicateArguments - | [self: RawTransactionArgument, other: RawTransactionArgument]; -} -export function isDuplicate(options: IsDuplicateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'other']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'is_duplicate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidateMetadataArguments { - metadata: RawTransactionArgument; -} -export interface ValidateMetadataOptions { - package: string; - arguments: ValidateMetadataArguments | [metadata: RawTransactionArgument]; -} -/** Aborts if validator metadata is valid */ -export function validateMetadata(options: ValidateMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'validate_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidateMetadataBcsArguments { - metadata: RawTransactionArgument; -} -export interface ValidateMetadataBcsOptions { - package: string; - arguments: ValidateMetadataBcsArguments | [metadata: RawTransactionArgument]; -} -export function validateMetadataBcs(options: ValidateMetadataBcsOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['metadata']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator', - function: 'validate_metadata_bcs', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts deleted file mode 100644 index f6da63e52..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_cap.ts +++ /dev/null @@ -1,19 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = '0x3::validator_cap'; -export const UnverifiedValidatorOperationCap = new MoveStruct({ - name: `${$moduleName}::UnverifiedValidatorOperationCap`, - fields: { - id: bcs.Address, - authorizer_validator_address: bcs.Address, - }, -}); -export const ValidatorOperationCap = new MoveStruct({ - name: `${$moduleName}::ValidatorOperationCap`, - fields: { - authorizer_validator_address: bcs.Address, - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts deleted file mode 100644 index ee38fabc1..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_set.ts +++ /dev/null @@ -1,426 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - MoveTuple, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as validator from './validator.js'; -import * as table_vec from '../sui/table_vec.js'; -import * as table from '../sui/table.js'; -import * as vec_map from '../sui/vec_map.js'; -import * as bag from '../sui/bag.js'; -import * as staking_pool from './staking_pool.js'; -const $moduleName = '0x3::validator_set'; -export const ValidatorSet = new MoveStruct({ - name: `${$moduleName}::ValidatorSet`, - fields: { - /** - * Total amount of stake from all active validators at the beginning of the epoch. - * Written only once per epoch, in `advance_epoch` function. - */ - total_stake: bcs.u64(), - /** The current list of active validators. */ - active_validators: bcs.vector(validator.Validator), - /** - * List of new validator candidates added during the current epoch. They will be - * processed at the end of the epoch. - */ - pending_active_validators: table_vec.TableVec, - /** - * Removal requests from the validators. Each element is an index pointing to - * `active_validators`. - */ - pending_removals: bcs.vector(bcs.u64()), - /** Mappings from staking pool's ID to the sui address of a validator. */ - staking_pool_mappings: table.Table, - /** - * Mapping from a staking pool ID to the inactive validator that has that pool as - * its staking pool. When a validator is deactivated the validator is removed from - * `active_validators` it is added to this table so that stakers can continue to - * withdraw their stake from it. - */ - inactive_validators: table.Table, - /** - * Table storing preactive/candidate validators, mapping their addresses to their - * `Validator ` structs. When an address calls `request_add_validator_candidate`, - * they get added to this table and become a preactive validator. When the - * candidate has met the min stake requirement, they can call - * `request_add_validator` to officially add them to the active validator set - * `active_validators` next epoch. - */ - validator_candidates: table.Table, - /** - * Table storing the number of epochs during which a validator's stake has been - * below the low stake threshold. - */ - at_risk_validators: vec_map.VecMap(bcs.Address, bcs.u64()), - /** Any extra fields that's not defined statically. */ - extra_fields: bag.Bag, - }, -}); -export const ValidatorEpochInfoEvent = new MoveStruct({ - name: `${$moduleName}::ValidatorEpochInfoEvent`, - fields: { - epoch: bcs.u64(), - validator_address: bcs.Address, - reference_gas_survey_quote: bcs.u64(), - stake: bcs.u64(), - commission_rate: bcs.u64(), - pool_staking_reward: bcs.u64(), - storage_fund_staking_reward: bcs.u64(), - pool_token_exchange_rate: staking_pool.PoolTokenExchangeRate, - tallying_rule_reporters: bcs.vector(bcs.Address), - tallying_rule_global_score: bcs.u64(), - }, -}); -export const ValidatorEpochInfoEventV2 = new MoveStruct({ - name: `${$moduleName}::ValidatorEpochInfoEventV2`, - fields: { - epoch: bcs.u64(), - validator_address: bcs.Address, - reference_gas_survey_quote: bcs.u64(), - stake: bcs.u64(), - voting_power: bcs.u64(), - commission_rate: bcs.u64(), - pool_staking_reward: bcs.u64(), - storage_fund_staking_reward: bcs.u64(), - pool_token_exchange_rate: staking_pool.PoolTokenExchangeRate, - tallying_rule_reporters: bcs.vector(bcs.Address), - tallying_rule_global_score: bcs.u64(), - }, -}); -export const ValidatorJoinEvent = new MoveStruct({ - name: `${$moduleName}::ValidatorJoinEvent`, - fields: { - epoch: bcs.u64(), - validator_address: bcs.Address, - staking_pool_id: bcs.Address, - }, -}); -export const ValidatorLeaveEvent = new MoveStruct({ - name: `${$moduleName}::ValidatorLeaveEvent`, - fields: { - epoch: bcs.u64(), - validator_address: bcs.Address, - staking_pool_id: bcs.Address, - is_voluntary: bcs.bool(), - }, -}); -export const VotingPowerAdmissionStartEpochKey = new MoveTuple({ - name: `${$moduleName}::VotingPowerAdmissionStartEpochKey`, - fields: [bcs.bool()], -}); -export interface DeriveReferenceGasPriceArguments { - self: RawTransactionArgument; -} -export interface DeriveReferenceGasPriceOptions { - package: string; - arguments: DeriveReferenceGasPriceArguments | [self: RawTransactionArgument]; -} -/** - * Called by `sui_system` to derive reference gas price for the new epoch. Derive - * the reference gas price based on the gas price quote submitted by each - * validator. The returned gas price should be greater than or equal to 2/3 of the - * validators submitted gas price, weighted by stake. - */ -export function deriveReferenceGasPrice(options: DeriveReferenceGasPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'derive_reference_gas_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TotalStakeArguments { - self: RawTransactionArgument; -} -export interface TotalStakeOptions { - package: string; - arguments: TotalStakeArguments | [self: RawTransactionArgument]; -} -export function totalStake(options: TotalStakeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'total_stake', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorTotalStakeAmountArguments { - self: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface ValidatorTotalStakeAmountOptions { - package: string; - arguments: - | ValidatorTotalStakeAmountArguments - | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -export function validatorTotalStakeAmount(options: ValidatorTotalStakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'validator_total_stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorStakeAmountArguments { - self: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface ValidatorStakeAmountOptions { - package: string; - arguments: - | ValidatorStakeAmountArguments - | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -export function validatorStakeAmount(options: ValidatorStakeAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'validator_stake_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorVotingPowerArguments { - self: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface ValidatorVotingPowerOptions { - package: string; - arguments: - | ValidatorVotingPowerArguments - | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -export function validatorVotingPower(options: ValidatorVotingPowerOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'validator_voting_power', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorStakingPoolIdArguments { - self: RawTransactionArgument; - validatorAddress: RawTransactionArgument; -} -export interface ValidatorStakingPoolIdOptions { - package: string; - arguments: - | ValidatorStakingPoolIdArguments - | [self: RawTransactionArgument, validatorAddress: RawTransactionArgument]; -} -export function validatorStakingPoolId(options: ValidatorStakingPoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'validatorAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'validator_staking_pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface StakingPoolMappingsArguments { - self: RawTransactionArgument; -} -export interface StakingPoolMappingsOptions { - package: string; - arguments: StakingPoolMappingsArguments | [self: RawTransactionArgument]; -} -export function stakingPoolMappings(options: StakingPoolMappingsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'staking_pool_mappings', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ValidatorAddressByPoolIdArguments { - self: RawTransactionArgument; - poolId: RawTransactionArgument; -} -export interface ValidatorAddressByPoolIdOptions { - package: string; - arguments: - | ValidatorAddressByPoolIdArguments - | [self: RawTransactionArgument, poolId: RawTransactionArgument]; -} -export function validatorAddressByPoolId(options: ValidatorAddressByPoolIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'poolId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'validator_address_by_pool_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GetActiveValidatorRefArguments { - self: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface GetActiveValidatorRefOptions { - package: string; - arguments: - | GetActiveValidatorRefArguments - | [self: RawTransactionArgument, addr: RawTransactionArgument]; -} -export function getActiveValidatorRef(options: GetActiveValidatorRefOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'get_active_validator_ref', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GetPendingValidatorRefArguments { - self: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface GetPendingValidatorRefOptions { - package: string; - arguments: - | GetPendingValidatorRefArguments - | [self: RawTransactionArgument, addr: RawTransactionArgument]; -} -export function getPendingValidatorRef(options: GetPendingValidatorRefOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'get_pending_validator_ref', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SumVotingPowerByAddressesArguments { - vs: RawTransactionArgument; - addresses: RawTransactionArgument; -} -export interface SumVotingPowerByAddressesOptions { - package: string; - arguments: - | SumVotingPowerByAddressesArguments - | [vs: RawTransactionArgument, addresses: RawTransactionArgument]; -} -/** Sum up the total stake of a given list of validator addresses. */ -export function sumVotingPowerByAddresses(options: SumVotingPowerByAddressesOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector
'] satisfies (string | null)[]; - const parameterNames = ['vs', 'addresses']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'sum_voting_power_by_addresses', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ActiveValidatorsArguments { - self: RawTransactionArgument; -} -export interface ActiveValidatorsOptions { - package: string; - arguments: ActiveValidatorsArguments | [self: RawTransactionArgument]; -} -/** Return the active validators in `self` */ -export function activeValidators(options: ActiveValidatorsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'active_validators', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsValidatorCandidateArguments { - self: RawTransactionArgument; - addr: RawTransactionArgument; -} -export interface IsValidatorCandidateOptions { - package: string; - arguments: - | IsValidatorCandidateArguments - | [self: RawTransactionArgument, addr: RawTransactionArgument]; -} -/** Returns true if the `addr` is a validator candidate. */ -export function isValidatorCandidate(options: IsValidatorCandidateOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'addr']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'is_validator_candidate', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsInactiveValidatorArguments { - self: RawTransactionArgument; - stakingPoolId: RawTransactionArgument; -} -export interface IsInactiveValidatorOptions { - package: string; - arguments: - | IsInactiveValidatorArguments - | [self: RawTransactionArgument, stakingPoolId: RawTransactionArgument]; -} -/** - * Returns true if the staking pool identified by `staking_pool_id` is of an - * inactive validator. - */ -export function isInactiveValidator(options: IsInactiveValidatorOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['self', 'stakingPoolId']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'validator_set', - function: 'is_inactive_validator', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts deleted file mode 100644 index 56550b349..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/validator_wrapper.ts +++ /dev/null @@ -1,12 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import * as versioned from '../sui/versioned.js'; -const $moduleName = '0x3::validator_wrapper'; -export const ValidatorWrapper = new MoveStruct({ - name: `${$moduleName}::ValidatorWrapper`, - fields: { - inner: versioned.Versioned, - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts b/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts deleted file mode 100644 index 73d8bd4ca..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/sui_system/voting_power.ts +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = '0x3::voting_power'; -export const VotingPowerInfo = new MoveStruct({ - name: `${$moduleName}::VotingPowerInfo`, - fields: { - validator_index: bcs.u64(), - voting_power: bcs.u64(), - }, -}); -export const VotingPowerInfoV2 = new MoveStruct({ - name: `${$moduleName}::VotingPowerInfoV2`, - fields: { - validator_index: bcs.u64(), - voting_power: bcs.u64(), - stake: bcs.u64(), - }, -}); -export interface TotalVotingPowerOptions { - package: string; - arguments?: []; -} -/** Return the (constant) total voting power */ -export function totalVotingPower(options: TotalVotingPowerOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'voting_power', - function: 'total_voting_power', - }); -} -export interface QuorumThresholdOptions { - package: string; - arguments?: []; -} -/** Return the (constant) quorum threshold */ -export function quorumThreshold(options: QuorumThresholdOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'voting_power', - function: 'quorum_threshold', - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts b/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts deleted file mode 100644 index ebc470d56..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/admin.ts +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Admin features of the SuiNS application. Meant to be called directly by the - * suins admin. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'suins::admin'; -export const Admin = new MoveStruct({ - name: `${$moduleName}::Admin`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface AuthorizeArguments { - cap: RawTransactionArgument; - suins: RawTransactionArgument; -} -export interface AuthorizeOptions { - package: string; - arguments: - | AuthorizeArguments - | [cap: RawTransactionArgument, suins: RawTransactionArgument]; -} -/** - * Authorize the admin application in the SuiNS to get access to protected - * functions. Must be called in order to use the rest of the functions. - */ -export function authorize(options: AuthorizeOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['cap', 'suins']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'admin', - function: 'authorize', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReserveDomainArguments { - _: RawTransactionArgument; - suins: RawTransactionArgument; - domainName: RawTransactionArgument; - noYears: RawTransactionArgument; -} -export interface ReserveDomainOptions { - package: string; - arguments: - | ReserveDomainArguments - | [ - _: RawTransactionArgument, - suins: RawTransactionArgument, - domainName: RawTransactionArgument, - noYears: RawTransactionArgument, - ]; -} -/** Reserve a `domain` in the `SuiNS`. */ -export function reserveDomain(options: ReserveDomainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String', 'u8', '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['_', 'suins', 'domainName', 'noYears']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'admin', - function: 'reserve_domain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReserveDomainsArguments { - _: RawTransactionArgument; - suins: RawTransactionArgument; - domains: RawTransactionArgument; - noYears: RawTransactionArgument; -} -export interface ReserveDomainsOptions { - package: string; - arguments: - | ReserveDomainsArguments - | [ - _: RawTransactionArgument, - suins: RawTransactionArgument, - domains: RawTransactionArgument, - noYears: RawTransactionArgument, - ]; -} -/** Reserve a list of domains. */ -export function reserveDomains(options: ReserveDomainsOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - null, - 'vector<0x1::string::String>', - 'u8', - '0x2::clock::Clock', - ] satisfies (string | null)[]; - const parameterNames = ['_', 'suins', 'domains', 'noYears']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'admin', - function: 'reserve_domains', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts b/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts deleted file mode 100644 index 6aae3cefd..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/auction.ts +++ /dev/null @@ -1,345 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** Implementation of auction module. More information in: ../../../docs */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from '../sui/balance.js'; -import * as linked_table from '../sui/linked_table.js'; -import * as domain from './domain.js'; -import * as coin from '../sui/coin.js'; -import * as suins_registration from './suins_registration.js'; -const $moduleName = 'suins::auction'; -export const App = new MoveStruct({ - name: `${$moduleName}::App`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const AuctionHouse = new MoveStruct({ - name: `${$moduleName}::AuctionHouse`, - fields: { - id: bcs.Address, - balance: balance.Balance, - auctions: linked_table.LinkedTable(domain.Domain), - }, -}); -export const Auction = new MoveStruct({ - name: `${$moduleName}::Auction`, - fields: { - domain: domain.Domain, - start_timestamp_ms: bcs.u64(), - end_timestamp_ms: bcs.u64(), - winner: bcs.Address, - current_bid: coin.Coin, - nft: suins_registration.SuinsRegistration, - }, -}); -export const AuctionStartedEvent = new MoveStruct({ - name: `${$moduleName}::AuctionStartedEvent`, - fields: { - domain: domain.Domain, - start_timestamp_ms: bcs.u64(), - end_timestamp_ms: bcs.u64(), - starting_bid: bcs.u64(), - bidder: bcs.Address, - }, -}); -export const AuctionFinalizedEvent = new MoveStruct({ - name: `${$moduleName}::AuctionFinalizedEvent`, - fields: { - domain: domain.Domain, - start_timestamp_ms: bcs.u64(), - end_timestamp_ms: bcs.u64(), - winning_bid: bcs.u64(), - winner: bcs.Address, - }, -}); -export const BidEvent = new MoveStruct({ - name: `${$moduleName}::BidEvent`, - fields: { - domain: domain.Domain, - bid: bcs.u64(), - bidder: bcs.Address, - }, -}); -export const AuctionExtendedEvent = new MoveStruct({ - name: `${$moduleName}::AuctionExtendedEvent`, - fields: { - domain: domain.Domain, - end_timestamp_ms: bcs.u64(), - }, -}); -export interface StartAuctionAndPlaceBidArguments { - self: RawTransactionArgument; - suins: RawTransactionArgument; - domainName: RawTransactionArgument; - bid: RawTransactionArgument; -} -export interface StartAuctionAndPlaceBidOptions { - package: string; - arguments: - | StartAuctionAndPlaceBidArguments - | [ - self: RawTransactionArgument, - suins: RawTransactionArgument, - domainName: RawTransactionArgument, - bid: RawTransactionArgument, - ]; -} -/** Start an auction if it's not started yet; and make the first bid. */ -export function startAuctionAndPlaceBid(options: StartAuctionAndPlaceBidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'suins', 'domainName', 'bid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'start_auction_and_place_bid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PlaceBidArguments { - self: RawTransactionArgument; - domainName: RawTransactionArgument; - bid: RawTransactionArgument; -} -export interface PlaceBidOptions { - package: string; - arguments: - | PlaceBidArguments - | [ - self: RawTransactionArgument, - domainName: RawTransactionArgument, - bid: RawTransactionArgument, - ]; -} -/** - * #### Notice - * - * Bidders use this function to place a new bid. - * - * Panics Panics if `domain` is invalid or there isn't an auction for `domain` or - * `bid` is too low, - */ -export function placeBid(options: PlaceBidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String', null, '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'domainName', 'bid']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'place_bid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ClaimArguments { - self: RawTransactionArgument; - domainName: RawTransactionArgument; -} -export interface ClaimOptions { - package: string; - arguments: - | ClaimArguments - | [self: RawTransactionArgument, domainName: RawTransactionArgument]; -} -/** - * #### Notice - * - * Auction winner can come and claim the NFT - * - * Panics sender is not the winner - */ -export function claim(options: ClaimOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'domainName']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'claim', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GetAuctionMetadataArguments { - self: RawTransactionArgument; - domainName: RawTransactionArgument; -} -export interface GetAuctionMetadataOptions { - package: string; - arguments: - | GetAuctionMetadataArguments - | [self: RawTransactionArgument, domainName: RawTransactionArgument]; -} -/** - * #### Notice - * - * Get metadata of an auction - * - * #### Params - * - * The domain name being auctioned. - * - * #### Return - * - * (`start_timestamp_ms`, `end_timestamp_ms`, `winner`, `highest_amount`) - */ -export function getAuctionMetadata(options: GetAuctionMetadataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['self', 'domainName']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'get_auction_metadata', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CollectWinningAuctionFundArguments { - self: RawTransactionArgument; - domainName: RawTransactionArgument; -} -export interface CollectWinningAuctionFundOptions { - package: string; - arguments: - | CollectWinningAuctionFundArguments - | [self: RawTransactionArgument, domainName: RawTransactionArgument]; -} -export function collectWinningAuctionFund(options: CollectWinningAuctionFundOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['self', 'domainName']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'collect_winning_auction_fund', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AdminWithdrawFundsArguments { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface AdminWithdrawFundsOptions { - package: string; - arguments: - | AdminWithdrawFundsArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; -} -export function adminWithdrawFunds(options: AdminWithdrawFundsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'admin_withdraw_funds', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AdminFinalizeAuctionArguments { - admin: RawTransactionArgument; - self: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface AdminFinalizeAuctionOptions { - package: string; - arguments: - | AdminFinalizeAuctionArguments - | [ - admin: RawTransactionArgument, - self: RawTransactionArgument, - domain: RawTransactionArgument, - ]; -} -/** - * Admin functionality used to finalize a single auction. - * - * An `operation_limit` limit must be provided which controls how many individual - * operations to perform. This allows the admin to be able to make forward progress - * in finalizing auctions even in the presence of thousands of bids. - * - * This will attempt to do as much as possible of the following based on the - * provided `operation_limit`: - * - * - claim the winning bid and place in `AuctionHouse.balance` - * - push the `SuinsRegistration` to the winner - * - push loosing bids back to their respective account owners - * - * Once all of the above has been done the auction is destroyed, freeing on-chain - * storage. - */ -export function adminFinalizeAuction(options: AdminFinalizeAuctionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['admin', 'self', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'admin_finalize_auction', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AdminTryFinalizeAuctionsArguments { - admin: RawTransactionArgument; - self: RawTransactionArgument; - operationLimit: RawTransactionArgument; -} -export interface AdminTryFinalizeAuctionsOptions { - package: string; - arguments: - | AdminTryFinalizeAuctionsArguments - | [ - admin: RawTransactionArgument, - self: RawTransactionArgument, - operationLimit: RawTransactionArgument, - ]; -} -/** - * Admin functionality used to finalize an arbitrary number of auctions. - * - * An `operation_limit` limit must be provided which controls how many individual - * operations to perform. This allows the admin to be able to make forward progress - * in finalizing auctions even in the presence of thousands of auctions/bids. - */ -export function adminTryFinalizeAuctions(options: AdminTryFinalizeAuctionsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['admin', 'self', 'operationLimit']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'auction', - function: 'admin_try_finalize_auctions', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/config.ts deleted file mode 100644 index 5942f427e..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/config.ts +++ /dev/null @@ -1,229 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'suins::config'; -export const Config = new MoveStruct({ - name: `${$moduleName}::Config`, - fields: { - public_key: bcs.vector(bcs.u8()), - three_char_price: bcs.u64(), - four_char_price: bcs.u64(), - five_plus_char_price: bcs.u64(), - }, -}); -export interface NewArguments { - PublicKey: RawTransactionArgument; - ThreeCharPrice: RawTransactionArgument; - FourCharPrice: RawTransactionArgument; - FivePlusCharPrice: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: - | NewArguments - | [ - PublicKey: RawTransactionArgument, - ThreeCharPrice: RawTransactionArgument, - FourCharPrice: RawTransactionArgument, - FivePlusCharPrice: RawTransactionArgument, - ]; -} -/** - * Create a new instance of the configuration object. Define all properties from - * the start. - */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'u64', 'u64', 'u64'] satisfies (string | null)[]; - const parameterNames = ['PublicKey', 'ThreeCharPrice', 'FourCharPrice', 'FivePlusCharPrice']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetPublicKeyOptions { - package: string; - arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; -} -export function setPublicKey(options: SetPublicKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'set_public_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - }); -} -export interface SetThreeCharPriceOptions { - package: string; - arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; -} -export function setThreeCharPrice(options: SetThreeCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'set_three_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - }); -} -export interface SetFourCharPriceOptions { - package: string; - arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; -} -export function setFourCharPrice(options: SetFourCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'set_four_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - }); -} -export interface SetFivePlusCharPriceOptions { - package: string; - arguments: [_: RawTransactionArgument, _: RawTransactionArgument]; -} -export function setFivePlusCharPrice(options: SetFivePlusCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'set_five_plus_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - }); -} -export interface CalculatePriceOptions { - package: string; - arguments: [ - _: RawTransactionArgument, - _: RawTransactionArgument, - _: RawTransactionArgument, - ]; -} -export function calculatePrice(options: CalculatePriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8', 'u8'] satisfies (string | null)[]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'calculate_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes), - }); -} -export interface PublicKeyArguments { - _: RawTransactionArgument; -} -export interface PublicKeyOptions { - package: string; - arguments: PublicKeyArguments | [_: RawTransactionArgument]; -} -export function publicKey(options: PublicKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'public_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ThreeCharPriceArguments { - _: RawTransactionArgument; -} -export interface ThreeCharPriceOptions { - package: string; - arguments: ThreeCharPriceArguments | [_: RawTransactionArgument]; -} -export function threeCharPrice(options: ThreeCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'three_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FourCharPriceArguments { - _: RawTransactionArgument; -} -export interface FourCharPriceOptions { - package: string; - arguments: FourCharPriceArguments | [_: RawTransactionArgument]; -} -export function fourCharPrice(options: FourCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'four_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface FivePlusCharPriceArguments { - _: RawTransactionArgument; -} -export interface FivePlusCharPriceOptions { - package: string; - arguments: FivePlusCharPriceArguments | [_: RawTransactionArgument]; -} -export function fivePlusCharPrice(options: FivePlusCharPriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'five_plus_char_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AssertValidUserRegisterableDomainArguments { - _: RawTransactionArgument; -} -export interface AssertValidUserRegisterableDomainOptions { - package: string; - arguments: AssertValidUserRegisterableDomainArguments | [_: RawTransactionArgument]; -} -export function assertValidUserRegisterableDomain( - options: AssertValidUserRegisterableDomainOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'config', - function: 'assert_valid_user_registerable_domain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts b/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts deleted file mode 100644 index 5fa477ca5..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/constants.ts +++ /dev/null @@ -1,167 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Module to wrap all constants used across the project. A singleton and not meant - * to be modified (only extended). - * - * This module is free from any non-framework dependencies and serves as a single - * place of storing constants and proving convenient APIs for reading. - */ - -import { type Transaction } from '@mysten/sui/transactions'; -export interface SuiTldOptions { - package: string; - arguments?: []; -} -/** Top level domain for SUI as a String. */ -export function suiTld(options: SuiTldOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'sui_tld', - }); -} -export interface DefaultImageOptions { - package: string; - arguments?: []; -} -/** Default value for the image_url. */ -export function defaultImage(options: DefaultImageOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'default_image', - }); -} -export interface MistPerSuiOptions { - package: string; - arguments?: []; -} -/** The amount of MIST in 1 SUI. */ -export function mistPerSui(options: MistPerSuiOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'mist_per_sui', - }); -} -export interface MinDomainLengthOptions { - package: string; - arguments?: []; -} -/** The minimum length of a domain name. */ -export function minDomainLength(options: MinDomainLengthOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'min_domain_length', - }); -} -export interface MaxDomainLengthOptions { - package: string; - arguments?: []; -} -/** The maximum length of a domain name. */ -export function maxDomainLength(options: MaxDomainLengthOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'max_domain_length', - }); -} -export interface MaxBpsOptions { - package: string; - arguments?: []; -} -/** Maximum value for basis points. */ -export function maxBps(options: MaxBpsOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'max_bps', - }); -} -export interface YearMsOptions { - package: string; - arguments?: []; -} -/** The amount of milliseconds in a year. */ -export function yearMs(options: YearMsOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'year_ms', - }); -} -export interface GracePeriodMsOptions { - package: string; - arguments?: []; -} -/** Grace period in milliseconds after which the domain expires. */ -export function gracePeriodMs(options: GracePeriodMsOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'grace_period_ms', - }); -} -export interface SubdomainAllowCreationKeyOptions { - package: string; - arguments?: []; -} -/** Subdomain constants The NameRecord key that a subdomain can create child names. */ -export function subdomainAllowCreationKey(options: SubdomainAllowCreationKeyOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'subdomain_allow_creation_key', - }); -} -export interface SubdomainAllowExtensionKeyOptions { - package: string; - arguments?: []; -} -/** The NameRecord key that a subdomain can self-renew. */ -export function subdomainAllowExtensionKey(options: SubdomainAllowExtensionKeyOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'subdomain_allow_extension_key', - }); -} -export interface LeafExpirationTimestampOptions { - package: string; - arguments?: []; -} -/** A getter for a leaf name record's expiration timestamp. */ -export function leafExpirationTimestamp(options: LeafExpirationTimestampOptions = {}) { - const packageAddress = options.package; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'constants', - function: 'leaf_expiration_timestamp', - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts b/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts deleted file mode 100644 index 02b17da21..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/controller.ts +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveTuple, - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -const $moduleName = 'suins::controller'; -export const ControllerV2 = new MoveTuple({ - name: `${$moduleName}::ControllerV2`, - fields: [bcs.bool()], -}); -export const Controller = new MoveStruct({ - name: `${$moduleName}::Controller`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface SetTargetAddressArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; - newTarget: RawTransactionArgument; -} -export interface SetTargetAddressOptions { - package: string; - arguments: - | SetTargetAddressArguments - | [ - suins: RawTransactionArgument, - nft: RawTransactionArgument, - newTarget: RawTransactionArgument, - ]; -} -/** Set the target address of a domain. */ -export function setTargetAddress(options: SetTargetAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - null, - '0x1::option::Option
', - '0x2::clock::Clock', - ] satisfies (string | null)[]; - const parameterNames = ['suins', 'nft', 'newTarget']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'set_target_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetReverseLookupArguments { - suins: RawTransactionArgument; - domainName: RawTransactionArgument; -} -export interface SetReverseLookupOptions { - package: string; - arguments: - | SetReverseLookupArguments - | [suins: RawTransactionArgument, domainName: RawTransactionArgument]; -} -/** Set the reverse lookup address for the domain */ -export function setReverseLookup(options: SetReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['suins', 'domainName']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'set_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UnsetReverseLookupArguments { - suins: RawTransactionArgument; -} -export interface UnsetReverseLookupOptions { - package: string; - arguments: UnsetReverseLookupArguments | [suins: RawTransactionArgument]; -} -/** User-facing function - unset the reverse lookup address for the domain. */ -export function unsetReverseLookup(options: UnsetReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['suins']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'unset_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetObjectReverseLookupArguments { - suins: RawTransactionArgument; - obj: RawTransactionArgument; - domainName: RawTransactionArgument; -} -export interface SetObjectReverseLookupOptions { - package: string; - arguments: - | SetObjectReverseLookupArguments - | [ - suins: RawTransactionArgument, - obj: RawTransactionArgument, - domainName: RawTransactionArgument, - ]; -} -/** - * Allows setting the reverse lookup address for an object. Expects a mutable - * reference of the object. - */ -export function setObjectReverseLookup(options: SetObjectReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID', '0x1::string::String'] satisfies ( - | string - | null - )[]; - const parameterNames = ['suins', 'obj', 'domainName']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'set_object_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UnsetObjectReverseLookupArguments { - suins: RawTransactionArgument; - obj: RawTransactionArgument; -} -export interface UnsetObjectReverseLookupOptions { - package: string; - arguments: - | UnsetObjectReverseLookupArguments - | [suins: RawTransactionArgument, obj: RawTransactionArgument]; -} -/** - * Allows unsetting the reverse lookup address for an object. Expects a mutable - * reference of the object. - */ -export function unsetObjectReverseLookup(options: UnsetObjectReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::object::ID'] satisfies (string | null)[]; - const parameterNames = ['suins', 'obj']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'unset_object_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetUserDataArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; - key: RawTransactionArgument; - value: RawTransactionArgument; -} -export interface SetUserDataOptions { - package: string; - arguments: - | SetUserDataArguments - | [ - suins: RawTransactionArgument, - nft: RawTransactionArgument, - key: RawTransactionArgument, - value: RawTransactionArgument, - ]; -} -/** User-facing function - add a new key-value pair to the name record's data. */ -export function setUserData(options: SetUserDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - null, - '0x1::string::String', - '0x1::string::String', - '0x2::clock::Clock', - ] satisfies (string | null)[]; - const parameterNames = ['suins', 'nft', 'key', 'value']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'set_user_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UnsetUserDataArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; - key: RawTransactionArgument; -} -export interface UnsetUserDataOptions { - package: string; - arguments: - | UnsetUserDataArguments - | [ - suins: RawTransactionArgument, - nft: RawTransactionArgument, - key: RawTransactionArgument, - ]; -} -/** User-facing function - remove a key from the name record's data. */ -export function unsetUserData(options: UnsetUserDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::string::String', '0x2::clock::Clock'] satisfies ( - | string - | null - )[]; - const parameterNames = ['suins', 'nft', 'key']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'unset_user_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BurnExpiredArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface BurnExpiredOptions { - package: string; - arguments: - | BurnExpiredArguments - | [suins: RawTransactionArgument, nft: RawTransactionArgument]; -} -export function burnExpired(options: BurnExpiredOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['suins', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'burn_expired', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BurnExpiredSubnameArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface BurnExpiredSubnameOptions { - package: string; - arguments: - | BurnExpiredSubnameArguments - | [suins: RawTransactionArgument, nft: RawTransactionArgument]; -} -export function burnExpiredSubname(options: BurnExpiredSubnameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['suins', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'controller', - function: 'burn_expired_subname', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts deleted file mode 100644 index 9e4eaa36d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/core_config.ts +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * Core configuration of the SuiNS application. - * - * This configuration is used to validate domains for registration and renewal. It - * can only be stored as a valid config in the `SuiNS` object by an admin, hence - * why all the functions are public. Having just the config object cannot pose a - * security risk as it cannot be used. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_set from '../sui/vec_set.js'; -import * as vec_map from '../sui/vec_map.js'; -const $moduleName = 'suins::core_config'; -export const CoreConfig = new MoveStruct({ - name: `${$moduleName}::CoreConfig`, - fields: { - /** Public key of the API server. Currently only used for direct setup. */ - public_key: bcs.vector(bcs.u8()), - /** - * Minimum length of the label part of the domain. This is different from the base - * `domain` checks. This is our minimum acceptable length (for sales). - */ - min_label_length: bcs.u8(), - /** Maximum length of the label part of the domain. */ - max_label_length: bcs.u8(), - /** List of valid TLDs for registration / renewals. */ - valid_tlds: vec_set.VecSet(bcs.string()), - /** The `PaymentIntent` version that can be used for handling sales. */ - payments_version: bcs.u8(), - /** Maximum number of years available for a domain. */ - max_years: bcs.u8(), - extra: vec_map.VecMap(bcs.string(), bcs.string()), - }, -}); -export interface NewArguments { - publicKey: RawTransactionArgument; - minLabelLength: RawTransactionArgument; - maxLabelLength: RawTransactionArgument; - paymentsVersion: RawTransactionArgument; - maxYears: RawTransactionArgument; - validTlds: RawTransactionArgument; - extra: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: - | NewArguments - | [ - publicKey: RawTransactionArgument, - minLabelLength: RawTransactionArgument, - maxLabelLength: RawTransactionArgument, - paymentsVersion: RawTransactionArgument, - maxYears: RawTransactionArgument, - validTlds: RawTransactionArgument, - extra: RawTransactionArgument, - ]; -} -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = [ - 'vector', - 'u8', - 'u8', - 'u8', - 'u8', - 'vector<0x1::string::String>', - null, - ] satisfies (string | null)[]; - const parameterNames = [ - 'publicKey', - 'minLabelLength', - 'maxLabelLength', - 'paymentsVersion', - 'maxYears', - 'validTlds', - 'extra', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PublicKeyArguments { - config: RawTransactionArgument; -} -export interface PublicKeyOptions { - package: string; - arguments: PublicKeyArguments | [config: RawTransactionArgument]; -} -export function publicKey(options: PublicKeyOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'public_key', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MinLabelLengthArguments { - config: RawTransactionArgument; -} -export interface MinLabelLengthOptions { - package: string; - arguments: MinLabelLengthArguments | [config: RawTransactionArgument]; -} -export function minLabelLength(options: MinLabelLengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'min_label_length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MaxLabelLengthArguments { - config: RawTransactionArgument; -} -export interface MaxLabelLengthOptions { - package: string; - arguments: MaxLabelLengthArguments | [config: RawTransactionArgument]; -} -export function maxLabelLength(options: MaxLabelLengthOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'max_label_length', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsValidTldArguments { - config: RawTransactionArgument; - tld: RawTransactionArgument; -} -export interface IsValidTldOptions { - package: string; - arguments: - | IsValidTldArguments - | [config: RawTransactionArgument, tld: RawTransactionArgument]; -} -export function isValidTld(options: IsValidTldOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['config', 'tld']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'is_valid_tld', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PaymentsVersionArguments { - config: RawTransactionArgument; -} -export interface PaymentsVersionOptions { - package: string; - arguments: PaymentsVersionArguments | [config: RawTransactionArgument]; -} -export function paymentsVersion(options: PaymentsVersionOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'payments_version', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface MaxYearsArguments { - config: RawTransactionArgument; -} -export interface MaxYearsOptions { - package: string; - arguments: MaxYearsArguments | [config: RawTransactionArgument]; -} -export function maxYears(options: MaxYearsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'core_config', - function: 'max_years', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts b/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts index f2c0c3076..8542ac7c3 100644 --- a/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts +++ b/packages/suins/src/contracts/suins_auction/deps/suins/domain.ts @@ -10,13 +10,8 @@ * https://en.wikipedia.org/wiki/Domain_name#Domain_name_syntax */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; +import { MoveStruct } from '../../../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; const $moduleName = 'suins::domain'; export const Domain = new MoveStruct({ name: `${$moduleName}::Domain`, @@ -31,204 +26,3 @@ export const Domain = new MoveStruct({ labels: bcs.vector(bcs.string()), }, }); -export interface NewArguments { - domain: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [domain: RawTransactionArgument]; -} -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ToStringArguments { - self: RawTransactionArgument; -} -export interface ToStringOptions { - package: string; - arguments: ToStringArguments | [self: RawTransactionArgument]; -} -/** Converts a domain into a fully-qualified string representation. */ -export function toString(options: ToStringOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'to_string', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface LabelArguments { - self: RawTransactionArgument; - level: RawTransactionArgument; -} -export interface LabelOptions { - package: string; - arguments: - | LabelArguments - | [self: RawTransactionArgument, level: RawTransactionArgument]; -} -/** - * Returns the `label` in a domain specified by `level`. - * - * Given the domain "pay.name.sui" the individual labels have the following levels: - * - * - "pay" - `2` - * - "name" - `1` - * - "sui" - `0` - * - * This means that the TLD will always be at level `0`. - */ -export function label(options: LabelOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'level']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'label', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TldArguments { - self: RawTransactionArgument; -} -export interface TldOptions { - package: string; - arguments: TldArguments | [self: RawTransactionArgument]; -} -/** - * Returns the TLD (Top-Level Domain) of a `Domain`. - * - * "name.sui" -> "sui" - */ -export function tld(options: TldOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'tld', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SldArguments { - self: RawTransactionArgument; -} -export interface SldOptions { - package: string; - arguments: SldArguments | [self: RawTransactionArgument]; -} -/** - * Returns the SLD (Second-Level Domain) of a `Domain`. - * - * "name.sui" -> "sui" - */ -export function sld(options: SldOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'sld', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NumberOfLevelsArguments { - self: RawTransactionArgument; -} -export interface NumberOfLevelsOptions { - package: string; - arguments: NumberOfLevelsArguments | [self: RawTransactionArgument]; -} -export function numberOfLevels(options: NumberOfLevelsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'number_of_levels', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsSubdomainArguments { - domain: RawTransactionArgument; -} -export interface IsSubdomainOptions { - package: string; - arguments: IsSubdomainArguments | [domain: RawTransactionArgument]; -} -export function isSubdomain(options: IsSubdomainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'is_subdomain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ParentArguments { - domain: RawTransactionArgument; -} -export interface ParentOptions { - package: string; - arguments: ParentArguments | [domain: RawTransactionArgument]; -} -/** Derive the parent of a subdomain. e.g. `subdomain.example.sui` -> `example.sui` */ -export function parent(options: ParentOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'parent', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsParentOfArguments { - parent: RawTransactionArgument; - child: RawTransactionArgument; -} -export interface IsParentOfOptions { - package: string; - arguments: - | IsParentOfArguments - | [parent: RawTransactionArgument, child: RawTransactionArgument]; -} -/** Checks if `parent` domain is a valid parent for `child`. */ -export function isParentOf(options: IsParentOfOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['parent', 'child']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'domain', - function: 'is_parent_of', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts b/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts deleted file mode 100644 index 6b5220a5d..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/name_record.ts +++ /dev/null @@ -1,319 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * The `NameRecord` is a struct that represents a single record in the registry. - * Can be replaced by any other data structure due to the way `NameRecord`s are - * stored and managed. SuiNS has no direct and permanent dependency on this module. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from '../sui/vec_map.js'; -const $moduleName = 'suins::name_record'; -export const NameRecord = new MoveStruct({ - name: `${$moduleName}::NameRecord`, - fields: { - /** - * The ID of the `SuinsRegistration` assigned to this record. - * - * The owner of the corresponding `SuinsRegistration` has the rights to be able to - * change and adjust the `target_address` of this domain. - * - * It is possible that the ID changes if the record expires and is purchased by - * someone else. - */ - nft_id: bcs.Address, - /** Timestamp in milliseconds when the record expires. */ - expiration_timestamp_ms: bcs.u64(), - /** The target address that this domain points to */ - target_address: bcs.option(bcs.Address), - /** Additional data which may be stored in a record */ - data: vec_map.VecMap(bcs.string(), bcs.string()), - }, -}); -export interface NewArguments { - nftId: RawTransactionArgument; - expirationTimestampMs: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: - | NewArguments - | [ - nftId: RawTransactionArgument, - expirationTimestampMs: RawTransactionArgument, - ]; -} -/** Create a new NameRecord. */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', 'u64'] satisfies (string | null)[]; - const parameterNames = ['nftId', 'expirationTimestampMs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewLeafArguments { - parentId: RawTransactionArgument; - targetAddress: RawTransactionArgument; -} -export interface NewLeafOptions { - package: string; - arguments: - | NewLeafArguments - | [ - parentId: RawTransactionArgument, - targetAddress: RawTransactionArgument, - ]; -} -/** Create a `leaf` NameRecord. */ -export function newLeaf(options: NewLeafOptions) { - const packageAddress = options.package; - const argumentsTypes = ['0x2::object::ID', '0x1::option::Option
'] satisfies ( - | string - | null - )[]; - const parameterNames = ['parentId', 'targetAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'new_leaf', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetDataArguments { - self: RawTransactionArgument; - data: RawTransactionArgument; -} -export interface SetDataOptions { - package: string; - arguments: - | SetDataArguments - | [self: RawTransactionArgument, data: RawTransactionArgument]; -} -/** - * Set data as a vec_map directly overriding the data set in the registration self. - * This simplifies the editing flow and gives the user and clients a fine-grained - * control over custom data. - * - * Here's a meta example of how a PTB would look like: - * - * ``` - * let record = moveCall('data', [domain_name]); - * moveCall('vec_map::insert', [record.data, key, value]); - * moveCall('vec_map::remove', [record.data, other_key]); - * moveCall('set_data', [domain_name, record.data]); - * ``` - */ -export function setData(options: SetDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'data']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'set_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetTargetAddressArguments { - self: RawTransactionArgument; - newAddress: RawTransactionArgument; -} -export interface SetTargetAddressOptions { - package: string; - arguments: - | SetTargetAddressArguments - | [self: RawTransactionArgument, newAddress: RawTransactionArgument]; -} -/** Set the `target_address` field of the `NameRecord`. */ -export function setTargetAddress(options: SetTargetAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::option::Option
'] satisfies (string | null)[]; - const parameterNames = ['self', 'newAddress']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'set_target_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetExpirationTimestampMsArguments { - self: RawTransactionArgument; - expirationTimestampMs: RawTransactionArgument; -} -export interface SetExpirationTimestampMsOptions { - package: string; - arguments: - | SetExpirationTimestampMsArguments - | [ - self: RawTransactionArgument, - expirationTimestampMs: RawTransactionArgument, - ]; -} -export function setExpirationTimestampMs(options: SetExpirationTimestampMsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'expirationTimestampMs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'set_expiration_timestamp_ms', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasExpiredArguments { - self: RawTransactionArgument; -} -export interface HasExpiredOptions { - package: string; - arguments: HasExpiredArguments | [self: RawTransactionArgument]; -} -/** Check if the record has expired. */ -export function hasExpired(options: HasExpiredOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'has_expired', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasExpiredPastGracePeriodArguments { - self: RawTransactionArgument; -} -export interface HasExpiredPastGracePeriodOptions { - package: string; - arguments: HasExpiredPastGracePeriodArguments | [self: RawTransactionArgument]; -} -/** Check if the record has expired, taking into account the grace period. */ -export function hasExpiredPastGracePeriod(options: HasExpiredPastGracePeriodOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'has_expired_past_grace_period', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsLeafRecordArguments { - self: RawTransactionArgument; -} -export interface IsLeafRecordOptions { - package: string; - arguments: IsLeafRecordArguments | [self: RawTransactionArgument]; -} -/** Checks whether a name_record is a `leaf` record. */ -export function isLeafRecord(options: IsLeafRecordOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'is_leaf_record', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DataArguments { - self: RawTransactionArgument; -} -export interface DataOptions { - package: string; - arguments: DataArguments | [self: RawTransactionArgument]; -} -/** Read the `data` field from the `NameRecord`. */ -export function data(options: DataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface TargetAddressArguments { - self: RawTransactionArgument; -} -export interface TargetAddressOptions { - package: string; - arguments: TargetAddressArguments | [self: RawTransactionArgument]; -} -/** Read the `target_address` field from the `NameRecord`. */ -export function targetAddress(options: TargetAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'target_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NftIdArguments { - self: RawTransactionArgument; -} -export interface NftIdOptions { - package: string; - arguments: NftIdArguments | [self: RawTransactionArgument]; -} -/** Read the `nft_id` field from the `NameRecord`. */ -export function nftId(options: NftIdOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'nft_id', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExpirationTimestampMsArguments { - self: RawTransactionArgument; -} -export interface ExpirationTimestampMsOptions { - package: string; - arguments: ExpirationTimestampMsArguments | [self: RawTransactionArgument]; -} -/** Read the `expiration_timestamp_ms` field from the `NameRecord`. */ -export function expirationTimestampMs(options: ExpirationTimestampMsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'name_record', - function: 'expiration_timestamp_ms', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts b/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts deleted file mode 100644 index 13dfeed06..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/payment.ts +++ /dev/null @@ -1,444 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - MoveEnum, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as domain_1 from './domain.js'; -import * as vec_map from '../sui/vec_map.js'; -import * as type_name from '../suins_auction/type_name.js'; -const $moduleName = 'suins::payment'; -export const RequestData = new MoveStruct({ - name: `${$moduleName}::RequestData`, - fields: { - /** The version of the payment module. */ - version: bcs.u8(), - /** The domain for which the payment is being made. */ - domain: domain_1.Domain, - /** The years for which the payment is being made. Defaults to 1 for registration. */ - years: bcs.u8(), - /** The amount the user has to pay in base units. */ - base_amount: bcs.u64(), - /** - * The discounts (each app can add a key for its discount) to avoid multiple - * additions of the same discount. - */ - discounts_applied: vec_map.VecMap(bcs.string(), bcs.u64()), - /** - * a metadata field for future-proofness. No use-cases are enabled in the current - * release. - */ - metadata: vec_map.VecMap(bcs.string(), bcs.string()), - }, -}); -export const TransactionEvent = new MoveStruct({ - name: `${$moduleName}::TransactionEvent`, - fields: { - app: type_name.TypeName, - domain: domain_1.Domain, - years: bcs.u8(), - request_data_version: bcs.u8(), - base_amount: bcs.u64(), - discounts_applied: vec_map.VecMap(bcs.string(), bcs.u64()), - metadata: vec_map.VecMap(bcs.string(), bcs.string()), - is_renewal: bcs.bool(), - currency: type_name.TypeName, - currency_amount: bcs.u64(), - }, -}); -/** - * The payment intent for a given domain - * - * - Registration: The user is registering a new domain. - * - Renewal: The user is renewing an existing domain. - */ -export const PaymentIntent = new MoveEnum({ - name: `${$moduleName}::PaymentIntent`, - fields: { - Registration: RequestData, - Renewal: RequestData, - }, -}); -/** - * A receipt that is generated after a successful payment. Can be used to: - * - * - Prove that the payment was successful. - * - Register a new name, or renew an existing one. - */ -export const Receipt = new MoveEnum({ - name: `${$moduleName}::Receipt`, - fields: { - Registration: new MoveStruct({ - name: `Receipt.Registration`, - fields: { - domain: domain_1.Domain, - years: bcs.u8(), - version: bcs.u8(), - }, - }), - Renewal: new MoveStruct({ - name: `Receipt.Renewal`, - fields: { - domain: domain_1.Domain, - years: bcs.u8(), - version: bcs.u8(), - }, - }), - }, -}); -export interface ApplyPercentageDiscountArguments> { - intent: RawTransactionArgument; - suins: RawTransactionArgument; - _: RawTransactionArgument; - discountKey: RawTransactionArgument; - discount: RawTransactionArgument; - allowMultipleDiscounts: RawTransactionArgument; -} -export interface ApplyPercentageDiscountOptions> { - package: string; - arguments: - | ApplyPercentageDiscountArguments - | [ - intent: RawTransactionArgument, - suins: RawTransactionArgument, - _: RawTransactionArgument, - discountKey: RawTransactionArgument, - discount: RawTransactionArgument, - allowMultipleDiscounts: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** - * Allow an authorized app to apply a percentage discount to the payment intent. - * E.g. an NS payment can apply a 10% discount on top of a user's 20% discount if - * allow_multiple_discounts is true - */ -export function applyPercentageDiscount>( - options: ApplyPercentageDiscountOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [ - null, - null, - `${options.typeArguments[0]}`, - '0x1::string::String', - 'u8', - 'bool', - ] satisfies (string | null)[]; - const parameterNames = [ - 'intent', - 'suins', - '_', - 'discountKey', - 'discount', - 'allowMultipleDiscounts', - ]; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'apply_percentage_discount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface FinalizePaymentArguments> { - intent: RawTransactionArgument; - suins: RawTransactionArgument; - app: RawTransactionArgument; - coin: RawTransactionArgument; -} -export interface FinalizePaymentOptions> { - package: string; - arguments: - | FinalizePaymentArguments - | [ - intent: RawTransactionArgument, - suins: RawTransactionArgument, - app: RawTransactionArgument, - coin: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** - * Allow an authorized app to finalize a payment. Returns a receipt that can be - * used to register or renew a domain. - * - * SAFETY: Only authorized packages can call this. We do not check the amount of - * funds in this helper. This is the responsibility of the `payments` app. - */ -export function finalizePayment>(options: FinalizePaymentOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, `${options.typeArguments[0]}`, null] satisfies ( - | string - | null - )[]; - const parameterNames = ['intent', 'suins', 'app', 'coin']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'finalize_payment', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface InitRegistrationArguments { - suins: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface InitRegistrationOptions { - package: string; - arguments: - | InitRegistrationArguments - | [suins: RawTransactionArgument, domain: RawTransactionArgument]; -} -/** - * Creates a `PaymentIntent` for registering a new domain. This is a hot-potato and - * can only be consumed in a single transaction. - */ -export function initRegistration(options: InitRegistrationOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[]; - const parameterNames = ['suins', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'init_registration', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface InitRenewalArguments { - suins: RawTransactionArgument; - nft: RawTransactionArgument; - years: RawTransactionArgument; -} -export interface InitRenewalOptions { - package: string; - arguments: - | InitRenewalArguments - | [ - suins: RawTransactionArgument, - nft: RawTransactionArgument, - years: RawTransactionArgument, - ]; -} -/** - * Creates a `PaymentIntent` for renewing an existing domain. This is a hot-potato - * and can only be consumed in a single transaction. - */ -export function initRenewal(options: InitRenewalOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'u8'] satisfies (string | null)[]; - const parameterNames = ['suins', 'nft', 'years']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'init_renewal', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RegisterArguments { - receipt: RawTransactionArgument; - suins: RawTransactionArgument; -} -export interface RegisterOptions { - package: string; - arguments: - | RegisterArguments - | [receipt: RawTransactionArgument, suins: RawTransactionArgument]; -} -/** - * Register a domain with the given receipt. This is a hot-potato and can only be - * consumed in a single transaction. - */ -export function register(options: RegisterOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['receipt', 'suins']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'register', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RenewArguments { - receipt: RawTransactionArgument; - suins: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface RenewOptions { - package: string; - arguments: - | RenewArguments - | [ - receipt: RawTransactionArgument, - suins: RawTransactionArgument, - nft: RawTransactionArgument, - ]; -} -/** - * Renew a domain with the given receipt. This is a hot-potato and can only be - * consumed in a single transaction. - */ -export function renew(options: RenewOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['receipt', 'suins', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'renew', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RequestDataArguments { - intent: RawTransactionArgument; -} -export interface RequestDataOptions { - package: string; - arguments: RequestDataArguments | [intent: RawTransactionArgument]; -} -/** Getters */ -export function requestData(options: RequestDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['intent']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'request_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface YearsArguments { - self: RawTransactionArgument; -} -export interface YearsOptions { - package: string; - arguments: YearsArguments | [self: RawTransactionArgument]; -} -export function years(options: YearsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'years', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BaseAmountArguments { - self: RawTransactionArgument; -} -export interface BaseAmountOptions { - package: string; - arguments: BaseAmountArguments | [self: RawTransactionArgument]; -} -export function baseAmount(options: BaseAmountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'base_amount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DomainArguments { - self: RawTransactionArgument; -} -export interface DomainOptions { - package: string; - arguments: DomainArguments | [self: RawTransactionArgument]; -} -export function domain(options: DomainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'domain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DiscountAppliedArguments { - self: RawTransactionArgument; -} -export interface DiscountAppliedOptions { - package: string; - arguments: DiscountAppliedArguments | [self: RawTransactionArgument]; -} -/** Returns true if at least one discount has been applied to the payment intent. */ -export function discountApplied(options: DiscountAppliedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'discount_applied', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DiscountsAppliedArguments { - self: RawTransactionArgument; -} -export interface DiscountsAppliedOptions { - package: string; - arguments: DiscountsAppliedArguments | [self: RawTransactionArgument]; -} -/** A list of discounts that have been applied to the payment intent. */ -export function discountsApplied(options: DiscountsAppliedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'discounts_applied', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface CalculateTotalAfterDiscountArguments { - data: RawTransactionArgument; - discount: RawTransactionArgument; -} -export interface CalculateTotalAfterDiscountOptions { - package: string; - arguments: - | CalculateTotalAfterDiscountArguments - | [data: RawTransactionArgument, discount: RawTransactionArgument]; -} -/** Public helper to calculate price after a percentage discount has been applied. */ -export function calculateTotalAfterDiscount(options: CalculateTotalAfterDiscountOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u8'] satisfies (string | null)[]; - const parameterNames = ['data', 'discount']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'payment', - function: 'calculate_total_after_discount', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts b/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts deleted file mode 100644 index 3c8912878..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/pricing_config.ts +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveTuple, - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as vec_map from '../sui/vec_map.js'; -const $moduleName = 'suins::pricing_config'; -export const Range = new MoveTuple({ - name: `${$moduleName}::Range`, - fields: [bcs.u64(), bcs.u64()], -}); -export const PricingConfig = new MoveStruct({ - name: `${$moduleName}::PricingConfig`, - fields: { - pricing: vec_map.VecMap(Range, bcs.u64()), - }, -}); -export const RenewalConfig = new MoveStruct({ - name: `${$moduleName}::RenewalConfig`, - fields: { - config: PricingConfig, - }, -}); -export interface CalculateBasePriceArguments { - config: RawTransactionArgument; - length: RawTransactionArgument; -} -export interface CalculateBasePriceOptions { - package: string; - arguments: - | CalculateBasePriceArguments - | [config: RawTransactionArgument, length: RawTransactionArgument]; -} -/** - * Calculates the base price for a given length. - * - * - Base price type is abstracted away. We can switch to a different base. Our - * core base will become USDC. - * - The price is calculated based on the length of the domain name and the - * available ranges. - */ -export function calculateBasePrice(options: CalculateBasePriceOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['config', 'length']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'calculate_base_price', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewArguments { - ranges: RawTransactionArgument; - prices: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: - | NewArguments - | [ranges: RawTransactionArgument, prices: RawTransactionArgument]; -} -/** - * Creates a new PricingConfig with the given ranges and prices. - * - * - The ranges should be sorted in `ascending order` and should not overlap. - * - The length of the ranges and prices should be the same. - * - * All the ranges are inclusive (e.g. [3,5]: includes 3, 4, and 5). - */ -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector', 'vector'] satisfies (string | null)[]; - const parameterNames = ['ranges', 'prices']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface IsBetweenInclusiveArguments { - range: RawTransactionArgument; - length: RawTransactionArgument; -} -export interface IsBetweenInclusiveOptions { - package: string; - arguments: - | IsBetweenInclusiveArguments - | [range: RawTransactionArgument, length: RawTransactionArgument]; -} -/** Checks if the value is between the range (inclusive). */ -export function isBetweenInclusive(options: IsBetweenInclusiveOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['range', 'length']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'is_between_inclusive', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface PricingArguments { - config: RawTransactionArgument; -} -export interface PricingOptions { - package: string; - arguments: PricingArguments | [config: RawTransactionArgument]; -} -/** Returns the pricing config for usage in external apps. */ -export function pricing(options: PricingOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'pricing', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewRenewalConfigArguments { - config: RawTransactionArgument; -} -export interface NewRenewalConfigOptions { - package: string; - arguments: NewRenewalConfigArguments | [config: RawTransactionArgument]; -} -/** Constructor for Renewal that initializes it with a PricingConfig. */ -export function newRenewalConfig(options: NewRenewalConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'new_renewal_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NewRangeArguments { - range: RawTransactionArgument; -} -export interface NewRangeOptions { - package: string; - arguments: NewRangeArguments | [range: RawTransactionArgument]; -} -export function newRange(options: NewRangeOptions) { - const packageAddress = options.package; - const argumentsTypes = ['vector'] satisfies (string | null)[]; - const parameterNames = ['range']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'new_range', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ConfigArguments { - renewal: RawTransactionArgument; -} -export interface ConfigOptions { - package: string; - arguments: ConfigArguments | [renewal: RawTransactionArgument]; -} -export function config(options: ConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['renewal']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'pricing_config', - function: 'config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts b/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts deleted file mode 100644 index 0f609102b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/registry.ts +++ /dev/null @@ -1,518 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as table from '../sui/table.js'; -const $moduleName = 'suins::registry'; -export const Registry = new MoveStruct({ - name: `${$moduleName}::Registry`, - fields: { - /** - * The `registry` table maps `Domain` to `NameRecord`. Added / replaced in the - * `add_record` function. - */ - registry: table.Table, - /** - * The `reverse_registry` table maps `address` to `domain_name`. Updated in the - * `set_reverse_lookup` function. - */ - reverse_registry: table.Table, - }, -}); -export interface NewArguments { - _: RawTransactionArgument; -} -export interface NewOptions { - package: string; - arguments: NewArguments | [_: RawTransactionArgument]; -} -export function _new(options: NewOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'new', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AddRecordIgnoringGracePeriodArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; - noYears: RawTransactionArgument; -} -export interface AddRecordIgnoringGracePeriodOptions { - package: string; - arguments: - | AddRecordIgnoringGracePeriodArguments - | [ - self: RawTransactionArgument, - domain: RawTransactionArgument, - noYears: RawTransactionArgument, - ]; -} -/** - * Attempts to add a new record to the registry without looking at the grace - * period. Currently used for subdomains where there's no grace period to respect. - * Returns a `SuinsRegistration` upon success. - */ -export function addRecordIgnoringGracePeriod(options: AddRecordIgnoringGracePeriodOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'u8', '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self', 'domain', 'noYears']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'add_record_ignoring_grace_period', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AddRecordArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; - noYears: RawTransactionArgument; -} -export interface AddRecordOptions { - package: string; - arguments: - | AddRecordArguments - | [ - self: RawTransactionArgument, - domain: RawTransactionArgument, - noYears: RawTransactionArgument, - ]; -} -/** - * Attempts to add a new record to the registry and returns a `SuinsRegistration` - * upon success. Only use with second-level names. Enforces a `grace_period` by - * default. Not suitable for subdomains (unless a grace period is needed). - */ -export function addRecord(options: AddRecordOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, 'u8', '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self', 'domain', 'noYears']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'add_record', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BurnRegistrationObjectArguments { - self: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface BurnRegistrationObjectOptions { - package: string; - arguments: - | BurnRegistrationObjectArguments - | [self: RawTransactionArgument, nft: RawTransactionArgument]; -} -/** - * Attempts to burn an NFT and get storage rebates. Only works if the NFT has - * expired. - */ -export function burnRegistrationObject(options: BurnRegistrationObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'burn_registration_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface WrapSubdomainArguments { - _: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface WrapSubdomainOptions { - package: string; - arguments: - | WrapSubdomainArguments - | [_: RawTransactionArgument, nft: RawTransactionArgument]; -} -/** Allow creation of subdomain wrappers only to authorized modules. */ -export function wrapSubdomain(options: WrapSubdomainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['_', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'wrap_subdomain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface BurnSubdomainObjectArguments { - self: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface BurnSubdomainObjectOptions { - package: string; - arguments: - | BurnSubdomainObjectArguments - | [self: RawTransactionArgument, nft: RawTransactionArgument]; -} -/** - * Attempts to burn a subdomain registration object, and also invalidates any - * records in the registry / reverse registry. - */ -export function burnSubdomainObject(options: BurnSubdomainObjectOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'burn_subdomain_object', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AddLeafRecordArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; - target: RawTransactionArgument; -} -export interface AddLeafRecordOptions { - package: string; - arguments: - | AddLeafRecordArguments - | [ - self: RawTransactionArgument, - domain: RawTransactionArgument, - target: RawTransactionArgument, - ]; -} -/** - * Adds a `leaf` record to the registry. A `leaf` record is a record that is a - * subdomain and doesn't have an equivalent `SuinsRegistration` object. - * - * Instead, the parent's `SuinsRegistration` object is used to manage - * target_address & remove it / determine expiration. - * - * 1. Leaf records can't have children. They only work as a resolving mechanism. - * 2. Leaf records must always have a `target` address (can't point to `none`). - * 3. Leaf records do not expire. Their expiration date is actually what defines - * their type. - * - * Leaf record's expiration is defined by the parent's expiration. Since the parent - * can only be a `node`, we need to check that the parent's NFT_ID is valid & - * hasn't expired. - */ -export function addLeafRecord(options: AddLeafRecordOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock', 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'domain', 'target']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'add_leaf_record', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface RemoveLeafRecordArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface RemoveLeafRecordOptions { - package: string; - arguments: - | RemoveLeafRecordArguments - | [self: RawTransactionArgument, domain: RawTransactionArgument]; -} -/** - * Can be used to remove a leaf record. Leaf records do not have any symmetrical - * `SuinsRegistration` object. Authorization of who calls this is delegated to the - * authorized module that calls this. - */ -export function removeLeafRecord(options: RemoveLeafRecordOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'remove_leaf_record', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetTargetAddressArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; - newTarget: RawTransactionArgument; -} -export interface SetTargetAddressOptions { - package: string; - arguments: - | SetTargetAddressArguments - | [ - self: RawTransactionArgument, - domain: RawTransactionArgument, - newTarget: RawTransactionArgument, - ]; -} -export function setTargetAddress(options: SetTargetAddressOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x1::option::Option
'] satisfies (string | null)[]; - const parameterNames = ['self', 'domain', 'newTarget']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'set_target_address', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UnsetReverseLookupArguments { - self: RawTransactionArgument; - address: RawTransactionArgument; -} -export interface UnsetReverseLookupOptions { - package: string; - arguments: - | UnsetReverseLookupArguments - | [self: RawTransactionArgument, address: RawTransactionArgument]; -} -export function unsetReverseLookup(options: UnsetReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'address']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'unset_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetReverseLookupArguments { - self: RawTransactionArgument; - address: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface SetReverseLookupOptions { - package: string; - arguments: - | SetReverseLookupArguments - | [ - self: RawTransactionArgument, - address: RawTransactionArgument, - domain: RawTransactionArgument, - ]; -} -/** Reverse lookup can only be set for the record that has the target address. */ -export function setReverseLookup(options: SetReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address', null] satisfies (string | null)[]; - const parameterNames = ['self', 'address', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'set_reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetExpirationTimestampMsArguments { - self: RawTransactionArgument; - nft: RawTransactionArgument; - domain: RawTransactionArgument; - expirationTimestampMs: RawTransactionArgument; -} -export interface SetExpirationTimestampMsOptions { - package: string; - arguments: - | SetExpirationTimestampMsArguments - | [ - self: RawTransactionArgument, - nft: RawTransactionArgument, - domain: RawTransactionArgument, - expirationTimestampMs: RawTransactionArgument, - ]; -} -/** - * Update the `expiration_timestamp_ms` of the given `SuinsRegistration` and - * `NameRecord`. Requires the `SuinsRegistration` to make sure that both timestamps - * are in sync. - */ -export function setExpirationTimestampMs(options: SetExpirationTimestampMsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['self', 'nft', 'domain', 'expirationTimestampMs']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'set_expiration_timestamp_ms', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface SetDataArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; - data: RawTransactionArgument; -} -export interface SetDataOptions { - package: string; - arguments: - | SetDataArguments - | [ - self: RawTransactionArgument, - domain: RawTransactionArgument, - data: RawTransactionArgument, - ]; -} -/** - * Update the `data` of the given `NameRecord` using a `SuinsRegistration`. Use - * with caution and validate(!!) that any system fields are not removed - * (accidentally), when building authorized packages that can write the metadata - * field. - */ -export function setData(options: SetDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'domain', 'data']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'set_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasRecordArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface HasRecordOptions { - package: string; - arguments: - | HasRecordArguments - | [self: RawTransactionArgument, domain: RawTransactionArgument]; -} -/** Check whether the given `domain` is registered in the `Registry`. */ -export function hasRecord(options: HasRecordOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'has_record', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface LookupArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface LookupOptions { - package: string; - arguments: - | LookupArguments - | [self: RawTransactionArgument, domain: RawTransactionArgument]; -} -/** Returns the `NameRecord` associated with the given domain or None. */ -export function lookup(options: LookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ReverseLookupArguments { - self: RawTransactionArgument; - address: RawTransactionArgument; -} -export interface ReverseLookupOptions { - package: string; - arguments: - | ReverseLookupArguments - | [self: RawTransactionArgument, address: RawTransactionArgument]; -} -/** Returns the `domain_name` associated with the given address or None. */ -export function reverseLookup(options: ReverseLookupOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, 'address'] satisfies (string | null)[]; - const parameterNames = ['self', 'address']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'reverse_lookup', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface AssertNftIsAuthorizedArguments { - self: RawTransactionArgument; - nft: RawTransactionArgument; -} -export interface AssertNftIsAuthorizedOptions { - package: string; - arguments: - | AssertNftIsAuthorizedArguments - | [self: RawTransactionArgument, nft: RawTransactionArgument]; -} -/** - * Asserts that the provided NFT: - * - * 1. Matches the ID in the corresponding `Record` - * 2. Has not expired (does not take into account the grace period) - */ -export function assertNftIsAuthorized(options: AssertNftIsAuthorizedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self', 'nft']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'assert_nft_is_authorized', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface GetDataArguments { - self: RawTransactionArgument; - domain: RawTransactionArgument; -} -export interface GetDataOptions { - package: string; - arguments: - | GetDataArguments - | [self: RawTransactionArgument, domain: RawTransactionArgument]; -} -/** Returns the `data` associated with the given `Domain`. */ -export function getData(options: GetDataOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', 'domain']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'registry', - function: 'get_data', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts b/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts deleted file mode 100644 index 9f6703e99..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/subdomain_registration.ts +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * A wrapper for `SuinsRegistration` subdomain objects. - * - * With the wrapper, we are allowing easier distinction between second level names - * & subdomains in RPC Querying | filtering. - * - * We maintain all core functionality unchanged for registry, expiration etc. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as suins_registration from './suins_registration.js'; -const $moduleName = 'suins::subdomain_registration'; -export const SubDomainRegistration = new MoveStruct({ - name: `${$moduleName}::SubDomainRegistration`, - fields: { - id: bcs.Address, - nft: suins_registration.SuinsRegistration, - }, -}); -export interface NftArguments { - name: RawTransactionArgument; -} -export interface NftOptions { - package: string; - arguments: NftArguments | [name: RawTransactionArgument]; -} -export function nft(options: NftOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'subdomain_registration', - function: 'nft', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface NftMutArguments { - name: RawTransactionArgument; -} -export interface NftMutOptions { - package: string; - arguments: NftMutArguments | [name: RawTransactionArgument]; -} -export function nftMut(options: NftMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['name']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'subdomain_registration', - function: 'nft_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts b/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts deleted file mode 100644 index 3b217d87c..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/suins.ts +++ /dev/null @@ -1,460 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** - * The main module of the SuiNS application, defines the `SuiNS` object and the - * authorization mechanism for interacting with the main data storage. - * - * Authorization mechanic: The Admin can authorize applications to access protected - * features of the SuiNS, they're named with a prefix `app_*`. Once authorized, - * application can get mutable access to the `Registry` and add to the application - * `Balance`. - * - * At any moment any of the applications can be deathorized by the Admin making it - * impossible for the deauthorized module to access the registry. - * - * --- - * - * Package Upgrades in mind: - * - * - None of the public functions of the SuiNS feature any specific types - instead - * we use generics to define the actual types in arbitrary modules. - * - The `Registry` itself (the main feature of the application) is stored as a - * dynamic field so that we can change the type and the module that serves the - * registry without breaking the SuiNS compatibility. - * - Any of the old modules can be deauthorized hence disabling its access to the - * registry and the balance. - */ - -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; -import { bcs, type BcsType } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as balance from '../sui/balance.js'; -const $moduleName = 'suins::suins'; -export const AdminCap = new MoveStruct({ - name: `${$moduleName}::AdminCap`, - fields: { - id: bcs.Address, - }, -}); -export const SuiNS = new MoveStruct({ - name: `${$moduleName}::SuiNS`, - fields: { - id: bcs.Address, - /** - * The total balance of the SuiNS. Can be added to by authorized apps. Can be - * withdrawn only by the application Admin. - */ - balance: balance.Balance, - }, -}); -export const SUINS = new MoveStruct({ - name: `${$moduleName}::SUINS`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const ConfigKey = new MoveStruct({ - name: `${$moduleName}::ConfigKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const RegistryKey = new MoveStruct({ - name: `${$moduleName}::RegistryKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const BalanceKey = new MoveStruct({ - name: `${$moduleName}::BalanceKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export const AppKey = new MoveStruct({ - name: `${$moduleName}::AppKey`, - fields: { - dummy_field: bcs.bool(), - }, -}); -export interface WithdrawArguments { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface WithdrawOptions { - package: string; - arguments: - | WithdrawArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; -} -/** - * Withdraw from the SuiNS balance directly and access the Coins within the same - * transaction. This is useful for the admin to withdraw funds from the SuiNS and - * then send them somewhere specific or keep at the address. - */ -export function withdraw(options: WithdrawOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'withdraw', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface WithdrawCustomArguments { - self: RawTransactionArgument; - _: RawTransactionArgument; -} -export interface WithdrawCustomOptions { - package: string; - arguments: - | WithdrawCustomArguments - | [self: RawTransactionArgument, _: RawTransactionArgument]; - typeArguments: [string]; -} -/** Withdraw from the SuiNS balance of a custom coin type. */ -export function withdrawCustom(options: WithdrawCustomOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['self', '_']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'withdraw_custom', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AuthorizeAppArguments { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface AuthorizeAppOptions { - package: string; - arguments: - | AuthorizeAppArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Authorize an application to access protected features of the SuiNS. */ -export function authorizeApp(options: AuthorizeAppOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'authorize_app', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface DeauthorizeAppArguments { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface DeauthorizeAppOptions { - package: string; - arguments: - | DeauthorizeAppArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Deauthorize an application by removing its authorization key. */ -export function deauthorizeApp(options: DeauthorizeAppOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'deauthorize_app', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface IsAppAuthorizedArguments { - self: RawTransactionArgument; -} -export interface IsAppAuthorizedOptions { - package: string; - arguments: IsAppAuthorizedArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Check if an application is authorized to access protected features of the SuiNS. */ -export function isAppAuthorized(options: IsAppAuthorizedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'is_app_authorized', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AssertAppIsAuthorizedArguments { - self: RawTransactionArgument; -} -export interface AssertAppIsAuthorizedOptions { - package: string; - arguments: AssertAppIsAuthorizedArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Assert that an application is authorized to access protected features of the - * SuiNS. Aborts with `EAppNotAuthorized` if not. - */ -export function assertAppIsAuthorized(options: AssertAppIsAuthorizedOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'assert_app_is_authorized', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AppAddBalanceArguments> { - _: RawTransactionArgument; - self: RawTransactionArgument; - balance: RawTransactionArgument; -} -export interface AppAddBalanceOptions> { - package: string; - arguments: - | AppAddBalanceArguments - | [ - _: RawTransactionArgument, - self: RawTransactionArgument, - balance: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Adds balance to the SuiNS. */ -export function appAddBalance>(options: AppAddBalanceOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self', 'balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'app_add_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AppAddCustomBalanceArguments> { - self: RawTransactionArgument; - _: RawTransactionArgument; - balance: RawTransactionArgument; -} -export interface AppAddCustomBalanceOptions> { - package: string; - arguments: - | AppAddCustomBalanceArguments - | [ - self: RawTransactionArgument, - _: RawTransactionArgument, - balance: RawTransactionArgument, - ]; - typeArguments: [string, string]; -} -/** Adds a balance of type `T` to the SuiNS protocol as an authorized app. */ -export function appAddCustomBalance>( - options: AppAddCustomBalanceOptions, -) { - const packageAddress = options.package; - const argumentsTypes = [null, `${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['self', '_', 'balance']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'app_add_custom_balance', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AppRegistryMutArguments> { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface AppRegistryMutOptions> { - package: string; - arguments: - | AppRegistryMutArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string, string]; -} -/** - * Get a mutable access to the `Registry` object. Can only be performed by - * authorized applications. - */ -export function appRegistryMut>(options: AppRegistryMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [`${options.typeArguments[0]}`, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'app_registry_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddConfigArguments> { - _: RawTransactionArgument; - self: RawTransactionArgument; - config: RawTransactionArgument; -} -export interface AddConfigOptions> { - package: string; - arguments: - | AddConfigArguments - | [ - _: RawTransactionArgument, - self: RawTransactionArgument, - config: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Attach dynamic configuration object to the application. */ -export function addConfig>(options: AddConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['_', 'self', 'config']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'add_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface GetConfigArguments { - self: RawTransactionArgument; -} -export interface GetConfigOptions { - package: string; - arguments: GetConfigArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Borrow configuration object. Read-only mode for applications. */ -export function getConfig(options: GetConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'get_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RemoveConfigArguments { - _: RawTransactionArgument; - self: RawTransactionArgument; -} -export interface RemoveConfigOptions { - package: string; - arguments: - | RemoveConfigArguments - | [_: RawTransactionArgument, self: RawTransactionArgument]; - typeArguments: [string]; -} -/** - * Get the configuration object for editing. The admin should put it back after - * editing (no extra check performed). Can be used to swap configuration since the - * `T` has `drop`. Eg nothing is stopping the admin from removing the configuration - * object and adding a new one. - * - * Fully taking the config also allows for edits within a transaction. - */ -export function removeConfig(options: RemoveConfigOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['_', 'self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'remove_config', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface RegistryArguments { - self: RawTransactionArgument; -} -export interface RegistryOptions { - package: string; - arguments: RegistryArguments | [self: RawTransactionArgument]; - typeArguments: [string]; -} -/** Get a read-only access to the `Registry` object. */ -export function registry(options: RegistryOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'registry', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} -export interface AddRegistryArguments> { - _: RawTransactionArgument; - self: RawTransactionArgument; - registry: RawTransactionArgument; -} -export interface AddRegistryOptions> { - package: string; - arguments: - | AddRegistryArguments - | [ - _: RawTransactionArgument, - self: RawTransactionArgument, - registry: RawTransactionArgument, - ]; - typeArguments: [string]; -} -/** Add a registry to the SuiNS. Can only be performed by the admin. */ -export function addRegistry>(options: AddRegistryOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, null, `${options.typeArguments[0]}`] satisfies (string | null)[]; - const parameterNames = ['_', 'self', 'registry']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins', - function: 'add_registry', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - typeArguments: options.typeArguments, - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts b/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts index b852c671f..893c036c8 100644 --- a/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts +++ b/packages/suins/src/contracts/suins_auction/deps/suins/suins_registration.ts @@ -13,21 +13,16 @@ * - all getters are public and take an immutable reference */ -import { - MoveStruct, - normalizeMoveArguments, - type RawTransactionArgument, -} from '../../../utils/index.js'; +import { MoveStruct } from '../../../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; -import { type Transaction } from '@mysten/sui/transactions'; -import * as domain_1 from './domain.js'; +import * as domain from './domain.js'; const $moduleName = 'suins::suins_registration'; export const SuinsRegistration = new MoveStruct({ name: `${$moduleName}::SuinsRegistration`, fields: { id: bcs.Address, /** The parsed domain. */ - domain: domain_1.Domain, + domain: domain.Domain, /** The domain name that the NFT is for. */ domain_name: bcs.string(), /** Timestamp in milliseconds when this NFT expires. */ @@ -36,169 +31,3 @@ export const SuinsRegistration = new MoveStruct({ image_url: bcs.string(), }, }); -export interface HasExpiredArguments { - self: RawTransactionArgument; -} -export interface HasExpiredOptions { - package: string; - arguments: HasExpiredArguments | [self: RawTransactionArgument]; -} -/** - * Check whether the `SuinsRegistration` has expired by comparing the expiration - * timeout with the current time. - */ -export function hasExpired(options: HasExpiredOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'has_expired', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface HasExpiredPastGracePeriodArguments { - self: RawTransactionArgument; -} -export interface HasExpiredPastGracePeriodOptions { - package: string; - arguments: HasExpiredPastGracePeriodArguments | [self: RawTransactionArgument]; -} -/** - * Check whether the `SuinsRegistration` has expired by comparing the expiration - * timeout with the current time. This function also takes into account the grace - * period. - */ -export function hasExpiredPastGracePeriod(options: HasExpiredPastGracePeriodOptions) { - const packageAddress = options.package; - const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'has_expired_past_grace_period', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DomainArguments { - self: RawTransactionArgument; -} -export interface DomainOptions { - package: string; - arguments: DomainArguments | [self: RawTransactionArgument]; -} -/** Get the `domain` field of the `SuinsRegistration`. */ -export function domain(options: DomainOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'domain', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface DomainNameArguments { - self: RawTransactionArgument; -} -export interface DomainNameOptions { - package: string; - arguments: DomainNameArguments | [self: RawTransactionArgument]; -} -/** Get the `domain_name` field of the `SuinsRegistration`. */ -export function domainName(options: DomainNameOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'domain_name', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ExpirationTimestampMsArguments { - self: RawTransactionArgument; -} -export interface ExpirationTimestampMsOptions { - package: string; - arguments: ExpirationTimestampMsArguments | [self: RawTransactionArgument]; -} -/** Get the `expiration_timestamp_ms` field of the `SuinsRegistration`. */ -export function expirationTimestampMs(options: ExpirationTimestampMsOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'expiration_timestamp_ms', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface ImageUrlArguments { - self: RawTransactionArgument; -} -export interface ImageUrlOptions { - package: string; - arguments: ImageUrlArguments | [self: RawTransactionArgument]; -} -/** Get the `image_url` field of the `SuinsRegistration`. */ -export function imageUrl(options: ImageUrlOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'image_url', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidArguments { - self: RawTransactionArgument; -} -export interface UidOptions { - package: string; - arguments: UidArguments | [self: RawTransactionArgument]; -} -export function uid(options: UidOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'uid', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} -export interface UidMutArguments { - self: RawTransactionArgument; -} -export interface UidMutOptions { - package: string; - arguments: UidMutArguments | [self: RawTransactionArgument]; -} -/** Get the mutable `id` field of the `SuinsRegistration`. */ -export function uidMut(options: UidMutOptions) { - const packageAddress = options.package; - const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['self']; - return (tx: Transaction) => - tx.moveCall({ - package: packageAddress, - module: 'suins_registration', - function: 'uid_mut', - arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), - }); -} diff --git a/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts b/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts deleted file mode 100644 index 6f3ea453b..000000000 --- a/packages/suins/src/contracts/suins_auction/deps/suins/update_image.ts +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************************** - * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * - **************************************************************/ - -/** This module is deprecated due to our different approach to display. */ - -import { MoveStruct } from '../../../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; -const $moduleName = 'suins::update_image'; -export const UpdateImage = new MoveStruct({ - name: `${$moduleName}::UpdateImage`, - fields: { - dummy_field: bcs.bool(), - }, -}); diff --git a/packages/suins/src/contracts/suins_auction/offer.ts b/packages/suins/src/contracts/suins_auction/offer.ts index 6297ec93f..524a7fe12 100644 --- a/packages/suins/src/contracts/suins_auction/offer.ts +++ b/packages/suins/src/contracts/suins_auction/offer.ts @@ -9,7 +9,7 @@ import * as object_bag from './deps/sui/object_bag.js'; import * as bag from './deps/sui/bag.js'; import * as balance from './deps/sui/balance.js'; import * as suins_registration from './deps/suins/suins_registration.js'; -import * as type_name from './type_name.js'; +import * as type_name from './deps/std/type_name.js'; const $moduleName = '@suins/auction::offer'; export const OfferTable = new MoveStruct({ name: `${$moduleName}::OfferTable`, diff --git a/packages/suins/src/contracts/suins_auction/option.ts b/packages/suins/src/contracts/suins_auction/option.ts index d87305cbf..0c9e1c330 100644 --- a/packages/suins/src/contracts/suins_auction/option.ts +++ b/packages/suins/src/contracts/suins_auction/option.ts @@ -61,21 +61,18 @@ export function some>(options: SomeOptions typeArguments: options.typeArguments, }); } -export interface IsNoneArguments> { - t: RawTransactionArgument; +export interface IsNoneArguments { + t: RawTransactionArgument; } -export interface IsNoneOptions> { +export interface IsNoneOptions { package?: string; - arguments: IsNoneArguments | [t: RawTransactionArgument]; + arguments: IsNoneArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** Return true if `t` does not hold a value */ -export function isNone>(options: IsNoneOptions) { +export function isNone(options: IsNoneOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -86,21 +83,18 @@ export function isNone>(options: IsNoneOptions> { - t: RawTransactionArgument; +export interface IsSomeArguments { + t: RawTransactionArgument; } -export interface IsSomeOptions> { +export interface IsSomeOptions { package?: string; - arguments: IsSomeArguments | [t: RawTransactionArgument]; + arguments: IsSomeArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** Return true if `t` holds a value */ -export function isSome>(options: IsSomeOptions) { +export function isSome(options: IsSomeOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -112,14 +106,14 @@ export function isSome>(options: IsSomeOptions> { - t: RawTransactionArgument; + t: RawTransactionArgument; eRef: RawTransactionArgument; } export interface ContainsOptions> { package?: string; arguments: | ContainsArguments - | [t: RawTransactionArgument, eRef: RawTransactionArgument]; + | [t: RawTransactionArgument, eRef: RawTransactionArgument]; typeArguments: [string]; } /** @@ -128,10 +122,7 @@ export interface ContainsOptions> { */ export function contains>(options: ContainsOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'eRef']; return (tx: Transaction) => tx.moveCall({ @@ -142,24 +133,21 @@ export function contains>(options: ContainsOptions< typeArguments: options.typeArguments, }); } -export interface BorrowArguments> { - t: RawTransactionArgument; +export interface BorrowArguments { + t: RawTransactionArgument; } -export interface BorrowOptions> { +export interface BorrowOptions { package?: string; - arguments: BorrowArguments | [t: RawTransactionArgument]; + arguments: BorrowArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** * Return an immutable reference to the value inside `t` Aborts if `t` does not * hold a value */ -export function borrow>(options: BorrowOptions) { +export function borrow(options: BorrowOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -171,14 +159,14 @@ export function borrow>(options: BorrowOptions> { - t: RawTransactionArgument; + t: RawTransactionArgument; defaultRef: RawTransactionArgument; } export interface BorrowWithDefaultOptions> { package?: string; arguments: | BorrowWithDefaultArguments - | [t: RawTransactionArgument, defaultRef: RawTransactionArgument]; + | [t: RawTransactionArgument, defaultRef: RawTransactionArgument]; typeArguments: [string]; } /** @@ -189,10 +177,7 @@ export function borrowWithDefault>( options: BorrowWithDefaultOptions, ) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'defaultRef']; return (tx: Transaction) => tx.moveCall({ @@ -204,12 +189,12 @@ export function borrowWithDefault>( }); } export interface GetWithDefaultArguments> { - t: RawTransactionArgument; + t: RawTransactionArgument; default: RawTransactionArgument; } export interface GetWithDefaultOptions> { package?: string; - arguments: GetWithDefaultArguments | [t: RawTransactionArgument]; + arguments: GetWithDefaultArguments | [t: RawTransactionArgument]; default: RawTransactionArgument; typeArguments: [string]; } @@ -221,10 +206,7 @@ export function getWithDefault>( options: GetWithDefaultOptions, ) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'default']; return (tx: Transaction) => tx.moveCall({ @@ -236,14 +218,14 @@ export function getWithDefault>( }); } export interface FillArguments> { - t: RawTransactionArgument; + t: RawTransactionArgument; e: RawTransactionArgument; } export interface FillOptions> { package?: string; arguments: | FillArguments - | [t: RawTransactionArgument, e: RawTransactionArgument]; + | [t: RawTransactionArgument, e: RawTransactionArgument]; typeArguments: [string]; } /** @@ -252,10 +234,7 @@ export interface FillOptions> { */ export function fill>(options: FillOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'e']; return (tx: Transaction) => tx.moveCall({ @@ -266,24 +245,21 @@ export function fill>(options: FillOptions typeArguments: options.typeArguments, }); } -export interface ExtractArguments> { - t: RawTransactionArgument; +export interface ExtractArguments { + t: RawTransactionArgument; } -export interface ExtractOptions> { +export interface ExtractOptions { package?: string; - arguments: ExtractArguments | [t: RawTransactionArgument]; + arguments: ExtractArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** * Convert a `some` option to a `none` by removing and returning the value stored * inside `t` Aborts if `t` does not hold a value */ -export function extract>(options: ExtractOptions) { +export function extract(options: ExtractOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -294,24 +270,21 @@ export function extract>(options: ExtractOptions> { - t: RawTransactionArgument; +export interface BorrowMutArguments { + t: RawTransactionArgument; } -export interface BorrowMutOptions> { +export interface BorrowMutOptions { package?: string; - arguments: BorrowMutArguments | [t: RawTransactionArgument]; + arguments: BorrowMutArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** * Return a mutable reference to the value inside `t` Aborts if `t` does not hold a * value */ -export function borrowMut>(options: BorrowMutOptions) { +export function borrowMut(options: BorrowMutOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -323,14 +296,14 @@ export function borrowMut>(options: BorrowMutOption }); } export interface SwapArguments> { - t: RawTransactionArgument; + t: RawTransactionArgument; e: RawTransactionArgument; } export interface SwapOptions> { package?: string; arguments: | SwapArguments - | [t: RawTransactionArgument, e: RawTransactionArgument]; + | [t: RawTransactionArgument, e: RawTransactionArgument]; typeArguments: [string]; } /** @@ -339,10 +312,7 @@ export interface SwapOptions> { */ export function swap>(options: SwapOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'e']; return (tx: Transaction) => tx.moveCall({ @@ -354,14 +324,14 @@ export function swap>(options: SwapOptions }); } export interface SwapOrFillArguments> { - t: RawTransactionArgument; + t: RawTransactionArgument; e: RawTransactionArgument; } export interface SwapOrFillOptions> { package?: string; arguments: | SwapOrFillArguments - | [t: RawTransactionArgument, e: RawTransactionArgument]; + | [t: RawTransactionArgument, e: RawTransactionArgument]; typeArguments: [string]; } /** @@ -371,10 +341,7 @@ export interface SwapOrFillOptions> { */ export function swapOrFill>(options: SwapOrFillOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'e']; return (tx: Transaction) => tx.moveCall({ @@ -386,12 +353,12 @@ export function swapOrFill>(options: SwapOrFillOpti }); } export interface DestroyWithDefaultArguments> { - t: RawTransactionArgument; + t: RawTransactionArgument; default: RawTransactionArgument; } export interface DestroyWithDefaultOptions> { package?: string; - arguments: DestroyWithDefaultArguments | [t: RawTransactionArgument]; + arguments: DestroyWithDefaultArguments | [t: RawTransactionArgument]; default: RawTransactionArgument; typeArguments: [string]; } @@ -400,10 +367,7 @@ export function destroyWithDefault>( options: DestroyWithDefaultOptions, ) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [ - `0x1::option::Option<${options.typeArguments[0]}>`, - `${options.typeArguments[0]}`, - ] satisfies (string | null)[]; + const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[]; const parameterNames = ['t', 'default']; return (tx: Transaction) => tx.moveCall({ @@ -414,21 +378,18 @@ export function destroyWithDefault>( typeArguments: options.typeArguments, }); } -export interface DestroySomeArguments> { - t: RawTransactionArgument; +export interface DestroySomeArguments { + t: RawTransactionArgument; } -export interface DestroySomeOptions> { +export interface DestroySomeOptions { package?: string; - arguments: DestroySomeArguments | [t: RawTransactionArgument]; + arguments: DestroySomeArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** Unpack `t` and return its contents Aborts if `t` does not hold a value */ -export function destroySome>(options: DestroySomeOptions) { +export function destroySome(options: DestroySomeOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -439,21 +400,18 @@ export function destroySome>(options: DestroySomeOp typeArguments: options.typeArguments, }); } -export interface DestroyNoneArguments> { - t: RawTransactionArgument; +export interface DestroyNoneArguments { + t: RawTransactionArgument; } -export interface DestroyNoneOptions> { +export interface DestroyNoneOptions { package?: string; - arguments: DestroyNoneArguments | [t: RawTransactionArgument]; + arguments: DestroyNoneArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** Unpack `t` Aborts if `t` holds a value */ -export function destroyNone>(options: DestroyNoneOptions) { +export function destroyNone(options: DestroyNoneOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ @@ -464,24 +422,21 @@ export function destroyNone>(options: DestroyNoneOp typeArguments: options.typeArguments, }); } -export interface ToVecArguments> { - t: RawTransactionArgument; +export interface ToVecArguments { + t: RawTransactionArgument; } -export interface ToVecOptions> { +export interface ToVecOptions { package?: string; - arguments: ToVecArguments | [t: RawTransactionArgument]; + arguments: ToVecArguments | [t: RawTransactionArgument]; typeArguments: [string]; } /** * Convert `t` into a vector of length 1 if it is `Some`, and an empty vector * otherwise */ -export function toVec>(options: ToVecOptions) { +export function toVec(options: ToVecOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = [`0x1::option::Option<${options.typeArguments[0]}>`] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['t']; return (tx: Transaction) => tx.moveCall({ diff --git a/packages/suins/src/contracts/suins_auction/string.ts b/packages/suins/src/contracts/suins_auction/string.ts index 0cfc77d89..221081c2b 100644 --- a/packages/suins/src/contracts/suins_auction/string.ts +++ b/packages/suins/src/contracts/suins_auction/string.ts @@ -50,7 +50,7 @@ export interface FromAsciiOptions { /** Convert an ASCII string to a UTF8 string */ export function fromAscii(options: FromAsciiOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -70,7 +70,7 @@ export interface ToAsciiOptions { /** Convert an UTF8 string to an ASCII string. Aborts if `s` is not valid ASCII */ export function toAscii(options: ToAsciiOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -110,7 +110,7 @@ export interface AsBytesOptions { /** Returns a reference to the underlying byte vector. */ export function asBytes(options: AsBytesOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -130,7 +130,7 @@ export interface IntoBytesOptions { /** Unpack the `string` to get its underlying bytes. */ export function intoBytes(options: IntoBytesOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -150,7 +150,7 @@ export interface IsEmptyOptions { /** Checks whether this string is empty. */ export function isEmpty(options: IsEmptyOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -170,7 +170,7 @@ export interface LengthOptions { /** Returns the length of this string, in bytes. */ export function length(options: LengthOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -193,7 +193,7 @@ export interface AppendOptions { /** Appends a string. */ export function append(options: AppendOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['s', 'r']; return (tx: Transaction) => tx.moveCall({ @@ -216,7 +216,7 @@ export interface AppendUtf8Options { /** Appends bytes which must be in valid utf8 format. */ export function appendUtf8(options: AppendUtf8Options) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'vector'] satisfies (string | null)[]; + const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; const parameterNames = ['s', 'bytes']; return (tx: Transaction) => tx.moveCall({ @@ -247,10 +247,7 @@ export interface InsertOptions { */ export function insert(options: InsertOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'u64', '0x1::string::String'] satisfies ( - | string - | null - )[]; + const argumentsTypes = [null, 'u64', null] satisfies (string | null)[]; const parameterNames = ['s', 'at', 'o']; return (tx: Transaction) => tx.moveCall({ @@ -283,7 +280,7 @@ export interface SubstringOptions { */ export function substring(options: SubstringOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; const parameterNames = ['s', 'i', 'j']; return (tx: Transaction) => tx.moveCall({ @@ -309,7 +306,7 @@ export interface IndexOfOptions { */ export function indexOf(options: IndexOfOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['s', 'r']; return (tx: Transaction) => tx.moveCall({ @@ -328,7 +325,7 @@ export interface BytesOptions { } export function bytes(options: BytesOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String'] satisfies (string | null)[]; + const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['s']; return (tx: Transaction) => tx.moveCall({ @@ -355,7 +352,7 @@ export interface SubStringOptions { } export function subString(options: SubStringOptions) { const packageAddress = options.package ?? '@suins/auction'; - const argumentsTypes = ['0x1::string::String', 'u64', 'u64'] satisfies (string | null)[]; + const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; const parameterNames = ['s', 'i', 'j']; return (tx: Transaction) => tx.moveCall({ diff --git a/packages/suins/src/contracts/suins_auction/type_name.ts b/packages/suins/src/contracts/suins_auction/type_name.ts index 8c4dd7751..e40f1033b 100644 --- a/packages/suins/src/contracts/suins_auction/type_name.ts +++ b/packages/suins/src/contracts/suins_auction/type_name.ts @@ -5,8 +5,8 @@ /** Functionality for converting Move types into values. Use with care! */ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; -import { bcs } from '@mysten/sui/bcs'; import { type Transaction } from '@mysten/sui/transactions'; +import * as ascii from './ascii.js'; const $moduleName = '@suins/auction::type_name'; export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, @@ -20,7 +20,7 @@ export const TypeName = new MoveStruct({ * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or * 32 depending on the Move platform) */ - name: bcs.string(), + name: ascii.String, }, }); export interface WithDefiningIdsOptions { From 56d233d2c9fe32920e0d7fd0afa90f27125e9542 Mon Sep 17 00:00:00 2001 From: Gabriel Matei Date: Tue, 17 Feb 2026 10:59:54 +0200 Subject: [PATCH 3/3] feat: Add E2E tests for SuiNS marketplace listings, offers, and auctions --- packages/suins/src/index.ts | 7 - .../suins/src/suins-marketplace-client.ts | 362 ------------------ packages/suins/test/marketplace-live.test.ts | 43 +++ packages/suins/test/marketplace-pre-built.ts | 246 ++++++++++++ 4 files changed, 289 insertions(+), 369 deletions(-) delete mode 100644 packages/suins/src/suins-marketplace-client.ts create mode 100644 packages/suins/test/marketplace-live.test.ts create mode 100644 packages/suins/test/marketplace-pre-built.ts diff --git a/packages/suins/src/index.ts b/packages/suins/src/index.ts index d148412e0..b377f716e 100644 --- a/packages/suins/src/index.ts +++ b/packages/suins/src/index.ts @@ -3,13 +3,6 @@ export { suins, SuinsClient, type SuinsExtensionOptions } from './suins-client.js'; export { SuinsTransaction } from './suins-transaction.js'; export { SuinsMarketplaceTransaction } from './suins-marketplace-transaction.js'; -export { - SuinsMarketplaceClient, - type ListingData, - type AuctionData, - type OfferData, - type SealConfig, -} from './suins-marketplace-client.js'; export type { SuinsClientConfig, PackageInfo, diff --git a/packages/suins/src/suins-marketplace-client.ts b/packages/suins/src/suins-marketplace-client.ts deleted file mode 100644 index dfd6a1930..000000000 --- a/packages/suins/src/suins-marketplace-client.ts +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { bcs } from '@mysten/sui/bcs'; -import { normalizeSuiNSName } from '@mysten/sui/utils'; - -import type { SuinsClient } from './suins-client.js'; -import type { MarketplacePackageInfo } from './types.js'; - -// ─── Response Types ─────────────────────────────────────────────── - -export type ListingData = { - /** Object ID of the listing */ - objectId: string; - /** Address of the listing owner */ - owner: string; - /** Listing price in base units */ - price: string; - /** Optional expiration timestamp in seconds */ - expiresAt: string | null; - /** The SuinsRegistration NFT ID held by the listing */ - suinsRegistrationId: string; -}; - -export type AuctionData = { - /** Object ID of the auction */ - objectId: string; - /** Address of the auction owner */ - owner: string; - /** Start time as Unix timestamp in seconds */ - startTime: string; - /** End time as Unix timestamp in seconds */ - endTime: string; - /** Minimum bid amount in base units */ - minBid: string; - /** Whether the auction has an encrypted reserve price */ - hasReservePrice: boolean; - /** Address of the current highest bidder */ - highestBidder: string; - /** Current highest bid value in base units */ - highestBidValue: string; - /** The SuinsRegistration NFT ID held by the auction */ - suinsRegistrationId: string; -}; - -export type OfferData = { - /** Offer value in base units */ - value: string; - /** Counter offer value set by the domain owner (0 if none) */ - counterOffer: string; - /** Optional expiration timestamp in seconds */ - expiresAt: string | null; -}; - -export type SealConfig = { - /** Key server object addresses */ - keyServers: string[]; - /** Public keys for each key server (as hex strings) */ - publicKeys: string[]; - /** Threshold for the vote */ - threshold: number; -}; - -// ─── Marketplace Client ─────────────────────────────────────────── - -/** - * Read-only client for querying marketplace state from on-chain data. - * - * All methods are pure RPC reads — no gas, no signing, no wallet required. - * - * @example - * ```ts - * const suinsClient = new SuinsClient({ client, network: 'testnet' }); - * const marketplace = new SuinsMarketplaceClient(suinsClient); - * - * const listing = await marketplace.getListing('example.sui'); - * const auction = await marketplace.getAuction('example.sui'); - * const sealConfig = await marketplace.getSealConfig(); - * ``` - */ -export class SuinsMarketplaceClient { - suinsClient: SuinsClient; - - constructor(client: SuinsClient) { - this.suinsClient = client; - } - - private get marketplaceConfig(): MarketplacePackageInfo { - const config = this.suinsClient.config.marketplace; - if (!config) { - throw new Error( - 'Marketplace config is not set. Make sure you are using a network that supports marketplace operations.', - ); - } - return config; - } - - // ─── Listings ───────────────────────────────────────────────── - - /** - * Fetches a fixed-price listing for a domain. - * - * Looks up the domain in the OfferTable's `listings` ObjectBag, - * then fetches the child Listing object. - * - * @param domainName - The domain name (e.g. 'example.sui') - * @returns The listing data, or null if no listing exists - */ - async getListing(domainName: string): Promise { - const normalizedName = normalizeSuiNSName(domainName, 'dot'); - - try { - // 1. Get the inner ObjectBag ID for listings - const listingsId = await this.getOfferListingsId(); - if (!listingsId) return null; - - // 2. Look up the child object in the ObjectBag - const domainNameBytes = new TextEncoder().encode(normalizedName); - const nameBcs = bcs.vector(bcs.u8()).serialize(Array.from(domainNameBytes)).toBytes(); - - const result = await this.suinsClient.client.core.getDynamicField({ - parentId: listingsId, - name: { type: 'vector', bcs: nameBcs }, - }); - - if (!result.dynamicField?.value?.bcs) { - return null; - } - - // 3. Fetch the child Listing object content - const objectId = bcs.Address.parse(result.dynamicField.value.bcs); - - const objResult = await this.suinsClient.client.core.getObject({ - objectId, - include: { json: true }, - }); - - if (!objResult.object?.json) { - return null; - } - - return this.parseListingJson(objectId, objResult.object.json); - } catch { - return null; - } - } - - // ─── Auctions ───────────────────────────────────────────────── - - /** - * Fetches an auction for a domain. - * - * Looks up the domain in the AuctionTable's `bag` ObjectBag, - * then fetches the child Auction object. - * - * @param domainName - The domain name (e.g. 'example.sui') - * @returns The auction data, or null if no auction exists - */ - async getAuction(domainName: string): Promise { - const normalizedName = normalizeSuiNSName(domainName, 'dot'); - - try { - const bagId = await this.getAuctionBagId(); - if (!bagId) return null; - - const domainNameBytes = new TextEncoder().encode(normalizedName); - const nameBcs = bcs.vector(bcs.u8()).serialize(Array.from(domainNameBytes)).toBytes(); - - const result = await this.suinsClient.client.core.getDynamicField({ - parentId: bagId, - name: { type: 'vector', bcs: nameBcs }, - }); - - if (!result.dynamicField?.value?.bcs) { - return null; - } - - const objectId = bcs.Address.parse(result.dynamicField.value.bcs); - - const objResult = await this.suinsClient.client.core.getObject({ - objectId, - include: { json: true }, - }); - - if (!objResult.object?.json) { - return null; - } - - return this.parseAuctionJson(objectId, objResult.object.json); - } catch { - return null; - } - } - - // ─── Seal Config ────────────────────────────────────────────── - - /** - * Fetches the Seal encryption configuration from the AuctionTable. - * - * This is needed before encrypting a reserve price for `createAuction` - * or before calling `sealApprove` + `getDerivedKeys` for finalization. - * - * @returns The Seal configuration (key servers, public keys, threshold) - */ - async getSealConfig(): Promise { - const config = this.marketplaceConfig; - - const result = await this.suinsClient.client.core.getObject({ - objectId: config.auctionTableId, - include: { json: true }, - }); - - if (!result.object?.json) { - throw new Error('Failed to fetch AuctionTable'); - } - - const json = result.object.json; - const keyServers = (json.key_servers as string[]) || []; - const publicKeys = (json.public_keys as string[]) || []; - const threshold = Number(json.threshold || 0); - - if (keyServers.length === 0 || publicKeys.length === 0 || threshold === 0) { - throw new Error('Seal configuration not set in AuctionTable'); - } - - return { keyServers, publicKeys, threshold }; - } - - // ─── Service Fee ────────────────────────────────────────────── - - /** - * Fetches the current service fee percentage from the OfferTable. - * - * The fee is expressed in basis points out of 100,000. - * For example, 2,500 = 2.5%. - * - * @returns The service fee as a number - */ - async getOfferServiceFee(): Promise { - const config = this.marketplaceConfig; - - const result = await this.suinsClient.client.core.getObject({ - objectId: config.offerTableId, - include: { json: true }, - }); - - if (!result.object?.json) { - throw new Error('Failed to fetch OfferTable'); - } - - return Number(result.object.json.service_fee || 0); - } - - /** - * Fetches the current service fee percentage from the AuctionTable. - * - * @returns The service fee as a number - */ - async getAuctionServiceFee(): Promise { - const config = this.marketplaceConfig; - - const result = await this.suinsClient.client.core.getObject({ - objectId: config.auctionTableId, - include: { json: true }, - }); - - if (!result.object?.json) { - throw new Error('Failed to fetch AuctionTable'); - } - - return Number(result.object.json.service_fee || 0); - } - - // ─── Helpers ────────────────────────────────────────────────── - - private async getOfferListingsId(): Promise { - const config = this.marketplaceConfig; - const result = await this.suinsClient.client.core.getObject({ - objectId: config.offerTableId, - include: { json: true }, - }); - - if (!result.object?.json) return null; - - const json = result.object.json as Record; - const listings = json.listings as Record | undefined; - const id = (listings?.fields as Record)?.id as - | Record - | undefined; - return id?.id ? String(id.id) : null; - } - - private async getAuctionBagId(): Promise { - const config = this.marketplaceConfig; - const result = await this.suinsClient.client.core.getObject({ - objectId: config.auctionTableId, - include: { json: true }, - }); - - if (!result.object?.json) return null; - - const json = result.object.json as Record; - const bag = json.bag as Record | undefined; - const id = (bag?.fields as Record)?.id as Record | undefined; - return id?.id ? String(id.id) : null; - } - - // ─── Private parsers ────────────────────────────────────────── - - private parseListingJson(objectId: string, json: Record): ListingData { - const expiresAtObj = json.expires_at as Record | null; - let expiresAtValue: string | null = null; - if (expiresAtObj) { - const vec = expiresAtObj.vec as unknown[] | undefined; - if (vec && vec.length > 0) { - expiresAtValue = String(vec[0]); - } - } - - const suinsReg = json.suins_registration as Record | undefined; - const suinsRegId = suinsReg - ? String((suinsReg.id as Record)?.id ?? suinsReg.id ?? '') - : ''; - - return { - objectId, - owner: String(json.owner ?? ''), - price: String(json.price ?? '0'), - expiresAt: expiresAtValue, - suinsRegistrationId: suinsRegId, - }; - } - - private parseAuctionJson(objectId: string, json: Record): AuctionData { - const reservePrice = json.reserve_price as Record | null; - let hasReservePrice = false; - if (reservePrice) { - const vec = reservePrice.vec as unknown[] | undefined; - hasReservePrice = !!vec && vec.length > 0; - } - - const highestBidBalance = json.highest_bid_balance as Record | undefined; - const bidValue = highestBidBalance ? String(highestBidBalance.value ?? '0') : '0'; - - const suinsReg = json.suins_registration as Record | undefined; - const suinsRegId = suinsReg - ? String((suinsReg.id as Record)?.id ?? suinsReg.id ?? '') - : ''; - - return { - objectId, - owner: String(json.owner ?? ''), - startTime: String(json.start_time ?? '0'), - endTime: String(json.end_time ?? '0'), - minBid: String(json.min_bid ?? '0'), - hasReservePrice, - highestBidder: String(json.highest_bidder ?? ''), - highestBidValue: bidValue, - suinsRegistrationId: suinsRegId, - }; - } -} diff --git a/packages/suins/test/marketplace-live.test.ts b/packages/suins/test/marketplace-live.test.ts new file mode 100644 index 000000000..2235a9c4e --- /dev/null +++ b/packages/suins/test/marketplace-live.test.ts @@ -0,0 +1,43 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from 'vitest'; + +import { + e2eMarketplaceListingFlow, + e2eMarketplaceOfferFlow, + e2eMarketplaceAuctionFlow, +} from './marketplace-pre-built.js'; + +describe('marketplace listings should work on live networks', () => { + it('should work on testnet', async () => { + const res = await e2eMarketplaceListingFlow('testnet'); + if (res.FailedTransaction) { + throw new Error(`Transaction failed: ${JSON.stringify(res.FailedTransaction?.status.error)}`); + } + + expect(res.Transaction.status.success).toEqual(true); + }); +}); + +describe('marketplace offers should work on live networks', () => { + it('should work on testnet', async () => { + const res = await e2eMarketplaceOfferFlow('testnet'); + if (res.FailedTransaction) { + throw new Error(`Transaction failed: ${JSON.stringify(res.FailedTransaction?.status.error)}`); + } + + expect(res.Transaction.status.success).toEqual(true); + }); +}); + +describe('marketplace auctions should work on live networks', () => { + it('should work on testnet', async () => { + const res = await e2eMarketplaceAuctionFlow('testnet'); + if (res.FailedTransaction) { + throw new Error(`Transaction failed: ${JSON.stringify(res.FailedTransaction?.status.error)}`); + } + + expect(res.Transaction.status.success).toEqual(true); + }); +}); diff --git a/packages/suins/test/marketplace-pre-built.ts b/packages/suins/test/marketplace-pre-built.ts new file mode 100644 index 000000000..21a2dade5 --- /dev/null +++ b/packages/suins/test/marketplace-pre-built.ts @@ -0,0 +1,246 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 +import { getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc'; +import { SuiGrpcClient } from '@mysten/sui/grpc'; +import { Transaction } from '@mysten/sui/transactions'; +import { MIST_PER_SUI, normalizeSuiAddress, SUI_TYPE_ARG } from '@mysten/sui/utils'; + +import { SuinsMarketplaceTransaction, SuinsTransaction, suins } from '../src/index.js'; + +/** + * Registers a unique SuiNS name and returns the NFT + remaining coin. + * Helper used by all marketplace flows. + */ +async function registerName(client: any, tx: Transaction, _sender: string) { + const coinConfig = client.suins.config.coins.SUI; // Specify the coin type used for the transaction + + // Split coins for registration and Pyth fee upfront + const [coinInput, pythFeeCoin] = tx.splitCoins(tx.gas, [10n * MIST_PER_SUI, MIST_PER_SUI]); + + const priceInfoObjectId = + coinConfig !== client.suins.config.coins.USDC + ? (await client.suins.getPriceInfoObject(tx, coinConfig.feed, pythFeeCoin))[0] + : null; + + const suinsTx = new SuinsTransaction(client.suins, tx); + const uniqueName = + (Date.now().toString(36) + Math.random().toString(36).substring(2)).repeat(2) + '.sui'; + + const nft = suinsTx.register({ + domain: uniqueName, + years: 2, + coinConfig, + coin: coinInput, + priceInfoObjectId, + }); + + return { nft, uniqueName, coinInput, pythFeeCoin }; +} + +/** + * Listing flow: register → createListing → buyListing → createListing → cancelListing + * + * Tests all three listing operations in a single transaction. + */ +export const e2eMarketplaceListingFlow = async (network: 'testnet') => { + const client = new SuiGrpcClient({ baseUrl: getJsonRpcFullnodeUrl(network), network }).$extend( + suins(), + ); + + const sender = normalizeSuiAddress('0x2'); + const tx = new Transaction(); + + // Register a name to get the NFT + const { nft, uniqueName, coinInput, pythFeeCoin } = await registerName(client, tx, sender); + + const marketplaceTx = new SuinsMarketplaceTransaction(client.suins, tx); + + // 1) Create a listing for the registered name + marketplaceTx.createListing({ + coinType: SUI_TYPE_ARG, + price: 1_000_000_000n, + suinsRegistration: nft, + }); + + // 2) Buy the listing back (returns the NFT) + const [paymentCoin] = tx.splitCoins(tx.gas, [1_000_000_000n]); + const boughtNft = marketplaceTx.buyListing({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + payment: paymentCoin, + }); + + // 3) Create another listing with the NFT we just bought + marketplaceTx.createListing({ + coinType: SUI_TYPE_ARG, + price: 2_000_000_000n, + suinsRegistration: boughtNft, + }); + + // 4) Cancel the listing (returns the NFT) + const cancelledNft = marketplaceTx.cancelListing({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + }); + + tx.transferObjects([cancelledNft, coinInput, pythFeeCoin], tx.pure.address(sender)); + tx.setSender(sender); + + return client.simulateTransaction({ + transaction: tx, + include: { effects: true }, + }); +}; + +/** + * Offer flow: register → placeOffer → cancelOffer → placeOffer → declineOffer + * → placeOffer → makeCounterOffer → acceptCounterOffer → acceptOffer + * + * Tests all six offer operations in a single transaction. + */ +export const e2eMarketplaceOfferFlow = async (network: 'testnet') => { + const client = new SuiGrpcClient({ baseUrl: getJsonRpcFullnodeUrl(network), network }).$extend( + suins(), + ); + + const sender = normalizeSuiAddress('0x2'); + const tx = new Transaction(); + + // Register a name so the domain exists on-chain + const { nft, uniqueName, coinInput, pythFeeCoin } = await registerName(client, tx, sender); + + const marketplaceTx = new SuinsMarketplaceTransaction(client.suins, tx); + + // 1) Place an offer + const [offerCoin1] = tx.splitCoins(tx.gas, [1n * MIST_PER_SUI]); + marketplaceTx.placeOffer({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + coin: offerCoin1, + }); + + // 2) Cancel the offer (returns the refunded coin) + const refundedCoin = marketplaceTx.cancelOffer({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + }); + + // 3) Place another offer + const [offerCoin2] = tx.splitCoins(tx.gas, [1n * MIST_PER_SUI]); + marketplaceTx.placeOffer({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + coin: offerCoin2, + }); + + // 4) Owner declines the offer (refunds the buyer) + marketplaceTx.declineOffer({ + coinType: SUI_TYPE_ARG, + suinsRegistration: nft, + buyerAddress: sender, + }); + + // 5) Place another offer + const [offerCoin3] = tx.splitCoins(tx.gas, [1n * MIST_PER_SUI]); + marketplaceTx.placeOffer({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + coin: offerCoin3, + }); + + // 6) Owner makes a counter offer (2 SUI) + marketplaceTx.makeCounterOffer({ + coinType: SUI_TYPE_ARG, + suinsRegistration: nft, + buyerAddress: sender, + counterOfferValue: 2n * MIST_PER_SUI, + }); + + // 7) Buyer accepts the counter offer (top-up of 1 SUI) + const [topUpCoin] = tx.splitCoins(tx.gas, [1n * MIST_PER_SUI]); + marketplaceTx.acceptCounterOffer({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + coin: topUpCoin, + }); + + // 8) Owner accepts the offer (returns the payment, NFT transferred by contract) + const paymentCoin = marketplaceTx.acceptOffer({ + coinType: SUI_TYPE_ARG, + suinsRegistration: nft, + buyerAddress: sender, + }); + + tx.transferObjects([refundedCoin, paymentCoin, coinInput, pythFeeCoin], tx.pure.address(sender)); + tx.setSender(sender); + + return client.simulateTransaction({ + transaction: tx, + include: { effects: true }, + }); +}; + +/** + * Auction flow: register → createAuction → cancelAuction → createAuction → placeBid + * + * Tests createAuction, cancelAuction, and placeBid in a single transaction. + * finalizeAuction is not tested because it requires the auction to have ended (time-based). + * sealApprove is not tested because it requires Seal encryption infrastructure. + * Times are in seconds. Min duration: 1h, Max duration: 30d. + */ +export const e2eMarketplaceAuctionFlow = async (network: 'testnet') => { + const client = new SuiGrpcClient({ baseUrl: getJsonRpcFullnodeUrl(network), network }).$extend( + suins(), + ); + const sender = normalizeSuiAddress('0x2'); + const tx = new Transaction(); + + // Register a name to get the NFT + const { nft, uniqueName, coinInput, pythFeeCoin } = await registerName(client, tx, sender); + + const nowSec = Math.floor(Date.now() / 1000); + const startTime = nowSec - 60; // slightly in the past so auction is active during simulation + const endTime = nowSec + 7_200; // 2 hours + + const marketplaceTx = new SuinsMarketplaceTransaction(client.suins, tx); + + // 1) Create an auction for the registered name + marketplaceTx.createAuction({ + coinType: SUI_TYPE_ARG, + startTime, + endTime, + minBid: 1_000_000_000n, + suinsRegistration: nft, + }); + + // 2) Cancel the auction before any bids (returns the NFT) + const cancelledNft = marketplaceTx.cancelAuction({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + }); + + // 3) Create another auction with the returned NFT + marketplaceTx.createAuction({ + coinType: SUI_TYPE_ARG, + startTime, + endTime, + minBid: 1_000_000_000n, + suinsRegistration: cancelledNft, + }); + + // 4) Place a bid on the auction + const [bidCoin] = tx.splitCoins(tx.gas, [1n * MIST_PER_SUI]); + marketplaceTx.placeBid({ + coinType: SUI_TYPE_ARG, + domainName: uniqueName, + bid: bidCoin, + }); + + tx.transferObjects([coinInput, pythFeeCoin], tx.pure.address(sender)); + tx.setSender(sender); + + return client.simulateTransaction({ + transaction: tx, + include: { effects: true }, + }); +};