@mysten/pas 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1 -0
  2. package/dist/client.d.mts +117 -0
  3. package/dist/client.d.mts.map +1 -0
  4. package/dist/client.mjs +89 -0
  5. package/dist/client.mjs.map +1 -0
  6. package/dist/constants.mjs +9 -0
  7. package/dist/constants.mjs.map +1 -0
  8. package/dist/contracts/pas/deps/std/type_name.mjs +17 -0
  9. package/dist/contracts/pas/deps/std/type_name.mjs.map +1 -0
  10. package/dist/contracts/pas/deps/sui/vec_map.mjs +37 -0
  11. package/dist/contracts/pas/deps/sui/vec_map.mjs.map +1 -0
  12. package/dist/contracts/pas/deps/sui/vec_set.mjs +26 -0
  13. package/dist/contracts/pas/deps/sui/vec_set.mjs.map +1 -0
  14. package/dist/contracts/pas/policy.mjs +33 -0
  15. package/dist/contracts/pas/policy.mjs.map +1 -0
  16. package/dist/contracts/pas/versioning.mjs +25 -0
  17. package/dist/contracts/pas/versioning.mjs.map +1 -0
  18. package/dist/contracts/ptb/ptb.mjs +162 -0
  19. package/dist/contracts/ptb/ptb.mjs.map +1 -0
  20. package/dist/contracts/sui/dynamic_field.mjs +22 -0
  21. package/dist/contracts/sui/dynamic_field.mjs.map +1 -0
  22. package/dist/contracts/utils/index.mjs +37 -0
  23. package/dist/contracts/utils/index.mjs.map +1 -0
  24. package/dist/derivation.mjs +70 -0
  25. package/dist/derivation.mjs.map +1 -0
  26. package/dist/error.d.mts +16 -0
  27. package/dist/error.d.mts.map +1 -0
  28. package/dist/error.mjs +26 -0
  29. package/dist/error.mjs.map +1 -0
  30. package/dist/index.d.mts +4 -0
  31. package/dist/index.mjs +4 -0
  32. package/dist/intents.mjs +494 -0
  33. package/dist/intents.mjs.map +1 -0
  34. package/dist/resolution.mjs +185 -0
  35. package/dist/resolution.mjs.map +1 -0
  36. package/dist/types.d.mts +34 -0
  37. package/dist/types.d.mts.map +1 -0
  38. package/package.json +59 -0
  39. package/src/client.ts +173 -0
  40. package/src/constants.ts +15 -0
  41. package/src/contracts/pas/account.ts +343 -0
  42. package/src/contracts/pas/clawback_funds.ts +114 -0
  43. package/src/contracts/pas/deps/std/type_name.ts +24 -0
  44. package/src/contracts/pas/deps/sui/vec_map.ts +33 -0
  45. package/src/contracts/pas/deps/sui/vec_set.ts +22 -0
  46. package/src/contracts/pas/keys.ts +90 -0
  47. package/src/contracts/pas/namespace.ts +207 -0
  48. package/src/contracts/pas/policy.ts +212 -0
  49. package/src/contracts/pas/request.ts +87 -0
  50. package/src/contracts/pas/send_funds.ts +174 -0
  51. package/src/contracts/pas/templates.ts +101 -0
  52. package/src/contracts/pas/unlock_funds.ts +155 -0
  53. package/src/contracts/pas/versioning.ts +69 -0
  54. package/src/contracts/ptb/ptb.ts +821 -0
  55. package/src/contracts/sui/dynamic_field.ts +171 -0
  56. package/src/contracts/utils/index.ts +235 -0
  57. package/src/derivation.ts +107 -0
  58. package/src/error.ts +29 -0
  59. package/src/index.ts +6 -0
  60. package/src/intents.ts +852 -0
  61. package/src/resolution.ts +294 -0
  62. package/src/types.ts +34 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptb.mjs","names":[],"sources":["../../../src/contracts/ptb/ptb.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/** Module: ptb */\n\nimport {\n\tMoveTuple,\n\tMoveStruct,\n\tMoveEnum,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} from '../utils/index.js';\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { type Transaction as Transaction_1 } from '@mysten/sui/transactions';\nconst $moduleName = '@mysten/ptb::ptb';\nexport const Command = new MoveTuple({\n\tname: `${$moduleName}::Command`,\n\tfields: [bcs.u8(), bcs.vector(bcs.u8())],\n});\nexport const Transaction = new MoveStruct({\n\tname: `${$moduleName}::Transaction`,\n\tfields: {\n\t\tcommands: bcs.vector(Command),\n\t},\n});\n/**\n * Defines a simplified `ObjectArg` type for the `Transaction`.\n *\n * Differences with canonical Sui `ObjectArg` type:\n *\n * - Uses `address` type as a fixed-length sequence of bytes without length prefix.\n * - Extends the number of variants to support off-chain resolution.\n */\nexport const ObjectArg = new MoveEnum({\n\tname: `${$moduleName}::ObjectArg`,\n\tfields: {\n\t\tImmOrOwnedObject: new MoveStruct({\n\t\t\tname: `ObjectArg.ImmOrOwnedObject`,\n\t\t\tfields: {\n\t\t\t\tobject_id: bcs.Address,\n\t\t\t\tsequence_number: bcs.u64(),\n\t\t\t\tdigest: bcs.Address,\n\t\t\t},\n\t\t}),\n\t\tSharedObject: new MoveStruct({\n\t\t\tname: `ObjectArg.SharedObject`,\n\t\t\tfields: {\n\t\t\t\tobject_id: bcs.Address,\n\t\t\t\tinitial_shared_version: bcs.u64(),\n\t\t\t\tis_mutable: bcs.bool(),\n\t\t\t},\n\t\t}),\n\t\tReceiving: new MoveStruct({\n\t\t\tname: `ObjectArg.Receiving`,\n\t\t\tfields: {\n\t\t\t\tobject_id: bcs.Address,\n\t\t\t\tsequence_number: bcs.u64(),\n\t\t\t\tdigest: bcs.Address,\n\t\t\t},\n\t\t}),\n\t\tExt: bcs.string(),\n\t},\n});\nexport const WithdrawFrom = new MoveEnum({\n\tname: `${$moduleName}::WithdrawFrom`,\n\tfields: {\n\t\tSender: null,\n\t\tSponsor: null,\n\t},\n});\n/**\n * Defines a simplified `CallArg` type for `Transaction`.\n *\n * Differences with canonical Sui `CallArg` type:\n *\n * - ObjectArg is a simplified, unresolved representation of Object arguments;\n * - Ext(...) is a custom extension for the `CallArg` which allows off-chain\n * resolvers to convert them into the appropriate values for context.\n */\nexport const CallArg = new MoveEnum({\n\tname: `${$moduleName}::CallArg`,\n\tfields: {\n\t\tPure: bcs.vector(bcs.u8()),\n\t\tObject: ObjectArg,\n\t\tFundsWithdrawal: new MoveStruct({\n\t\t\tname: `CallArg.FundsWithdrawal`,\n\t\t\tfields: {\n\t\t\t\tamount: bcs.u64(),\n\t\t\t\ttype_name: bcs.string(),\n\t\t\t\twithdraw_from: WithdrawFrom,\n\t\t\t},\n\t\t}),\n\t\t/**\n\t\t * Extended arguments for off-chain resolution. Can be created and registered in a\n\t\t * transaction through `ext_input`.\n\t\t *\n\t\t * Extended arguments are namespaced by Type associated with them. In an\n\t\t * application, this can be the root object, or a special type used for off chain\n\t\t * resolution.\n\t\t */\n\t\tExt: new MoveTuple({ name: `CallArg.Ext`, fields: [bcs.string(), bcs.string()] }),\n\t},\n});\n/** Defines a simplified `Argument` type for the `Transaction`. */\nexport const Argument = new MoveEnum({\n\tname: `${$moduleName}::Argument`,\n\tfields: {\n\t\tGasCoin: null,\n\t\tInput: CallArg,\n\t\tResult: bcs.u16(),\n\t\tNestedResult: new MoveTuple({ name: `Argument.NestedResult`, fields: [bcs.u16(), bcs.u16()] }),\n\t\t/**\n\t\t * Extended arguments for off-chain resolution. Cannot be constructed directly,\n\t\t * only through future extensions.\n\t\t */\n\t\tExt: bcs.vector(bcs.u8()),\n\t},\n});\nexport const MoveCall = new MoveStruct({\n\tname: `${$moduleName}::MoveCall`,\n\tfields: {\n\t\tpackage_id: bcs.string(),\n\t\tmodule_name: bcs.string(),\n\t\tfunction: bcs.string(),\n\t\targuments: bcs.vector(Argument),\n\t\ttype_arguments: bcs.vector(bcs.string()),\n\t},\n});\nexport const TransferObjects = new MoveStruct({\n\tname: `${$moduleName}::TransferObjects`,\n\tfields: {\n\t\tobjects: bcs.vector(Argument),\n\t\tto: Argument,\n\t},\n});\nexport const SplitCoins = new MoveStruct({\n\tname: `${$moduleName}::SplitCoins`,\n\tfields: {\n\t\tcoin: Argument,\n\t\tamounts: bcs.vector(Argument),\n\t},\n});\nexport const MergeCoins = new MoveStruct({\n\tname: `${$moduleName}::MergeCoins`,\n\tfields: {\n\t\tcoin: Argument,\n\t\tcoins: bcs.vector(Argument),\n\t},\n});\nexport const Publish = new MoveStruct({\n\tname: `${$moduleName}::Publish`,\n\tfields: {\n\t\tmodules_bytes: bcs.vector(bcs.vector(bcs.u8())),\n\t\tdependencies: bcs.vector(bcs.Address),\n\t},\n});\nexport const MakeMoveVec = new MoveStruct({\n\tname: `${$moduleName}::MakeMoveVec`,\n\tfields: {\n\t\telement_type: bcs.option(bcs.string()),\n\t\telements: bcs.vector(Argument),\n\t},\n});\nexport const Upgrade = new MoveStruct({\n\tname: `${$moduleName}::Upgrade`,\n\tfields: {\n\t\tmodules_bytes: bcs.vector(bcs.vector(bcs.u8())),\n\t\tdependencies: bcs.vector(bcs.Address),\n\t\tobject_id: bcs.Address,\n\t\tupgrade_ticket: Argument,\n\t},\n});\nexport interface NewOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Create a new Transaction builder. */\nexport function _new(options: NewOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'new',\n\t\t});\n}\nexport interface ClockOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0x6` (Clock). */\nexport function clock(options: ClockOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'clock',\n\t\t});\n}\nexport interface RandomOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0x8` (Random). */\nexport function random(options: RandomOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'random',\n\t\t});\n}\nexport interface DisplayOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0xD` (DisplayRegistry). */\nexport function display(options: DisplayOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'display',\n\t\t});\n}\nexport interface DenyListOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0x403` (DenyList). */\nexport function denyList(options: DenyListOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'deny_list',\n\t\t});\n}\nexport interface CoinRegistryOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0xC` (CoinRegistry). */\nexport function coinRegistry(options: CoinRegistryOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'coin_registry',\n\t\t});\n}\nexport interface AccumulatorRootOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Shorthand for `object_by_id` with `0xACC` (AccumulatorRoot). */\nexport function accumulatorRoot(options: AccumulatorRootOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'accumulator_root',\n\t\t});\n}\nexport interface GasOptions {\n\tpackage?: string;\n\targuments?: [];\n}\n/** Create a gas coin input. */\nexport function gas(options: GasOptions = {}) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'gas',\n\t\t});\n}\nexport interface PureArguments<T extends BcsType<any>> {\n\tvalue: RawTransactionArgument<T>;\n}\nexport interface PureOptions<T extends BcsType<any>> {\n\tpackage?: string;\n\targuments: PureArguments<T> | [value: RawTransactionArgument<T>];\n\ttypeArguments: [string];\n}\n/** Create a pure input. */\nexport function pure<T extends BcsType<any>>(options: PureOptions<T>) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[];\n\tconst parameterNames = ['value'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'pure',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectRefArguments {\n\tobjectId: RawTransactionArgument<string>;\n\tsequenceNumber: RawTransactionArgument<number | bigint>;\n\tdigest: RawTransactionArgument<string>;\n}\nexport interface ObjectRefOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ObjectRefArguments\n\t\t| [\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tsequenceNumber: RawTransactionArgument<number | bigint>,\n\t\t\t\tdigest: RawTransactionArgument<string>,\n\t\t ];\n}\n/**\n * Create a fully-resolved immutable or owned object argument. Should be used with\n * caution, yet for immutable or owned objects refs can be stored. For automatic\n * version resolution, use `object_by_id`.\n */\nexport function objectRef(options: ObjectRefOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x2::object::ID', 'u64', 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['objectId', 'sequenceNumber', 'digest'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'object_ref',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SharedObjectRefArguments {\n\tobjectId: RawTransactionArgument<string>;\n\tinitialSharedVersion: RawTransactionArgument<number | bigint>;\n\tisMutable: RawTransactionArgument<boolean>;\n}\nexport interface SharedObjectRefOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SharedObjectRefArguments\n\t\t| [\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tinitialSharedVersion: RawTransactionArgument<number | bigint>,\n\t\t\t\tisMutable: RawTransactionArgument<boolean>,\n\t\t ];\n}\n/**\n * Create a fully-resolved shared object argument. Should be used with caution, yet\n * for shared objects refs can be stored. For automatic version resolution, use\n * `shared_object_by_id`.\n *\n * TODO: should it be named `consensus_managed_object_ref`? NOTE: the naming is\n * changing elsewhere\n */\nexport function sharedObjectRef(options: SharedObjectRefOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x2::object::ID', 'u64', 'bool'] satisfies (string | null)[];\n\tconst parameterNames = ['objectId', 'initialSharedVersion', 'isMutable'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'shared_object_ref',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ReceivingObjectRefArguments {\n\tobjectId: RawTransactionArgument<string>;\n\tsequenceNumber: RawTransactionArgument<number | bigint>;\n\tdigest: RawTransactionArgument<string>;\n}\nexport interface ReceivingObjectRefOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ReceivingObjectRefArguments\n\t\t| [\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tsequenceNumber: RawTransactionArgument<number | bigint>,\n\t\t\t\tdigest: RawTransactionArgument<string>,\n\t\t ];\n}\n/**\n * Create a fully-resolved receiving object argument. Should be used with caution,\n * since the version of the object is dynamic. For automatic version resolution,\n * use `object_by_id`.\n */\nexport function receivingObjectRef(options: ReceivingObjectRefOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x2::object::ID', 'u64', 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['objectId', 'sequenceNumber', 'digest'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'receiving_object_ref',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ObjectByTypeOptions {\n\tpackage?: string;\n\targuments?: [];\n\ttypeArguments: [string];\n}\n/** Create an off-chain input handler for a given type T. */\nexport function objectByType(options: ObjectByTypeOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'object_by_type',\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ObjectByTypeStringArguments {\n\ttypeName: RawTransactionArgument<string>;\n}\nexport interface ObjectByTypeStringOptions {\n\tpackage?: string;\n\targuments: ObjectByTypeStringArguments | [typeName: RawTransactionArgument<string>];\n}\n/** Create an off-chain input handler for a given type as a String. */\nexport function objectByTypeString(options: ObjectByTypeStringOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['typeName'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'object_by_type_string',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ObjectByIdArguments {\n\tid: RawTransactionArgument<string>;\n}\nexport interface ObjectByIdOptions {\n\tpackage?: string;\n\targuments: ObjectByIdArguments | [id: RawTransactionArgument<string>];\n}\n/** Create an off-chain input handler for an object with a specific ID. */\nexport function objectById(options: ObjectByIdOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[];\n\tconst parameterNames = ['id'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'object_by_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ReceivingObjectByIdArguments {\n\tid: RawTransactionArgument<string>;\n}\nexport interface ReceivingObjectByIdOptions {\n\tpackage?: string;\n\targuments: ReceivingObjectByIdArguments | [id: RawTransactionArgument<string>];\n}\n/** Create an off-chain input handler for a receiving object with a specific ID. */\nexport function receivingObjectById(options: ReceivingObjectByIdOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[];\n\tconst parameterNames = ['id'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'receiving_object_by_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ExtInputArguments {\n\tname: RawTransactionArgument<string>;\n}\nexport interface ExtInputOptions {\n\tpackage?: string;\n\targuments: ExtInputArguments | [name: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Create an external input handler. Expected to be understood by the off-chain\n * tooling.\n */\nexport function extInput(options: ExtInputOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['name'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'ext_input',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ExtInputRawArguments {\n\tnamespace: RawTransactionArgument<string>;\n\tname: RawTransactionArgument<string>;\n}\nexport interface ExtInputRawOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ExtInputRawArguments\n\t\t| [namespace: RawTransactionArgument<string>, name: RawTransactionArgument<string>];\n}\n/**\n * Create an external input handler for a given type T. This can be used to\n * hardcode the namespace value without having access to `T`.\n */\nexport function extInputRaw(options: ExtInputRawOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x1::string::String', '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['namespace', 'name'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'ext_input_raw',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface CommandArguments {\n\tself: RawTransactionArgument<string>;\n\tcommand: RawTransactionArgument<string>;\n}\nexport interface CommandOptions {\n\tpackage?: string;\n\targuments:\n\t\t| CommandArguments\n\t\t| [self: RawTransactionArgument<string>, command: RawTransactionArgument<string>];\n}\n/**\n * Register a command in the Transaction builder. Returns the Argument, which is\n * treated as the `Result(idx)` of the command, and can be turned into a nested\n * result `NestedResult(idx, idx)`.\n */\nexport function command(options: CommandOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'command'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'command',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NestedArguments {\n\tself: RawTransactionArgument<string>;\n\tsubIdx: RawTransactionArgument<number>;\n}\nexport interface NestedOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NestedArguments\n\t\t| [self: RawTransactionArgument<string>, subIdx: RawTransactionArgument<number>];\n}\n/**\n * Spawn a nested result out of a (just) `Result`. Simple result is a command\n * output.\n */\nexport function nested(options: NestedOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [null, 'u16'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'subIdx'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'nested',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface MoveCallArguments {\n\tpackageId: RawTransactionArgument<string>;\n\tmoduleName: RawTransactionArgument<string>;\n\tfunction: RawTransactionArgument<string>;\n\targuments: RawTransactionArgument<string[]>;\n\ttypeArguments: RawTransactionArgument<string[]>;\n}\nexport interface MoveCallOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MoveCallArguments\n\t\t| [\n\t\t\t\tpackageId: RawTransactionArgument<string>,\n\t\t\t\tmoduleName: RawTransactionArgument<string>,\n\t\t\t\tfunction: RawTransactionArgument<string>,\n\t\t\t\targuments: RawTransactionArgument<string[]>,\n\t\t\t\ttypeArguments: RawTransactionArgument<string[]>,\n\t\t ];\n}\n/** Create a `MoveCall` command. */\nexport function moveCall(options: MoveCallOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [\n\t\t'0x1::string::String',\n\t\t'0x1::string::String',\n\t\t'0x1::string::String',\n\t\t'vector<null>',\n\t\t'vector<0x1::string::String>',\n\t] satisfies (string | null)[];\n\tconst parameterNames = ['packageId', 'moduleName', 'function', 'arguments', 'typeArguments'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'move_call',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TransferObjectsArguments {\n\tobjects: RawTransactionArgument<string[]>;\n\tto: RawTransactionArgument<string>;\n}\nexport interface TransferObjectsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| TransferObjectsArguments\n\t\t| [objects: RawTransactionArgument<string[]>, to: RawTransactionArgument<string>];\n}\n/**\n * Create a `TransferObjects` command Expects a vector of arguments to transfer and\n * an address value for destination.\n */\nexport function transferObjects(options: TransferObjectsOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['vector<null>', null] satisfies (string | null)[];\n\tconst parameterNames = ['objects', 'to'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'transfer_objects',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SplitCoinsArguments {\n\tcoin: RawTransactionArgument<string>;\n\tamounts: RawTransactionArgument<string[]>;\n}\nexport interface SplitCoinsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SplitCoinsArguments\n\t\t| [coin: RawTransactionArgument<string>, amounts: RawTransactionArgument<string[]>];\n}\n/** Create a `SplitCoins` command. */\nexport function splitCoins(options: SplitCoinsOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [null, 'vector<null>'] satisfies (string | null)[];\n\tconst parameterNames = ['coin', 'amounts'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'split_coins',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface MergeCoinsArguments {\n\tcoin: RawTransactionArgument<string>;\n\tcoins: RawTransactionArgument<string[]>;\n}\nexport interface MergeCoinsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MergeCoinsArguments\n\t\t| [coin: RawTransactionArgument<string>, coins: RawTransactionArgument<string[]>];\n}\n/**\n * Create a `MergeCoins` command. Takes a Coin Argument and a vector of other coin\n * arguments to merge into it.\n */\nexport function mergeCoins(options: MergeCoinsOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [null, 'vector<null>'] satisfies (string | null)[];\n\tconst parameterNames = ['coin', 'coins'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'merge_coins',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface PublishArguments {\n\tmodulesBytes: RawTransactionArgument<number[][]>;\n\tdependencies: RawTransactionArgument<string[]>;\n}\nexport interface PublishOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PublishArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<number[][]>,\n\t\t\t\tdependencies: RawTransactionArgument<string[]>,\n\t\t ];\n}\n/**\n * Create a `Publish` command. Takes a vector of modules' bytes and a vector of\n * dependencies.\n */\nexport function publish(options: PublishOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['vector<vector<u8>>', 'vector<0x2::object::ID>'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = ['modulesBytes', 'dependencies'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'publish',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface MakeMoveVecArguments {\n\telementType: RawTransactionArgument<string | null>;\n\telements: RawTransactionArgument<string[]>;\n}\nexport interface MakeMoveVecOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MakeMoveVecArguments\n\t\t| [\n\t\t\t\telementType: RawTransactionArgument<string | null>,\n\t\t\t\telements: RawTransactionArgument<string[]>,\n\t\t ];\n}\n/**\n * Create a `MakeMoveVec` command. Takes an optional element type and a vector of\n * elements to make into a vector.\n */\nexport function makeMoveVec(options: MakeMoveVecOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['0x1::option::Option<0x1::string::String>', 'vector<null>'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = ['elementType', 'elements'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'make_move_vec',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface UpgradeArguments {\n\tmodulesBytes: RawTransactionArgument<number[][]>;\n\tdependencies: RawTransactionArgument<string[]>;\n\tobjectId: RawTransactionArgument<string>;\n\tupgradeTicket: RawTransactionArgument<string>;\n}\nexport interface UpgradeOptions {\n\tpackage?: string;\n\targuments:\n\t\t| UpgradeArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<number[][]>,\n\t\t\t\tdependencies: RawTransactionArgument<string[]>,\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tupgradeTicket: RawTransactionArgument<string>,\n\t\t ];\n}\n/**\n * Create a `Upgrade` command. Takes a vector of modules' bytes, a vector of\n * dependencies, an updated package ID, and an upgrade ticket.\n */\nexport function upgrade(options: UpgradeOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = [\n\t\t'vector<vector<u8>>',\n\t\t'vector<0x2::object::ID>',\n\t\t'0x2::object::ID',\n\t\tnull,\n\t] satisfies (string | null)[];\n\tconst parameterNames = ['modulesBytes', 'dependencies', 'objectId', 'upgradeTicket'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'upgrade',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ExtArguments {\n\tdata: RawTransactionArgument<number[]>;\n}\nexport interface ExtOptions {\n\tpackage?: string;\n\targuments: ExtArguments | [data: RawTransactionArgument<number[]>];\n}\n/** Create an `Ext` command. */\nexport function ext(options: ExtOptions) {\n\tconst packageAddress = options.package ?? '@mysten/ptb';\n\tconst argumentsTypes = ['vector<u8>'] satisfies (string | null)[];\n\tconst parameterNames = ['data'];\n\treturn (tx: Transaction_1) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'ptb',\n\t\t\tfunction: 'ext',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,cAAc;AACpB,MAAa,UAAU,IAAI,UAAU;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ,CAAC,IAAI,IAAI,EAAE,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC;CACxC,CAAC;AACF,MAAa,cAAc,IAAI,WAAW;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,UAAU,IAAI,OAAO,QAAQ,EAC7B;CACD,CAAC;;;;;;;;;AASF,MAAa,YAAY,IAAI,SAAS;CACrC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,kBAAkB,IAAI,WAAW;GAChC,MAAM;GACN,QAAQ;IACP,WAAW,IAAI;IACf,iBAAiB,IAAI,KAAK;IAC1B,QAAQ,IAAI;IACZ;GACD,CAAC;EACF,cAAc,IAAI,WAAW;GAC5B,MAAM;GACN,QAAQ;IACP,WAAW,IAAI;IACf,wBAAwB,IAAI,KAAK;IACjC,YAAY,IAAI,MAAM;IACtB;GACD,CAAC;EACF,WAAW,IAAI,WAAW;GACzB,MAAM;GACN,QAAQ;IACP,WAAW,IAAI;IACf,iBAAiB,IAAI,KAAK;IAC1B,QAAQ,IAAI;IACZ;GACD,CAAC;EACF,KAAK,IAAI,QAAQ;EACjB;CACD,CAAC;AACF,MAAa,eAAe,IAAI,SAAS;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,QAAQ;EACR,SAAS;EACT;CACD,CAAC;;;;;;;;;;AAUF,MAAa,UAAU,IAAI,SAAS;CACnC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,MAAM,IAAI,OAAO,IAAI,IAAI,CAAC;EAC1B,QAAQ;EACR,iBAAiB,IAAI,WAAW;GAC/B,MAAM;GACN,QAAQ;IACP,QAAQ,IAAI,KAAK;IACjB,WAAW,IAAI,QAAQ;IACvB,eAAe;IACf;GACD,CAAC;EASF,KAAK,IAAI,UAAU;GAAE,MAAM;GAAe,QAAQ,CAAC,IAAI,QAAQ,EAAE,IAAI,QAAQ,CAAC;GAAE,CAAC;EACjF;CACD,CAAC;;AAEF,MAAa,WAAW,IAAI,SAAS;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,SAAS;EACT,OAAO;EACP,QAAQ,IAAI,KAAK;EACjB,cAAc,IAAI,UAAU;GAAE,MAAM;GAAyB,QAAQ,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,CAAC;GAAE,CAAC;EAK9F,KAAK,IAAI,OAAO,IAAI,IAAI,CAAC;EACzB;CACD,CAAC;AACF,MAAa,WAAW,IAAI,WAAW;CACtC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,YAAY,IAAI,QAAQ;EACxB,aAAa,IAAI,QAAQ;EACzB,UAAU,IAAI,QAAQ;EACtB,WAAW,IAAI,OAAO,SAAS;EAC/B,gBAAgB,IAAI,OAAO,IAAI,QAAQ,CAAC;EACxC;CACD,CAAC;AACF,MAAa,kBAAkB,IAAI,WAAW;CAC7C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,SAAS,IAAI,OAAO,SAAS;EAC7B,IAAI;EACJ;CACD,CAAC;AACF,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,MAAM;EACN,SAAS,IAAI,OAAO,SAAS;EAC7B;CACD,CAAC;AACF,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,MAAM;EACN,OAAO,IAAI,OAAO,SAAS;EAC3B;CACD,CAAC;AACF,MAAa,UAAU,IAAI,WAAW;CACrC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,eAAe,IAAI,OAAO,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC;EAC/C,cAAc,IAAI,OAAO,IAAI,QAAQ;EACrC;CACD,CAAC;AACF,MAAa,cAAc,IAAI,WAAW;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,cAAc,IAAI,OAAO,IAAI,QAAQ,CAAC;EACtC,UAAU,IAAI,OAAO,SAAS;EAC9B;CACD,CAAC;AACF,MAAa,UAAU,IAAI,WAAW;CACrC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,eAAe,IAAI,OAAO,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC;EAC/C,cAAc,IAAI,OAAO,IAAI,QAAQ;EACrC,WAAW,IAAI;EACf,gBAAgB;EAChB;CACD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { MoveStruct } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/sui/dynamic_field.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ const $moduleName = "0x2::dynamic_field";
9
+ function Field(...typeParameters) {
10
+ return new MoveStruct({
11
+ name: `${$moduleName}::Field<${typeParameters[0].name}, ${typeParameters[1].name}>`,
12
+ fields: {
13
+ id: bcs.Address,
14
+ name: typeParameters[0],
15
+ value: typeParameters[1]
16
+ }
17
+ });
18
+ }
19
+
20
+ //#endregion
21
+ export { Field };
22
+ //# sourceMappingURL=dynamic_field.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic_field.mjs","names":[],"sources":["../../../src/contracts/sui/dynamic_field.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { type BcsType, bcs } from '@mysten/sui/bcs';\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '0x2::dynamic_field';\nexport function Field<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Field<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tid: bcs.Address,\n\t\t\tname: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport interface AddOptions<T0 extends BcsType<any>, T1 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<T0>,\n\t\tRawTransactionArgument<T1>,\n\t];\n\ttypeArguments: [string, string];\n}\nexport function add<T0 extends BcsType<any>, T1 extends BcsType<any>>(options: AddOptions<T0, T1>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = [\n\t\t'0x2::object::ID',\n\t\t`${options.typeArguments[0]}`,\n\t\t`${options.typeArguments[1]}`,\n\t] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface BorrowOptions<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string, string];\n}\nexport function borrow<T0 extends BcsType<any>>(options: BorrowOptions<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'borrow',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface BorrowMutOptions<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string, string];\n}\nexport function borrowMut<T0 extends BcsType<any>>(options: BorrowMutOptions<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'borrow_mut',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RemoveOptions<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string, string];\n}\nexport function remove<T0 extends BcsType<any>>(options: RemoveOptions<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'remove',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface Exists_Options<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string];\n}\nexport function exists_<T0 extends BcsType<any>>(options: Exists_Options<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'exists_',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RemoveIfExistsOptions<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string, string];\n}\nexport function removeIfExists<T0 extends BcsType<any>>(options: RemoveIfExistsOptions<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'remove_if_exists',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ExistsWithTypeOptions<T0 extends BcsType<any>> {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];\n\ttypeArguments: [string, string];\n}\nexport function existsWithType<T0 extends BcsType<any>>(options: ExistsWithTypeOptions<T0>) {\n\tconst packageAddress =\n\t\toptions.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';\n\tconst argumentsTypes = ['0x2::object::ID', `${options.typeArguments[0]}`] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'dynamic_field',\n\t\t\tfunction: 'exists_with_type',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;AACD,QAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,GAAG,KAAmB,IAAI,eAAe,GAAG,KAAmB;EAC7G,QAAQ;GACP,IAAI,IAAI;GACR,MAAM,eAAe;GACrB,OAAO,eAAe;GACtB;EACD,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { BcsEnum, BcsStruct, BcsTuple, bcs } from "@mysten/sui/bcs";
2
+ import { normalizeSuiAddress } from "@mysten/sui/utils";
3
+ import "@mysten/sui/transactions";
4
+
5
+ //#region src/contracts/utils/index.ts
6
+ const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
7
+ const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
8
+ var MoveStruct = class extends BcsStruct {
9
+ async get({ objectId, ...options }) {
10
+ const [res] = await this.getMany({
11
+ ...options,
12
+ objectIds: [objectId]
13
+ });
14
+ return res;
15
+ }
16
+ async getMany({ client, ...options }) {
17
+ return (await client.core.getObjects({
18
+ ...options,
19
+ include: {
20
+ ...options.include,
21
+ content: true
22
+ }
23
+ })).objects.map((obj) => {
24
+ if (obj instanceof Error) throw obj;
25
+ return {
26
+ ...obj,
27
+ json: this.parse(obj.content)
28
+ };
29
+ });
30
+ }
31
+ };
32
+ var MoveEnum = class extends BcsEnum {};
33
+ var MoveTuple = class extends BcsTuple {};
34
+
35
+ //#endregion
36
+ export { MoveEnum, MoveStruct, MoveTuple };
37
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsType,\n\tTypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport { PASClientError } from '../../error.js';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport interface GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport interface GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectsOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]);\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new PASClientError(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new PASClientError(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new PASClientError(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new PASClientError(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i];\n\t\tconst bcsType = type === null ? null : getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new PASClientError(`Invalid argument ${stringify(arg)} for type ${type}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAcA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAqJxD,IAAa,aAAb,cAGU,UAAmB;CAC5B,MAAM,IAAiF,EACtF,UACA,GAAG,WAKF;EACD,MAAM,CAAC,OAAO,MAAM,KAAK,QAAiB;GACzC,GAAG;GACH,WAAW,CAAC,SAAS;GACrB,CAAC;AAEF,SAAO;;CAGR,MAAM,QAAqF,EAC1F,QACA,GAAG,WAOF;AASD,UARkB,MAAM,OAAO,KAAK,WAAW;GAC9C,GAAG;GACH,SAAS;IACR,GAAG,QAAQ;IACX,SAAS;IACT;GACD,CAAC,EAEc,QAAQ,KAAK,QAAQ;AACpC,OAAI,eAAe,MAClB,OAAM;AAGP,UAAO;IACN,GAAG;IACH,MAAM,KAAK,MAAM,IAAI,QAAQ;IAC7B;IACA;;;AAIJ,IAAa,WAAb,cAGU,QAAiB;AAE3B,IAAa,YAAb,cAGU,SAAkB"}
@@ -0,0 +1,70 @@
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { deriveDynamicFieldID, deriveObjectID, normalizeSuiAddress } from "@mysten/sui/utils";
3
+
4
+ //#region src/derivation.ts
5
+ /**
6
+ * Derives the account address for a given owner address.
7
+ *
8
+ * Accounts are derived using the namespace UID and a AccountKey(owner).
9
+ * The key structure in Move is: `AccountKey(address)`
10
+ *
11
+ * @param owner - The owner address (can be a user address or object address)
12
+ * @param packageConfig - PAS package configuration
13
+ * @returns The derived account object ID
14
+ */
15
+ function deriveAccountAddress(owner, packageConfig) {
16
+ const { packageId, namespaceId } = packageConfig;
17
+ const key = bcs.struct("AccountKey", { owner: bcs.Address }).serialize({ owner: normalizeSuiAddress(owner) }).toBytes();
18
+ return deriveObjectID(namespaceId, `${packageId}::keys::AccountKey`, key);
19
+ }
20
+ const DEFAULT_WRAP_TYPE = (t) => `0x2::balance::Balance<${t}>`;
21
+ /**
22
+ * Derives the policy address for a given asset type T.
23
+ *
24
+ * Policies are derived using the namespace UID and a PolicyKey<T>().
25
+ * The key structure in Move is: `PolicyKey<phantom T>()`
26
+ *
27
+ * By default the asset type is wrapped as `Balance<T>` to match the current
28
+ * on-chain convention. Pass `options.wrapType` to override.
29
+ *
30
+ * @param assetType - The full type of the asset (e.g., "0x2::sui::SUI")
31
+ * @param packageConfig - PAS package configuration
32
+ * @param options - Optional derivation options
33
+ * @returns The derived policy object ID
34
+ */
35
+ function derivePolicyAddress(assetType, packageConfig, options) {
36
+ const { packageId, namespaceId } = packageConfig;
37
+ const policyKeyBcs = new Uint8Array([0]);
38
+ return deriveObjectID(namespaceId, `${packageId}::keys::PolicyKey<${(options?.wrapType ?? DEFAULT_WRAP_TYPE)(assetType)}>`, policyKeyBcs);
39
+ }
40
+ /**
41
+ * Derives the templates object address for a given package configuration.
42
+ *
43
+ * Templates are derived using the namespace UID and a TemplateKey().
44
+ * The key structure in Move is: `TemplateKey()`
45
+ *
46
+ * @param packageConfig - PAS package configuration
47
+ * @returns The derived templates object ID
48
+ */
49
+ function deriveTemplateRegistryAddress(packageConfig) {
50
+ const { packageId, namespaceId } = packageConfig;
51
+ return deriveObjectID(namespaceId, `${packageId}::keys::TemplateKey`, new Uint8Array([0]));
52
+ }
53
+ /**
54
+ * Derives the dynamic field address for a template command on the Templates object.
55
+ *
56
+ * Templates store Commands as dynamic fields keyed by `TypeName` (the approval type's
57
+ * `type_name::with_defining_ids` value). The DF key type is `std::type_name::TypeName`
58
+ * which is a struct with a single `name: String` field.
59
+ *
60
+ * @param templatesId - The Templates object ID
61
+ * @param approvalTypeName - The fully qualified approval type name (e.g., "0x123::demo_usd::TransferApproval")
62
+ * @returns The derived dynamic field object ID
63
+ */
64
+ function deriveTemplateAddress(templatesId, approvalTypeName) {
65
+ return deriveDynamicFieldID(templatesId, "0x1::type_name::TypeName", bcs.string().serialize(approvalTypeName).toBytes());
66
+ }
67
+
68
+ //#endregion
69
+ export { deriveAccountAddress, derivePolicyAddress, deriveTemplateAddress, deriveTemplateRegistryAddress };
70
+ //# sourceMappingURL=derivation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivation.mjs","names":[],"sources":["../src/derivation.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { deriveDynamicFieldID, deriveObjectID, normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport type { PASPackageConfig } from './types.js';\n\n/**\n * Derives the account address for a given owner address.\n *\n * Accounts are derived using the namespace UID and a AccountKey(owner).\n * The key structure in Move is: `AccountKey(address)`\n *\n * @param owner - The owner address (can be a user address or object address)\n * @param packageConfig - PAS package configuration\n * @returns The derived account object ID\n */\nexport function deriveAccountAddress(owner: string, packageConfig: PASPackageConfig): string {\n\tconst { packageId, namespaceId } = packageConfig;\n\n\t// Serialize the AccountKey(address) as the key\n\t// AccountKey is a struct with a single field: address\n\tconst accountKeyBcs = bcs.struct('AccountKey', {\n\t\towner: bcs.Address,\n\t});\n\n\tconst key = accountKeyBcs.serialize({ owner: normalizeSuiAddress(owner) }).toBytes();\n\n\t// The type tag is the AccountKey type from the PAS package\n\tconst typeTag = `${packageId}::keys::AccountKey`;\n\n\treturn deriveObjectID(namespaceId, typeTag, key);\n}\n\nconst DEFAULT_WRAP_TYPE = (t: string) => `0x2::balance::Balance<${t}>`;\n\nexport interface DerivePolicyOptions {\n\t/** Transform the asset type before using it in the PolicyKey type tag.\n\t * Defaults to wrapping with `0x2::balance::Balance<T>`.\n\t * Pass `(t) => t` to use the raw type. */\n\twrapType?: (assetType: string) => string;\n}\n\n/**\n * Derives the policy address for a given asset type T.\n *\n * Policies are derived using the namespace UID and a PolicyKey<T>().\n * The key structure in Move is: `PolicyKey<phantom T>()`\n *\n * By default the asset type is wrapped as `Balance<T>` to match the current\n * on-chain convention. Pass `options.wrapType` to override.\n *\n * @param assetType - The full type of the asset (e.g., \"0x2::sui::SUI\")\n * @param packageConfig - PAS package configuration\n * @param options - Optional derivation options\n * @returns The derived policy object ID\n */\nexport function derivePolicyAddress(\n\tassetType: string,\n\tpackageConfig: PASPackageConfig,\n\toptions?: DerivePolicyOptions,\n): string {\n\tconst { packageId, namespaceId } = packageConfig;\n\n\tconst policyKeyBcs = new Uint8Array([0]);\n\n\tconst wrap = options?.wrapType ?? DEFAULT_WRAP_TYPE;\n\tconst typeTag = `${packageId}::keys::PolicyKey<${wrap(assetType)}>`;\n\treturn deriveObjectID(namespaceId, typeTag, policyKeyBcs);\n}\n\n/**\n * Derives the templates object address for a given package configuration.\n *\n * Templates are derived using the namespace UID and a TemplateKey().\n * The key structure in Move is: `TemplateKey()`\n *\n * @param packageConfig - PAS package configuration\n * @returns The derived templates object ID\n */\nexport function deriveTemplateRegistryAddress(packageConfig: PASPackageConfig): string {\n\tconst { packageId, namespaceId } = packageConfig;\n\n\t// The type tag is the TemplateKey type from the PAS package\n\tconst typeTag = `${packageId}::keys::TemplateKey`;\n\n\treturn deriveObjectID(namespaceId, typeTag, new Uint8Array([0]));\n}\n\n/**\n * Derives the dynamic field address for a template command on the Templates object.\n *\n * Templates store Commands as dynamic fields keyed by `TypeName` (the approval type's\n * `type_name::with_defining_ids` value). The DF key type is `std::type_name::TypeName`\n * which is a struct with a single `name: String` field.\n *\n * @param templatesId - The Templates object ID\n * @param approvalTypeName - The fully qualified approval type name (e.g., \"0x123::demo_usd::TransferApproval\")\n * @returns The derived dynamic field object ID\n */\nexport function deriveTemplateAddress(templatesId: string, approvalTypeName: string): string {\n\t// TypeName is a struct { name: String }, serialized as BCS string\n\tconst key = bcs.string().serialize(approvalTypeName).toBytes();\n\n\treturn deriveDynamicFieldID(templatesId, '0x1::type_name::TypeName', key);\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,qBAAqB,OAAe,eAAyC;CAC5F,MAAM,EAAE,WAAW,gBAAgB;CAQnC,MAAM,MAJgB,IAAI,OAAO,cAAc,EAC9C,OAAO,IAAI,SACX,CAAC,CAEwB,UAAU,EAAE,OAAO,oBAAoB,MAAM,EAAE,CAAC,CAAC,SAAS;AAKpF,QAAO,eAAe,aAFN,GAAG,UAAU,qBAEe,IAAI;;AAGjD,MAAM,qBAAqB,MAAc,yBAAyB,EAAE;;;;;;;;;;;;;;;AAuBpE,SAAgB,oBACf,WACA,eACA,SACS;CACT,MAAM,EAAE,WAAW,gBAAgB;CAEnC,MAAM,eAAe,IAAI,WAAW,CAAC,EAAE,CAAC;AAIxC,QAAO,eAAe,aADN,GAAG,UAAU,qBADhB,SAAS,YAAY,mBACoB,UAAU,CAAC,IACrB,aAAa;;;;;;;;;;;AAY1D,SAAgB,8BAA8B,eAAyC;CACtF,MAAM,EAAE,WAAW,gBAAgB;AAKnC,QAAO,eAAe,aAFN,GAAG,UAAU,sBAEe,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;AAcjE,SAAgB,sBAAsB,aAAqB,kBAAkC;AAI5F,QAAO,qBAAqB,aAAa,4BAF7B,IAAI,QAAQ,CAAC,UAAU,iBAAiB,CAAC,SAAS,CAEW"}
@@ -0,0 +1,16 @@
1
+ //#region src/error.d.ts
2
+ /**
3
+ * Base error class for PAS client errors
4
+ */
5
+ declare class PASClientError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ declare class PolicyNotFoundError extends PASClientError {
9
+ constructor(assetType: string, message?: string);
10
+ }
11
+ declare class InvalidObjectOwnershipError extends PASClientError {
12
+ constructor(objectId: string, ownerKind: string);
13
+ }
14
+ //#endregion
15
+ export { InvalidObjectOwnershipError, PASClientError, PolicyNotFoundError };
16
+ //# sourceMappingURL=error.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.mts","names":[],"sources":["../src/error.ts"],"sourcesContent":[],"mappings":";;AAMA;AAOA;AAOa,cAdA,cAAA,SAAuB,KAAA,CAca;;;cAPpC,mBAAA,SAA4B,cAAA;;;cAO5B,2BAAA,SAAoC,cAAA"}
package/dist/error.mjs ADDED
@@ -0,0 +1,26 @@
1
+ //#region src/error.ts
2
+ /**
3
+ * Base error class for PAS client errors
4
+ */
5
+ var PASClientError = class extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "PASClientError";
9
+ }
10
+ };
11
+ var PolicyNotFoundError = class extends PASClientError {
12
+ constructor(assetType, message) {
13
+ super(message ?? `Policy not found for asset type ${assetType}.`);
14
+ this.name = "PolicyNotFoundError";
15
+ }
16
+ };
17
+ var InvalidObjectOwnershipError = class extends PASClientError {
18
+ constructor(objectId, ownerKind) {
19
+ super(`Object ${objectId} has ownership kind "${ownerKind}" which is not allowed in PAS templates. Only shared and immutable objects can be referenced by templates.`);
20
+ this.name = "InvalidObjectOwnershipError";
21
+ }
22
+ };
23
+
24
+ //#endregion
25
+ export { InvalidObjectOwnershipError, PASClientError, PolicyNotFoundError };
26
+ //# sourceMappingURL=error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.mjs","names":[],"sources":["../src/error.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Base error class for PAS client errors\n */\nexport class PASClientError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'PASClientError';\n\t}\n}\n\nexport class PolicyNotFoundError extends PASClientError {\n\tconstructor(assetType: string, message?: string) {\n\t\tsuper(message ?? `Policy not found for asset type ${assetType}.`);\n\t\tthis.name = 'PolicyNotFoundError';\n\t}\n}\n\nexport class InvalidObjectOwnershipError extends PASClientError {\n\tconstructor(objectId: string, ownerKind: string) {\n\t\tsuper(\n\t\t\t`Object ${objectId} has ownership kind \"${ownerKind}\" which is not allowed in PAS templates. ` +\n\t\t\t\t`Only shared and immutable objects can be referenced by templates.`,\n\t\t);\n\t\tthis.name = 'InvalidObjectOwnershipError';\n\t}\n}\n"],"mappings":";;;;AAMA,IAAa,iBAAb,cAAoC,MAAM;CACzC,YAAY,SAAiB;AAC5B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAId,IAAa,sBAAb,cAAyC,eAAe;CACvD,YAAY,WAAmB,SAAkB;AAChD,QAAM,WAAW,mCAAmC,UAAU,GAAG;AACjE,OAAK,OAAO;;;AAId,IAAa,8BAAb,cAAiD,eAAe;CAC/D,YAAY,UAAkB,WAAmB;AAChD,QACC,UAAU,SAAS,uBAAuB,UAAU,4GAEpD;AACD,OAAK,OAAO"}
@@ -0,0 +1,4 @@
1
+ import { PASClientConfig, PASOptions, PASPackageConfig } from "./types.mjs";
2
+ import { PASClient, pas } from "./client.mjs";
3
+ import { InvalidObjectOwnershipError, PASClientError, PolicyNotFoundError } from "./error.mjs";
4
+ export { InvalidObjectOwnershipError, PASClient, type PASClientConfig, PASClientError, type PASOptions, type PASPackageConfig, PolicyNotFoundError, pas };
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { InvalidObjectOwnershipError, PASClientError, PolicyNotFoundError } from "./error.mjs";
2
+ import { PASClient, pas } from "./client.mjs";
3
+
4
+ export { InvalidObjectOwnershipError, PASClient, PASClientError, PolicyNotFoundError, pas };