@mysten/suins
Version:
1 lines • 12.4 kB
Source Map (JSON)
{"version":3,"file":"name_record.mjs","names":["vec_map.VecMap"],"sources":["../../../src/contracts/suins/name_record.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * The `NameRecord` is a struct that represents a single record in the registry.\n * Can be replaced by any other data structure due to the way `NameRecord`s are\n * stored and managed. SuiNS has no direct and permanent dependency on this module.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport * as vec_map from './deps/sui/vec_map.js';\nconst $moduleName = '@suins/core::name_record';\nexport const NameRecord = new MoveStruct({\n\tname: `${$moduleName}::NameRecord`,\n\tfields: {\n\t\t/**\n\t\t * The ID of the `SuinsRegistration` assigned to this record.\n\t\t *\n\t\t * The owner of the corresponding `SuinsRegistration` has the rights to be able to\n\t\t * change and adjust the `target_address` of this domain.\n\t\t *\n\t\t * It is possible that the ID changes if the record expires and is purchased by\n\t\t * someone else.\n\t\t */\n\t\tnft_id: bcs.Address,\n\t\t/** Timestamp in milliseconds when the record expires. */\n\t\texpiration_timestamp_ms: bcs.u64(),\n\t\t/** The target address that this domain points to */\n\t\ttarget_address: bcs.option(bcs.Address),\n\t\t/** Additional data which may be stored in a record */\n\t\tdata: vec_map.VecMap(bcs.string(), bcs.string()),\n\t},\n});\nexport interface NewArguments {\n\tnftId: RawTransactionArgument<string>;\n\texpirationTimestampMs: RawTransactionArgument<number | bigint>;\n}\nexport interface NewOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewArguments\n\t\t| [\n\t\t\t\tnftId: RawTransactionArgument<string>,\n\t\t\t\texpirationTimestampMs: RawTransactionArgument<number | bigint>,\n\t\t ];\n}\n/** Create a new NameRecord. */\nexport function _new(options: NewOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = ['0x2::object::ID', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['nftId', 'expirationTimestampMs'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'new',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NewLeafArguments {\n\tparentId: RawTransactionArgument<string>;\n\ttargetAddress: RawTransactionArgument<string | null>;\n}\nexport interface NewLeafOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewLeafArguments\n\t\t| [\n\t\t\t\tparentId: RawTransactionArgument<string>,\n\t\t\t\ttargetAddress: RawTransactionArgument<string | null>,\n\t\t ];\n}\n/** Create a `leaf` NameRecord. */\nexport function newLeaf(options: NewLeafOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = ['0x2::object::ID', '0x1::option::Option<address>'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = ['parentId', 'targetAddress'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'new_leaf',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SetDataArguments {\n\tself: RawTransactionArgument<string>;\n\tdata: RawTransactionArgument<string>;\n}\nexport interface SetDataOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SetDataArguments\n\t\t| [self: RawTransactionArgument<string>, data: RawTransactionArgument<string>];\n}\n/**\n * Set data as a vec_map directly overriding the data set in the registration self.\n * This simplifies the editing flow and gives the user and clients a fine-grained\n * control over custom data.\n *\n * Here's a meta example of how a PTB would look like:\n *\n * ```\n * let record = moveCall('data', [domain_name]);\n * moveCall('vec_map::insert', [record.data, key, value]);\n * moveCall('vec_map::remove', [record.data, other_key]);\n * moveCall('set_data', [domain_name, record.data]);\n * ```\n */\nexport function setData(options: SetDataOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'data'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'set_data',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SetTargetAddressArguments {\n\tself: RawTransactionArgument<string>;\n\tnewAddress: RawTransactionArgument<string | null>;\n}\nexport interface SetTargetAddressOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SetTargetAddressArguments\n\t\t| [self: RawTransactionArgument<string>, newAddress: RawTransactionArgument<string | null>];\n}\n/** Set the `target_address` field of the `NameRecord`. */\nexport function setTargetAddress(options: SetTargetAddressOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null, '0x1::option::Option<address>'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'newAddress'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'set_target_address',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SetExpirationTimestampMsArguments {\n\tself: RawTransactionArgument<string>;\n\texpirationTimestampMs: RawTransactionArgument<number | bigint>;\n}\nexport interface SetExpirationTimestampMsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SetExpirationTimestampMsArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\texpirationTimestampMs: RawTransactionArgument<number | bigint>,\n\t\t ];\n}\nexport function setExpirationTimestampMs(options: SetExpirationTimestampMsOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'expirationTimestampMs'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'set_expiration_timestamp_ms',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface HasExpiredArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface HasExpiredOptions {\n\tpackage?: string;\n\targuments: HasExpiredArguments | [self: RawTransactionArgument<string>];\n}\n/** Check if the record has expired. */\nexport function hasExpired(options: HasExpiredOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'has_expired',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface HasExpiredPastGracePeriodArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface HasExpiredPastGracePeriodOptions {\n\tpackage?: string;\n\targuments: HasExpiredPastGracePeriodArguments | [self: RawTransactionArgument<string>];\n}\n/** Check if the record has expired, taking into account the grace period. */\nexport function hasExpiredPastGracePeriod(options: HasExpiredPastGracePeriodOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'has_expired_past_grace_period',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface IsLeafRecordArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface IsLeafRecordOptions {\n\tpackage?: string;\n\targuments: IsLeafRecordArguments | [self: RawTransactionArgument<string>];\n}\n/** Checks whether a name_record is a `leaf` record. */\nexport function isLeafRecord(options: IsLeafRecordOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'is_leaf_record',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface DataArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface DataOptions {\n\tpackage?: string;\n\targuments: DataArguments | [self: RawTransactionArgument<string>];\n}\n/** Read the `data` field from the `NameRecord`. */\nexport function data(options: DataOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'data',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TargetAddressArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface TargetAddressOptions {\n\tpackage?: string;\n\targuments: TargetAddressArguments | [self: RawTransactionArgument<string>];\n}\n/** Read the `target_address` field from the `NameRecord`. */\nexport function targetAddress(options: TargetAddressOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'target_address',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NftIdArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface NftIdOptions {\n\tpackage?: string;\n\targuments: NftIdArguments | [self: RawTransactionArgument<string>];\n}\n/** Read the `nft_id` field from the `NameRecord`. */\nexport function nftId(options: NftIdOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'nft_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ExpirationTimestampMsArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface ExpirationTimestampMsOptions {\n\tpackage?: string;\n\targuments: ExpirationTimestampMsArguments | [self: RawTransactionArgument<string>];\n}\n/** Read the `expiration_timestamp_ms` field from the `NameRecord`. */\nexport function expirationTimestampMs(options: ExpirationTimestampMsOptions) {\n\tconst packageAddress = options.package ?? '@suins/core';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'name_record',\n\t\t\tfunction: 'expiration_timestamp_ms',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,cAAc;AACpB,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EAUP,QAAQ,IAAI;EAEZ,yBAAyB,IAAI,KAAK;EAElC,gBAAgB,IAAI,OAAO,IAAI,QAAQ;EAEvC,MAAMA,OAAe,IAAI,QAAQ,EAAE,IAAI,QAAQ,CAAC;EAChD;CACD,CAAC"}