@mysten/pas 0.1.3 → 0.2.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @mysten/pas
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bbf63cb: Add `typeTag` and `resolveTypeTag` methods to the generated `MoveStruct`, `MoveEnum`, and
8
+ `MoveTuple` classes.
9
+
10
+ - `typeTag(options?)` builds the type tag string for a generated type. `typeArguments` is the full
11
+ positional list of type arguments in Move declaration order; each entry is a type tag string,
12
+ another `typeTag()` result, or a BCS type (its name is used). Types with unfilled phantom
13
+ parameters require `typeArguments` at compile time, and argument arity is validated at runtime.
14
+ - `resolveTypeTag({ client, ... })` builds the tag, resolves MVR names through
15
+ `client.core.mvr.resolveType`, and returns the normalized address-only form suitable for queries
16
+ and comparisons against on-chain data.
17
+
18
+ - bbf63cb: Updated dependencies
19
+
20
+ ## 0.1.4
21
+
22
+ ### Patch Changes
23
+
24
+ - ca17d58: Add mainnet constants
25
+
3
26
  ## 0.1.3
4
27
 
5
28
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;iBAqBgB,GAAA,mCAAA,CAAA;EACf,aAAA;EACA,IAAA;EAAA,GACG;AAAA,IACD,UAAA,CAAW,IAAA;EACb,IAAA,EAAM,IAAA;EACN,QAAA,GAAW,MAAA,EAAQ,iBAAA,KAAsB,SAAA;AAAA;AAAA,cAS7B,SAAA;EAAA;cAGA,MAAA,EAAQ,eAAA;EAhBpB;;;EAgDA,gBAAA,CAAA,GAAgB,gBAAA;EA5CG;;;;;;EAsDnB,oBAAA,CAAqB,KAAA;EA1DrB;;;;;;;EAqEA,mBAAA,CAAoB,SAAA;EAjED;;;;;EA0EnB,6BAAA,CAAA;EAjEqB;;;;;;EA2ErB,qBAAA,CAAsB,gBAAA;;;;;;MASlB,IAAA,CAAA;;;;;;;;;;;;;;;;;;eAjDY,yBAAA,CAAA,WAAA"}
1
+ {"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;iBAqBgB,GAAA,mCAAA,CAAA;EACf,aAAA;EACA,IAAA;EAAA,GACG;AAAA,IACD,UAAA,CAAW,IAAA;EACb,IAAA,EAAM,IAAA;EACN,QAAA,GAAW,MAAA,EAAQ,iBAAA,KAAsB,SAAA;AAAA;AAAA,cAS7B,SAAA;EAAA;cAGA,MAAA,EAAQ,eAAA;EAhBpB;;;EA4CA,gBAAA,CAAA,GAAgB,gBAAA;EAxCG;;;;;;EAkDnB,oBAAA,CAAqB,KAAA;EAtDrB;;;;;;;EAiEA,mBAAA,CAAoB,SAAA;EA7DD;;;;;EAsEnB,6BAAA,CAAA;EA7DqB;;;;;;EAuErB,qBAAA,CAAsB,gBAAA;;;;;;MASlB,IAAA,CAAA;;;;;;;;;;;;;;;;;;eAjDY,yBAAA,CAAA,WAAA"}
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { TESTNET_PAS_PACKAGE_CONFIG } from "./constants.mjs";
1
+ import { MAINNET_PAS_PACKAGE_CONFIG, TESTNET_PAS_PACKAGE_CONFIG } from "./constants.mjs";
2
2
  import { deriveAccountAddress, derivePolicyAddress, deriveTemplateAddress, deriveTemplateRegistryAddress } from "./derivation.mjs";
3
3
  import { PASClientError } from "./error.mjs";
4
4
  import { accountForAddressIntent, sendBalanceIntent, unlockBalanceIntent, unlockUnrestrictedBalanceIntent } from "./intents.mjs";
@@ -24,8 +24,7 @@ var PASClient = class {
24
24
  return;
25
25
  }
26
26
  if (!network || network !== "mainnet" && network !== "testnet") throw new PASClientError("PAS client requires a known network (mainnet, testnet) or a custom package configuration.");
27
- if (network === "mainnet") throw new PASClientError("Mainnet is not supported yet.");
28
- this.#packageConfig = TESTNET_PAS_PACKAGE_CONFIG;
27
+ this.#packageConfig = network === "mainnet" ? MAINNET_PAS_PACKAGE_CONFIG : TESTNET_PAS_PACKAGE_CONFIG;
29
28
  }
30
29
  /**
31
30
  * Get the package configuration
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","names":["#packageConfig"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ClientWithCoreApi } from '@mysten/sui/client';\n\nimport { TESTNET_PAS_PACKAGE_CONFIG } from './constants.js';\nimport {\n\tderiveAccountAddress,\n\tderivePolicyAddress,\n\tderiveTemplateAddress,\n\tderiveTemplateRegistryAddress,\n} from './derivation.js';\nimport { PASClientError } from './error.js';\nimport {\n\taccountForAddressIntent,\n\tsendBalanceIntent,\n\tunlockBalanceIntent,\n\tunlockUnrestrictedBalanceIntent,\n} from './intents.js';\nimport type { PASClientConfig, PASOptions, PASPackageConfig } from './types.js';\n\nexport function pas<const Name extends string = 'pas'>({\n\tpackageConfig,\n\tname = 'pas' as Name,\n\t...options\n}: PASOptions<Name> = {}): {\n\tname: Name;\n\tregister: (client: ClientWithCoreApi) => PASClient;\n} {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) =>\n\t\t\tnew PASClient({ packageConfig, suiClient: client, ...options }),\n\t};\n}\n\nexport class PASClient {\n\t#packageConfig: PASPackageConfig;\n\n\tconstructor(config: PASClientConfig) {\n\t\tconst network = config.suiClient.network;\n\n\t\t// Mainnet: no custom config allowed (avoid accidental republishing).\n\t\tif (network === 'mainnet' && config.packageConfig) {\n\t\t\tthrow new PASClientError(\n\t\t\t\t'Custom package configuration is not allowed on mainnet. Use the built-in mainnet config when mainnet is supported.',\n\t\t\t);\n\t\t}\n\n\t\tif (config.packageConfig) {\n\t\t\tthis.#packageConfig = config.packageConfig;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!network || (network !== 'mainnet' && network !== 'testnet')) {\n\t\t\tthrow new PASClientError(\n\t\t\t\t'PAS client requires a known network (mainnet, testnet) or a custom package configuration.',\n\t\t\t);\n\t\t}\n\n\t\t// TODO: Remove when we add mainnet data\n\t\tif (network === 'mainnet') {\n\t\t\tthrow new PASClientError('Mainnet is not supported yet.');\n\t\t}\n\n\t\tthis.#packageConfig = TESTNET_PAS_PACKAGE_CONFIG;\n\t}\n\n\t/**\n\t * Get the package configuration\n\t */\n\tgetPackageConfig() {\n\t\treturn this.#packageConfig;\n\t}\n\n\t/**\n\t * Derives the account address for a given owner address.\n\t *\n\t * @param owner - The owner address (can be a user address or object address)\n\t * @returns The derived account object ID\n\t */\n\tderiveAccountAddress(owner: string): string {\n\t\treturn deriveAccountAddress(owner, this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the policy address for a given asset type T.\n\t * By default wraps with `Balance<T>` to match the on-chain convention.\n\t *\n\t * @param assetType - The full type of the asset (e.g., \"0x2::sui::SUI\")\n\t * @returns The derived policy object ID\n\t */\n\tderivePolicyAddress(assetType: string): string {\n\t\treturn derivePolicyAddress(assetType, this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the templates object address for a given package configuration.\n\t *\n\t * @returns The derived templates object ID\n\t */\n\tderiveTemplateRegistryAddress(): string {\n\t\treturn deriveTemplateRegistryAddress(this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the template DF address for a given approval type name.\n\t *\n\t * @param approvalTypeName - The fully qualified approval type name\n\t * @returns The derived dynamic field object ID\n\t */\n\tderiveTemplateAddress(approvalTypeName: string): string {\n\t\treturn deriveTemplateAddress(this.deriveTemplateRegistryAddress(), approvalTypeName);\n\t}\n\n\t/**\n\t * Intent-based transaction builders. Each method returns a synchronous closure\n\t * that registers a `$Intent` placeholder in the transaction. The actual PTB commands\n\t * are resolved lazily at `tx.build()` time via the shared PAS resolver plugin.\n\t */\n\tget call() {\n\t\treturn {\n\t\t\t/**\n\t\t\t * Creates a transfer funds intent. At build time, it auto-resolves the issuer's\n\t\t\t * approval template commands by reading the Policy and Templates objects on-chain.\n\t\t\t * If the recipient account does not exist, it will be created and shared automatically.\n\t\t\t *\n\t\t\t * @param options - Transfer options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.to - The receiver's address (owner of the destination account)\n\t\t\t * @param options.amount - The amount to transfer\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tsendBalance: sendBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Creates an unlock balance intent. At build time, it resolves the issuer's\n\t\t\t * approval template commands. This will fail if the issuer has not configured\n\t\t\t * unlock approvals for the asset type.\n\t\t\t *\n\t\t\t * @param options - Unlock options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.amount - The amount to unlock\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tunlockBalance: unlockBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Creates an unlock balance intent for unrestricted (non-managed) assets.\n\t\t\t * Use this when no Policy exists for the asset type (e.g., SUI).\n\t\t\t *\n\t\t\t * @param options - Unlock options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.amount - The amount to unlock\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tunlockUnrestrictedBalance: unlockUnrestrictedBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Returns a account object for the given address. At build time, if the account\n\t\t\t * already exists on-chain it resolves to an object reference; otherwise it\n\t\t\t * creates the account and shares it.\n\t\t\t *\n\t\t\t * @param owner - The owner address\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult` (the account)\n\t\t\t */\n\t\t\taccountForAddress: accountForAddressIntent(this.#packageConfig),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,IAAuC,EACtD,eACA,OAAO,OACP,GAAG,YACkB,EAAE,EAGtB;AACD,QAAO;EACN;EACA,WAAW,WACV,IAAI,UAAU;GAAE;GAAe,WAAW;GAAQ,GAAG;GAAS,CAAC;EAChE;;AAGF,IAAa,YAAb,MAAuB;CACtB;CAEA,YAAY,QAAyB;EACpC,MAAM,UAAU,OAAO,UAAU;AAGjC,MAAI,YAAY,aAAa,OAAO,cACnC,OAAM,IAAI,eACT,qHACA;AAGF,MAAI,OAAO,eAAe;AACzB,SAAKA,gBAAiB,OAAO;AAC7B;;AAGD,MAAI,CAAC,WAAY,YAAY,aAAa,YAAY,UACrD,OAAM,IAAI,eACT,4FACA;AAIF,MAAI,YAAY,UACf,OAAM,IAAI,eAAe,gCAAgC;AAG1D,QAAKA,gBAAiB;;;;;CAMvB,mBAAmB;AAClB,SAAO,MAAKA;;;;;;;;CASb,qBAAqB,OAAuB;AAC3C,SAAO,qBAAqB,OAAO,MAAKA,cAAe;;;;;;;;;CAUxD,oBAAoB,WAA2B;AAC9C,SAAO,oBAAoB,WAAW,MAAKA,cAAe;;;;;;;CAQ3D,gCAAwC;AACvC,SAAO,8BAA8B,MAAKA,cAAe;;;;;;;;CAS1D,sBAAsB,kBAAkC;AACvD,SAAO,sBAAsB,KAAK,+BAA+B,EAAE,iBAAiB;;;;;;;CAQrF,IAAI,OAAO;AACV,SAAO;GAaN,aAAa,kBAAkB,MAAKA,cAAe;GAanD,eAAe,oBAAoB,MAAKA,cAAe;GAYvD,2BAA2B,gCAAgC,MAAKA,cAAe;GAU/E,mBAAmB,wBAAwB,MAAKA,cAAe;GAC/D"}
1
+ {"version":3,"file":"client.mjs","names":["#packageConfig"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ClientWithCoreApi } from '@mysten/sui/client';\n\nimport { TESTNET_PAS_PACKAGE_CONFIG, MAINNET_PAS_PACKAGE_CONFIG } from './constants.js';\nimport {\n\tderiveAccountAddress,\n\tderivePolicyAddress,\n\tderiveTemplateAddress,\n\tderiveTemplateRegistryAddress,\n} from './derivation.js';\nimport { PASClientError } from './error.js';\nimport {\n\taccountForAddressIntent,\n\tsendBalanceIntent,\n\tunlockBalanceIntent,\n\tunlockUnrestrictedBalanceIntent,\n} from './intents.js';\nimport type { PASClientConfig, PASOptions, PASPackageConfig } from './types.js';\n\nexport function pas<const Name extends string = 'pas'>({\n\tpackageConfig,\n\tname = 'pas' as Name,\n\t...options\n}: PASOptions<Name> = {}): {\n\tname: Name;\n\tregister: (client: ClientWithCoreApi) => PASClient;\n} {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) =>\n\t\t\tnew PASClient({ packageConfig, suiClient: client, ...options }),\n\t};\n}\n\nexport class PASClient {\n\t#packageConfig: PASPackageConfig;\n\n\tconstructor(config: PASClientConfig) {\n\t\tconst network = config.suiClient.network;\n\n\t\t// Mainnet: no custom config allowed (avoid accidental republishing).\n\t\tif (network === 'mainnet' && config.packageConfig) {\n\t\t\tthrow new PASClientError(\n\t\t\t\t'Custom package configuration is not allowed on mainnet. Use the built-in mainnet config when mainnet is supported.',\n\t\t\t);\n\t\t}\n\n\t\tif (config.packageConfig) {\n\t\t\tthis.#packageConfig = config.packageConfig;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!network || (network !== 'mainnet' && network !== 'testnet')) {\n\t\t\tthrow new PASClientError(\n\t\t\t\t'PAS client requires a known network (mainnet, testnet) or a custom package configuration.',\n\t\t\t);\n\t\t}\n\n\t\tthis.#packageConfig =\n\t\t\tnetwork === 'mainnet' ? MAINNET_PAS_PACKAGE_CONFIG : TESTNET_PAS_PACKAGE_CONFIG;\n\t}\n\n\t/**\n\t * Get the package configuration\n\t */\n\tgetPackageConfig() {\n\t\treturn this.#packageConfig;\n\t}\n\n\t/**\n\t * Derives the account address for a given owner address.\n\t *\n\t * @param owner - The owner address (can be a user address or object address)\n\t * @returns The derived account object ID\n\t */\n\tderiveAccountAddress(owner: string): string {\n\t\treturn deriveAccountAddress(owner, this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the policy address for a given asset type T.\n\t * By default wraps with `Balance<T>` to match the on-chain convention.\n\t *\n\t * @param assetType - The full type of the asset (e.g., \"0x2::sui::SUI\")\n\t * @returns The derived policy object ID\n\t */\n\tderivePolicyAddress(assetType: string): string {\n\t\treturn derivePolicyAddress(assetType, this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the templates object address for a given package configuration.\n\t *\n\t * @returns The derived templates object ID\n\t */\n\tderiveTemplateRegistryAddress(): string {\n\t\treturn deriveTemplateRegistryAddress(this.#packageConfig);\n\t}\n\n\t/**\n\t * Derives the template DF address for a given approval type name.\n\t *\n\t * @param approvalTypeName - The fully qualified approval type name\n\t * @returns The derived dynamic field object ID\n\t */\n\tderiveTemplateAddress(approvalTypeName: string): string {\n\t\treturn deriveTemplateAddress(this.deriveTemplateRegistryAddress(), approvalTypeName);\n\t}\n\n\t/**\n\t * Intent-based transaction builders. Each method returns a synchronous closure\n\t * that registers a `$Intent` placeholder in the transaction. The actual PTB commands\n\t * are resolved lazily at `tx.build()` time via the shared PAS resolver plugin.\n\t */\n\tget call() {\n\t\treturn {\n\t\t\t/**\n\t\t\t * Creates a transfer funds intent. At build time, it auto-resolves the issuer's\n\t\t\t * approval template commands by reading the Policy and Templates objects on-chain.\n\t\t\t * If the recipient account does not exist, it will be created and shared automatically.\n\t\t\t *\n\t\t\t * @param options - Transfer options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.to - The receiver's address (owner of the destination account)\n\t\t\t * @param options.amount - The amount to transfer\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tsendBalance: sendBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Creates an unlock balance intent. At build time, it resolves the issuer's\n\t\t\t * approval template commands. This will fail if the issuer has not configured\n\t\t\t * unlock approvals for the asset type.\n\t\t\t *\n\t\t\t * @param options - Unlock options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.amount - The amount to unlock\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tunlockBalance: unlockBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Creates an unlock balance intent for unrestricted (non-managed) assets.\n\t\t\t * Use this when no Policy exists for the asset type (e.g., SUI).\n\t\t\t *\n\t\t\t * @param options - Unlock options\n\t\t\t * @param options.from - The sender's address (owner of the source account)\n\t\t\t * @param options.amount - The amount to unlock\n\t\t\t * @param options.assetType - The full asset type (e.g., \"0x2::sui::SUI\")\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult`\n\t\t\t */\n\t\t\tunlockUnrestrictedBalance: unlockUnrestrictedBalanceIntent(this.#packageConfig),\n\n\t\t\t/**\n\t\t\t * Returns a account object for the given address. At build time, if the account\n\t\t\t * already exists on-chain it resolves to an object reference; otherwise it\n\t\t\t * creates the account and shares it.\n\t\t\t *\n\t\t\t * @param owner - The owner address\n\t\t\t * @returns A sync closure `(tx: Transaction) => TransactionResult` (the account)\n\t\t\t */\n\t\t\taccountForAddress: accountForAddressIntent(this.#packageConfig),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,IAAuC,EACtD,eACA,OAAO,OACP,GAAG,YACkB,EAAE,EAGtB;AACD,QAAO;EACN;EACA,WAAW,WACV,IAAI,UAAU;GAAE;GAAe,WAAW;GAAQ,GAAG;GAAS,CAAC;EAChE;;AAGF,IAAa,YAAb,MAAuB;CACtB;CAEA,YAAY,QAAyB;EACpC,MAAM,UAAU,OAAO,UAAU;AAGjC,MAAI,YAAY,aAAa,OAAO,cACnC,OAAM,IAAI,eACT,qHACA;AAGF,MAAI,OAAO,eAAe;AACzB,SAAKA,gBAAiB,OAAO;AAC7B;;AAGD,MAAI,CAAC,WAAY,YAAY,aAAa,YAAY,UACrD,OAAM,IAAI,eACT,4FACA;AAGF,QAAKA,gBACJ,YAAY,YAAY,6BAA6B;;;;;CAMvD,mBAAmB;AAClB,SAAO,MAAKA;;;;;;;;CASb,qBAAqB,OAAuB;AAC3C,SAAO,qBAAqB,OAAO,MAAKA,cAAe;;;;;;;;;CAUxD,oBAAoB,WAA2B;AAC9C,SAAO,oBAAoB,WAAW,MAAKA,cAAe;;;;;;;CAQ3D,gCAAwC;AACvC,SAAO,8BAA8B,MAAKA,cAAe;;;;;;;;CAS1D,sBAAsB,kBAAkC;AACvD,SAAO,sBAAsB,KAAK,+BAA+B,EAAE,iBAAiB;;;;;;;CAQrF,IAAI,OAAO;AACV,SAAO;GAaN,aAAa,kBAAkB,MAAKA,cAAe;GAanD,eAAe,oBAAoB,MAAKA,cAAe;GAYvD,2BAA2B,gCAAgC,MAAKA,cAAe;GAU/E,mBAAmB,wBAAwB,MAAKA,cAAe;GAC/D"}
@@ -3,7 +3,11 @@ const TESTNET_PAS_PACKAGE_CONFIG = {
3
3
  packageId: "0x7e77592474ea9759b46ca5c6515ed4840952cd80d60ee54a1614382811d46730",
4
4
  namespaceId: "0xf7c77ac8bbbdf47f7b1cf8ac8aa489cfc4dff25847f3e2e1db53bde5c454be2b"
5
5
  };
6
+ const MAINNET_PAS_PACKAGE_CONFIG = {
7
+ packageId: "0xe2f75f77648329be3eac31d8455c81df95003dcb5ed50964102b7e1d44f82ad5",
8
+ namespaceId: "0xf4d3d9ecc611dcb361aae1548ff08792da4bf9d8a78b1398dbdc601e1e3b118e"
9
+ };
6
10
 
7
11
  //#endregion
8
- export { TESTNET_PAS_PACKAGE_CONFIG };
12
+ export { MAINNET_PAS_PACKAGE_CONFIG, TESTNET_PAS_PACKAGE_CONFIG };
9
13
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PASPackageConfig } from './types.js';\n\nexport const TESTNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {\n\tpackageId: '0x7e77592474ea9759b46ca5c6515ed4840952cd80d60ee54a1614382811d46730',\n\tnamespaceId: '0xf7c77ac8bbbdf47f7b1cf8ac8aa489cfc4dff25847f3e2e1db53bde5c454be2b',\n};\n\n// TODO: also update `client.ts` when adding these variables\nexport const MAINNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {\n\tpackageId: '', // TODO: Replace with actual mainnet package ID\n\tnamespaceId: '', // TODO: Replace with actual mainnet namespace ID\n};\n"],"mappings":";AAKA,MAAa,6BAA+C;CAC3D,WAAW;CACX,aAAa;CACb"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PASPackageConfig } from './types.js';\n\nexport const TESTNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {\n\tpackageId: '0x7e77592474ea9759b46ca5c6515ed4840952cd80d60ee54a1614382811d46730',\n\tnamespaceId: '0xf7c77ac8bbbdf47f7b1cf8ac8aa489cfc4dff25847f3e2e1db53bde5c454be2b',\n};\n\nexport const MAINNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {\n\tpackageId: '0xe2f75f77648329be3eac31d8455c81df95003dcb5ed50964102b7e1d44f82ad5',\n\tnamespaceId: '0xf4d3d9ecc611dcb361aae1548ff08792da4bf9d8a78b1398dbdc601e1e3b118e',\n};\n"],"mappings":";AAKA,MAAa,6BAA+C;CAC3D,WAAW;CACX,aAAa;CACb;AAED,MAAa,6BAA+C;CAC3D,WAAW;CACX,aAAa;CACb"}
@@ -9,7 +9,7 @@ import { bcs } from "@mysten/sui/bcs";
9
9
  /**************************************************************
10
10
  * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
11
11
  **************************************************************/
12
- const $moduleName = "@mysten/pas::policy";
12
+ const $moduleName = "@pas/pas::policy";
13
13
  const Policy = new MoveStruct({
14
14
  name: `${$moduleName}::Policy<phantom T>`,
15
15
  fields: {
@@ -1 +1 @@
1
- {"version":3,"file":"policy.mjs","names":["vec_map.VecMap","vec_set.VecSet","type_name.TypeName","versioning.Versioning"],"sources":["../../../src/contracts/pas/policy.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport {\n\tMoveStruct,\n\tMoveTuple,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} 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';\nimport * as vec_set from './deps/sui/vec_set.js';\nimport * as type_name from './deps/std/type_name.js';\nimport * as versioning from './versioning.js';\nconst $moduleName = '@mysten/pas::policy';\nexport const Policy = new MoveStruct({\n\tname: `${$moduleName}::Policy<phantom T>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\t/**\n\t\t * The required approvals per request type. The key must be one of the request\n\t\t * types (e.g. `send_funds`, `unlock_funds` or `clawback_funds`).\n\t\t *\n\t\t * The value is a vector of approvals that need to be gather to resolve the\n\t\t * request.\n\t\t */\n\t\trequired_approvals: vec_map.VecMap(bcs.string(), vec_set.VecSet(type_name.TypeName)),\n\t\t/**\n\t\t * Block versions to break backwards compatibility -- only used in case of\n\t\t * emergency.\n\t\t */\n\t\tversioning: versioning.Versioning,\n\t\t/** Whether clawback is allowed for this policy. */\n\t\tclawback_allowed: bcs.bool(),\n\t},\n});\nexport const PolicyCap = new MoveStruct({\n\tname: `${$moduleName}::PolicyCap<phantom T>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t},\n});\nexport const PolicyCapKey = new MoveTuple({\n\tname: `${$moduleName}::PolicyCapKey`,\n\tfields: [bcs.bool()],\n});\nexport interface NewForCurrencyArguments {\n\tnamespace: RawTransactionArgument<string>;\n\tCap: RawTransactionArgument<string>;\n\tclawbackAllowed: RawTransactionArgument<boolean>;\n}\nexport interface NewForCurrencyOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewForCurrencyArguments\n\t\t| [\n\t\t\t\tnamespace: RawTransactionArgument<string>,\n\t\t\t\tCap: RawTransactionArgument<string>,\n\t\t\t\tclawbackAllowed: RawTransactionArgument<boolean>,\n\t\t ];\n\ttypeArguments: [string];\n}\nexport function newForCurrency(options: NewForCurrencyOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, 'bool'] satisfies (string | null)[];\n\tconst parameterNames = ['namespace', 'Cap', 'clawbackAllowed'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'new_for_currency',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ShareArguments {\n\tpolicy: RawTransactionArgument<string>;\n}\nexport interface ShareOptions {\n\tpackage?: string;\n\targuments: ShareArguments | [policy: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\nexport function share(options: ShareOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['policy'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'share',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RequiredApprovalsArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tactionType: RawTransactionArgument<string>;\n}\nexport interface RequiredApprovalsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RequiredApprovalsArguments\n\t\t| [policy: RawTransactionArgument<string>, actionType: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/** Get the set of required approvals for a given action. */\nexport function requiredApprovals(options: RequiredApprovalsOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'actionType'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'required_approvals',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface SetRequiredApprovalArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\taction: RawTransactionArgument<string>;\n}\nexport interface SetRequiredApprovalOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SetRequiredApprovalArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\taction: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function setRequiredApproval(options: SetRequiredApprovalOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap', 'action'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'set_required_approval',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RemoveActionApprovalArguments {\n\tpolicy: RawTransactionArgument<string>;\n\t_: RawTransactionArgument<string>;\n\taction: RawTransactionArgument<string>;\n}\nexport interface RemoveActionApprovalOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RemoveActionApprovalArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\t_: RawTransactionArgument<string>,\n\t\t\t\taction: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/**\n * Remove the action approval for a given action (this will make all requests not\n * resolve).\n */\nexport function removeActionApproval(options: RemoveActionApprovalOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', '_', 'action'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'remove_action_approval',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface SyncVersioningArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tnamespace: RawTransactionArgument<string>;\n}\nexport interface SyncVersioningOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SyncVersioningArguments\n\t\t| [policy: RawTransactionArgument<string>, namespace: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Allows syncing the versioning of a policy to the namespace's versioning. This is\n * permission-less and can be done by anyone.\n */\nexport function syncVersioning(options: SyncVersioningOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'namespace'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'sync_versioning',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,cAAc;AACpB,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EAQR,oBAAoBA,OAAe,IAAI,QAAQ,EAAEC,OAAeC,SAAmB,CAAC;EAKpF,YAAYC;EAEZ,kBAAkB,IAAI,MAAM;EAC5B;CACD,CAAC;AACF,MAAa,YAAY,IAAI,WAAW;CACvC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,IAAI,IAAI,SACR;CACD,CAAC;AACF,MAAa,eAAe,IAAI,UAAU;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ,CAAC,IAAI,MAAM,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"policy.mjs","names":["vec_map.VecMap","vec_set.VecSet","type_name.TypeName","versioning.Versioning"],"sources":["../../../src/contracts/pas/policy.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport {\n\tMoveStruct,\n\tMoveTuple,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} 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';\nimport * as vec_set from './deps/sui/vec_set.js';\nimport * as type_name from './deps/std/type_name.js';\nimport * as versioning from './versioning.js';\nconst $moduleName = '@pas/pas::policy';\nexport const Policy = new MoveStruct({\n\tname: `${$moduleName}::Policy<phantom T>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\t/**\n\t\t * The required approvals per request type. The key must be one of the request\n\t\t * types (e.g. `send_funds`, `unlock_funds` or `clawback_funds`).\n\t\t *\n\t\t * The value is a vector of approvals that need to be gather to resolve the\n\t\t * request.\n\t\t */\n\t\trequired_approvals: vec_map.VecMap(bcs.string(), vec_set.VecSet(type_name.TypeName)),\n\t\t/**\n\t\t * Block versions to break backwards compatibility -- only used in case of\n\t\t * emergency.\n\t\t */\n\t\tversioning: versioning.Versioning,\n\t\t/** Whether clawback is allowed for this policy. */\n\t\tclawback_allowed: bcs.bool(),\n\t},\n});\nexport const PolicyCap = new MoveStruct({\n\tname: `${$moduleName}::PolicyCap<phantom T>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t},\n});\nexport const PolicyCapKey = new MoveTuple({\n\tname: `${$moduleName}::PolicyCapKey`,\n\tfields: [bcs.bool()],\n});\nexport interface NewForCurrencyArguments {\n\tnamespace: RawTransactionArgument<string>;\n\tCap: RawTransactionArgument<string>;\n\tclawbackAllowed: RawTransactionArgument<boolean>;\n}\nexport interface NewForCurrencyOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewForCurrencyArguments\n\t\t| [\n\t\t\t\tnamespace: RawTransactionArgument<string>,\n\t\t\t\tCap: RawTransactionArgument<string>,\n\t\t\t\tclawbackAllowed: RawTransactionArgument<boolean>,\n\t\t ];\n\ttypeArguments: [string];\n}\nexport function newForCurrency(options: NewForCurrencyOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, 'bool'] satisfies (string | null)[];\n\tconst parameterNames = ['namespace', 'Cap', 'clawbackAllowed'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'new_for_currency',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ShareArguments {\n\tpolicy: RawTransactionArgument<string>;\n}\nexport interface ShareOptions {\n\tpackage?: string;\n\targuments: ShareArguments | [policy: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\nexport function share(options: ShareOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['policy'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'share',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RequiredApprovalsArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tactionType: RawTransactionArgument<string>;\n}\nexport interface RequiredApprovalsOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RequiredApprovalsArguments\n\t\t| [policy: RawTransactionArgument<string>, actionType: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/** Get the set of required approvals for a given action. */\nexport function requiredApprovals(options: RequiredApprovalsOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'actionType'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'required_approvals',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface SetRequiredApprovalArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\taction: RawTransactionArgument<string>;\n}\nexport interface SetRequiredApprovalOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SetRequiredApprovalArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\taction: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function setRequiredApproval(options: SetRequiredApprovalOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap', 'action'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'set_required_approval',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface RemoveActionApprovalArguments {\n\tpolicy: RawTransactionArgument<string>;\n\t_: RawTransactionArgument<string>;\n\taction: RawTransactionArgument<string>;\n}\nexport interface RemoveActionApprovalOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RemoveActionApprovalArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\t_: RawTransactionArgument<string>,\n\t\t\t\taction: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/**\n * Remove the action approval for a given action (this will make all requests not\n * resolve).\n */\nexport function removeActionApproval(options: RemoveActionApprovalOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', '_', 'action'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'remove_action_approval',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface SyncVersioningArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tnamespace: RawTransactionArgument<string>;\n}\nexport interface SyncVersioningOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SyncVersioningArguments\n\t\t| [policy: RawTransactionArgument<string>, namespace: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Allows syncing the versioning of a policy to the namespace's versioning. This is\n * permission-less and can be done by anyone.\n */\nexport function syncVersioning(options: SyncVersioningOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'namespace'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'policy',\n\t\t\tfunction: 'sync_versioning',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,cAAc;AACpB,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EAQR,oBAAoBA,OAAe,IAAI,QAAQ,EAAEC,OAAeC,SAAmB,CAAC;EAKpF,YAAYC;EAEZ,kBAAkB,IAAI,MAAM;EAC5B;CACD,CAAC;AACF,MAAa,YAAY,IAAI,WAAW;CACvC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,IAAI,IAAI,SACR;CACD,CAAC;AACF,MAAa,eAAe,IAAI,UAAU;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ,CAAC,IAAI,MAAM,CAAC;CACpB,CAAC"}
@@ -14,7 +14,7 @@ import { bcs } from "@mysten/sui/bcs";
14
14
  * It allows for blocking specific versions of the package in case of emergency, or
15
15
  * to slowly deprecate an earlier feature.
16
16
  */
17
- const $moduleName = "@mysten/pas::versioning";
17
+ const $moduleName = "@pas/pas::versioning";
18
18
  const Versioning = new MoveStruct({
19
19
  name: `${$moduleName}::Versioning`,
20
20
  fields: { blocked_versions: VecSet(bcs.u64()) }
@@ -1 +1 @@
1
- {"version":3,"file":"versioning.mjs","names":["vec_set.VecSet"],"sources":["../../../src/contracts/pas/versioning.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Versioning module.\n *\n * This module is responsible for managing the versioning of the package.\n *\n * It allows for blocking specific versions of the package in case of emergency, or\n * to slowly deprecate an earlier feature.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nimport * as vec_set from './deps/sui/vec_set.js';\nconst $moduleName = '@mysten/pas::versioning';\nexport const Versioning = new MoveStruct({\n\tname: `${$moduleName}::Versioning`,\n\tfields: {\n\t\tblocked_versions: vec_set.VecSet(bcs.u64()),\n\t},\n});\nexport interface IsValidVersionArguments {\n\tversioning: TransactionArgument;\n\tversion: RawTransactionArgument<number | bigint>;\n}\nexport interface IsValidVersionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| IsValidVersionArguments\n\t\t| [versioning: TransactionArgument, version: RawTransactionArgument<number | bigint>];\n}\n/** Verify that a version is not part of the blocked version list. */\nexport function isValidVersion(options: IsValidVersionOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['versioning', 'version'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'versioning',\n\t\t\tfunction: 'is_valid_version',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface AssertIsValidVersionArguments {\n\tversioning: TransactionArgument;\n}\nexport interface AssertIsValidVersionOptions {\n\tpackage?: string;\n\targuments: AssertIsValidVersionArguments | [versioning: TransactionArgument];\n}\nexport function assertIsValidVersion(options: AssertIsValidVersionOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['versioning'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'versioning',\n\t\t\tfunction: 'assert_is_valid_version',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,cAAc;AACpB,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,kBAAkBA,OAAe,IAAI,KAAK,CAAC,EAC3C;CACD,CAAC"}
1
+ {"version":3,"file":"versioning.mjs","names":["vec_set.VecSet"],"sources":["../../../src/contracts/pas/versioning.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Versioning module.\n *\n * This module is responsible for managing the versioning of the package.\n *\n * It allows for blocking specific versions of the package in case of emergency, or\n * to slowly deprecate an earlier feature.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nimport * as vec_set from './deps/sui/vec_set.js';\nconst $moduleName = '@pas/pas::versioning';\nexport const Versioning = new MoveStruct({\n\tname: `${$moduleName}::Versioning`,\n\tfields: {\n\t\tblocked_versions: vec_set.VecSet(bcs.u64()),\n\t},\n});\nexport interface IsValidVersionArguments {\n\tversioning: TransactionArgument;\n\tversion: RawTransactionArgument<number | bigint>;\n}\nexport interface IsValidVersionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| IsValidVersionArguments\n\t\t| [versioning: TransactionArgument, version: RawTransactionArgument<number | bigint>];\n}\n/** Verify that a version is not part of the blocked version list. */\nexport function isValidVersion(options: IsValidVersionOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['versioning', 'version'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'versioning',\n\t\t\tfunction: 'is_valid_version',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface AssertIsValidVersionArguments {\n\tversioning: TransactionArgument;\n}\nexport interface AssertIsValidVersionOptions {\n\tpackage?: string;\n\targuments: AssertIsValidVersionArguments | [versioning: TransactionArgument];\n}\nexport function assertIsValidVersion(options: AssertIsValidVersionOptions) {\n\tconst packageAddress = options.package ?? '@mysten/pas';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['versioning'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'versioning',\n\t\t\tfunction: 'assert_is_valid_version',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,cAAc;AACpB,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,kBAAkBA,OAAe,IAAI,KAAK,CAAC,EAC3C;CACD,CAAC"}
@@ -6,7 +6,7 @@ import { bcs } from "@mysten/sui/bcs";
6
6
  * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
7
  **************************************************************/
8
8
  /** Module: ptb */
9
- const $moduleName = "@mysten/ptb::ptb";
9
+ const $moduleName = "@pas/ptb::ptb";
10
10
  const Command = new MoveTuple({
11
11
  name: `${$moduleName}::Command`,
12
12
  fields: [bcs.u8(), bcs.vector(bcs.u8())]
@@ -1 +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 {\n\ttype Transaction as Transaction_1,\n\ttype TransactionArgument,\n} 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: TransactionArgument;\n\tcommand: TransactionArgument;\n}\nexport interface CommandOptions {\n\tpackage?: string;\n\targuments: CommandArguments | [self: TransactionArgument, command: TransactionArgument];\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: TransactionArgument;\n\tsubIdx: RawTransactionArgument<number>;\n}\nexport interface NestedOptions {\n\tpackage?: string;\n\targuments: NestedArguments | [self: TransactionArgument, 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: TransactionArgument;\n\ttypeArguments: RawTransactionArgument<Array<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: TransactionArgument,\n\t\t\t\ttypeArguments: RawTransactionArgument<Array<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: TransactionArgument;\n\tto: TransactionArgument;\n}\nexport interface TransferObjectsOptions {\n\tpackage?: string;\n\targuments: TransferObjectsArguments | [objects: TransactionArgument, to: TransactionArgument];\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: TransactionArgument;\n\tamounts: TransactionArgument;\n}\nexport interface SplitCoinsOptions {\n\tpackage?: string;\n\targuments: SplitCoinsArguments | [coin: TransactionArgument, amounts: TransactionArgument];\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: TransactionArgument;\n\tcoins: TransactionArgument;\n}\nexport interface MergeCoinsOptions {\n\tpackage?: string;\n\targuments: MergeCoinsArguments | [coin: TransactionArgument, coins: TransactionArgument];\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<Array<Array<number>>>;\n\tdependencies: RawTransactionArgument<Array<string>>;\n}\nexport interface PublishOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PublishArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<Array<Array<number>>>,\n\t\t\t\tdependencies: RawTransactionArgument<Array<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: TransactionArgument;\n}\nexport interface MakeMoveVecOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MakeMoveVecArguments\n\t\t| [elementType: RawTransactionArgument<string | null>, elements: TransactionArgument];\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<Array<Array<number>>>;\n\tdependencies: RawTransactionArgument<Array<string>>;\n\tobjectId: RawTransactionArgument<string>;\n\tupgradeTicket: TransactionArgument;\n}\nexport interface UpgradeOptions {\n\tpackage?: string;\n\targuments:\n\t\t| UpgradeArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<Array<Array<number>>>,\n\t\t\t\tdependencies: RawTransactionArgument<Array<string>>,\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tupgradeTicket: TransactionArgument,\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<Array<number>>;\n}\nexport interface ExtOptions {\n\tpackage?: string;\n\targuments: ExtArguments | [data: RawTransactionArgument<Array<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":"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"}
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 {\n\ttype Transaction as Transaction_1,\n\ttype TransactionArgument,\n} from '@mysten/sui/transactions';\nconst $moduleName = '@pas/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: TransactionArgument;\n\tcommand: TransactionArgument;\n}\nexport interface CommandOptions {\n\tpackage?: string;\n\targuments: CommandArguments | [self: TransactionArgument, command: TransactionArgument];\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: TransactionArgument;\n\tsubIdx: RawTransactionArgument<number>;\n}\nexport interface NestedOptions {\n\tpackage?: string;\n\targuments: NestedArguments | [self: TransactionArgument, 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: TransactionArgument;\n\ttypeArguments: RawTransactionArgument<Array<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: TransactionArgument,\n\t\t\t\ttypeArguments: RawTransactionArgument<Array<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: TransactionArgument;\n\tto: TransactionArgument;\n}\nexport interface TransferObjectsOptions {\n\tpackage?: string;\n\targuments: TransferObjectsArguments | [objects: TransactionArgument, to: TransactionArgument];\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: TransactionArgument;\n\tamounts: TransactionArgument;\n}\nexport interface SplitCoinsOptions {\n\tpackage?: string;\n\targuments: SplitCoinsArguments | [coin: TransactionArgument, amounts: TransactionArgument];\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: TransactionArgument;\n\tcoins: TransactionArgument;\n}\nexport interface MergeCoinsOptions {\n\tpackage?: string;\n\targuments: MergeCoinsArguments | [coin: TransactionArgument, coins: TransactionArgument];\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<Array<Array<number>>>;\n\tdependencies: RawTransactionArgument<Array<string>>;\n}\nexport interface PublishOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PublishArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<Array<Array<number>>>,\n\t\t\t\tdependencies: RawTransactionArgument<Array<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: TransactionArgument;\n}\nexport interface MakeMoveVecOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MakeMoveVecArguments\n\t\t| [elementType: RawTransactionArgument<string | null>, elements: TransactionArgument];\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<Array<Array<number>>>;\n\tdependencies: RawTransactionArgument<Array<string>>;\n\tobjectId: RawTransactionArgument<string>;\n\tupgradeTicket: TransactionArgument;\n}\nexport interface UpgradeOptions {\n\tpackage?: string;\n\targuments:\n\t\t| UpgradeArguments\n\t\t| [\n\t\t\t\tmodulesBytes: RawTransactionArgument<Array<Array<number>>>,\n\t\t\t\tdependencies: RawTransactionArgument<Array<string>>,\n\t\t\t\tobjectId: RawTransactionArgument<string>,\n\t\t\t\tupgradeTicket: TransactionArgument,\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<Array<number>>;\n}\nexport interface ExtOptions {\n\tpackage?: string;\n\targuments: ExtArguments | [data: RawTransactionArgument<Array<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":"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"}
@@ -1,12 +1,78 @@
1
1
  import { PASClientError } from "../../error.mjs";
2
- import { BcsEnum, BcsStruct, BcsTuple, bcs } from "@mysten/sui/bcs";
3
- import { normalizeSuiAddress } from "@mysten/sui/utils";
2
+ import { BcsEnum, BcsStruct, BcsTuple, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
3
+ import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
4
4
  import "@mysten/sui/transactions";
5
5
 
6
6
  //#region src/contracts/utils/index.ts
7
7
  const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
8
8
  const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
9
+ const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
10
+ function splitTopLevelTypeArgs(inner) {
11
+ const parts = [];
12
+ let depth = 0;
13
+ let current = "";
14
+ for (const char of inner) {
15
+ if (char === "," && depth === 0) {
16
+ parts.push(current.trim());
17
+ current = "";
18
+ continue;
19
+ }
20
+ if (char === "<") depth++;
21
+ if (char === ">") depth--;
22
+ current += char;
23
+ }
24
+ if (current) parts.push(current.trim());
25
+ return parts;
26
+ }
27
+ function buildTypeTag(name, options) {
28
+ const lt = name.indexOf("<");
29
+ const base = lt === -1 ? name : name.slice(0, lt);
30
+ if (base.split("::").length !== 3) throw new PASClientError(`${name} is not a top-level Move type`);
31
+ let result = name;
32
+ if (options?.typeArguments) {
33
+ const baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));
34
+ const supplied = options.typeArguments.map((arg) => {
35
+ if (typeof arg === "string") return arg;
36
+ if (arg && typeof arg.serialize === "function" && typeof arg.name === "string") return arg.name;
37
+ throw new PASClientError(`Invalid type argument ${stringify(arg)}`);
38
+ });
39
+ if (supplied.length !== baked.length) throw new PASClientError(`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`);
40
+ result = supplied.length === 0 ? base : `${base}<${supplied.join(", ")}>`;
41
+ }
42
+ if (HAS_PHANTOM_REGEX.test(result)) throw new PASClientError(options?.typeArguments ? `A type argument contains an unfilled phantom parameter in ${result}` : `Missing type arguments for ${result}`);
43
+ if (options?.package) {
44
+ const [, ...rest] = result.split("::");
45
+ result = [options.package, ...rest].join("::");
46
+ }
47
+ if (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) TypeTagSerializer.parseFromStr(result);
48
+ return result;
49
+ }
50
+ async function resolveBuiltTypeTag(name, options) {
51
+ const { client, ...rest } = options;
52
+ const { type } = await client.core.mvr.resolveType({ type: buildTypeTag(name, rest) });
53
+ return normalizeStructTag(type);
54
+ }
9
55
  var MoveStruct = class extends BcsStruct {
56
+ /**
57
+ * Build the type tag for this struct.
58
+ *
59
+ * `typeArguments` is the full positional list, in Move declaration order, and
60
+ * is required when the struct has unfilled phantom parameters. The result may
61
+ * contain MVR names: those are valid in transaction `typeArguments`, but for
62
+ * queries or comparisons against on-chain data use `resolveTypeTag` instead.
63
+ */
64
+ typeTag(...args) {
65
+ return buildTypeTag(this.name, args[0]);
66
+ }
67
+ /**
68
+ * Build the type tag for this struct, then resolve any MVR names through the
69
+ * client (using its configured overrides and the MVR API) and return the
70
+ * normalized, address-only form suitable for queries and comparisons against
71
+ * on-chain data.
72
+ */
73
+ async resolveTypeTag(options) {
74
+ return resolveBuiltTypeTag(this.name, options);
75
+ }
10
76
  async get({ objectId, ...options }) {
11
77
  const [res] = await this.getMany({
12
78
  ...options,
@@ -31,8 +97,31 @@ var MoveStruct = class extends BcsStruct {
31
97
  });
32
98
  }
33
99
  };
34
- var MoveEnum = class extends BcsEnum {};
35
- var MoveTuple = class extends BcsTuple {};
100
+ var MoveEnum = class extends BcsEnum {
101
+ /** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */
102
+ typeTag(...args) {
103
+ return buildTypeTag(this.name, args[0]);
104
+ }
105
+ /** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */
106
+ async resolveTypeTag(options) {
107
+ return resolveBuiltTypeTag(this.name, options);
108
+ }
109
+ };
110
+ var MoveTuple = class extends BcsTuple {
111
+ /** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */
112
+ typeTag(...args) {
113
+ return buildTypeTag(this.name, args[0]);
114
+ }
115
+ /** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */
116
+ async resolveTypeTag(options) {
117
+ return resolveBuiltTypeTag(this.name, options);
118
+ }
119
+ };
120
+ function stringify(val) {
121
+ if (typeof val === "object") return JSON.stringify(val, (_key, value) => typeof value === "bigint" ? value.toString() : value);
122
+ if (typeof val === "bigint") return val.toString();
123
+ return val;
124
+ }
36
125
 
37
126
  //#endregion
38
127
  export { MoveEnum, MoveStruct, MoveTuple };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import { PASClientError } from '../../error.js';\n\nimport {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\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 inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\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 argType of argTypes) {\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 bcsType = argType === null ? null : getPureBcsSchema(argType);\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}\n\n\t\tif (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 ${argType}`);\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\tif (!res) {\n\t\t\tthrow new PASClientError(`No object found for id ${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":";;;;;;AAeA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAiJxD,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,MAAI,CAAC,IACJ,OAAM,IAAI,eAAe,0BAA0B,WAAW;AAG/D,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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import { PASClientError } from '../../error.js';\n\nimport {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\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 inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\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 argType of argTypes) {\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 bcsType = argType === null ? null : getPureBcsSchema(argType);\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}\n\n\t\tif (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 ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}`\n\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(name: string, options: TypeTagOptions | undefined): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new PASClientError(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (arg && typeof arg.serialize === 'function' && typeof arg.name === 'string') {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new PASClientError(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new PASClientError(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new PASClientError(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\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\tif (!res) {\n\t\t\tthrow new PASClientError(`No object found for id ${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\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/pas",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Permissioned Assets Standard SDK",
6
6
  "license": "Apache-2.0",
@@ -32,14 +32,14 @@
32
32
  "url": "https://github.com/mystenlabs/ts-sdks/issues"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/node": "^25.0.8",
35
+ "@types/node": "^25.9.3",
36
36
  "ts-retry-promise": "^0.8.1",
37
- "tsdown": "0.20.0-beta.1",
38
- "typescript": "^5.9.3",
39
- "vitest": "^4.0.17"
37
+ "tsdown": "0.22.2",
38
+ "typescript": "^6.0.3",
39
+ "vitest": "^4.1.8"
40
40
  },
41
41
  "peerDependencies": {
42
- "@mysten/sui": "^2.16.2"
42
+ "@mysten/sui": "^2.18.0"
43
43
  },
44
44
  "scripts": {
45
45
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
package/src/client.ts CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  import type { ClientWithCoreApi } from '@mysten/sui/client';
5
5
 
6
- import { TESTNET_PAS_PACKAGE_CONFIG } from './constants.js';
6
+ import { TESTNET_PAS_PACKAGE_CONFIG, MAINNET_PAS_PACKAGE_CONFIG } from './constants.js';
7
7
  import {
8
8
  deriveAccountAddress,
9
9
  derivePolicyAddress,
@@ -58,12 +58,8 @@ export class PASClient {
58
58
  );
59
59
  }
60
60
 
61
- // TODO: Remove when we add mainnet data
62
- if (network === 'mainnet') {
63
- throw new PASClientError('Mainnet is not supported yet.');
64
- }
65
-
66
- this.#packageConfig = TESTNET_PAS_PACKAGE_CONFIG;
61
+ this.#packageConfig =
62
+ network === 'mainnet' ? MAINNET_PAS_PACKAGE_CONFIG : TESTNET_PAS_PACKAGE_CONFIG;
67
63
  }
68
64
 
69
65
  /**
package/src/constants.ts CHANGED
@@ -8,8 +8,7 @@ export const TESTNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {
8
8
  namespaceId: '0xf7c77ac8bbbdf47f7b1cf8ac8aa489cfc4dff25847f3e2e1db53bde5c454be2b',
9
9
  };
10
10
 
11
- // TODO: also update `client.ts` when adding these variables
12
11
  export const MAINNET_PAS_PACKAGE_CONFIG: PASPackageConfig = {
13
- packageId: '', // TODO: Replace with actual mainnet package ID
14
- namespaceId: '', // TODO: Replace with actual mainnet namespace ID
12
+ packageId: '0xe2f75f77648329be3eac31d8455c81df95003dcb5ed50964102b7e1d44f82ad5',
13
+ namespaceId: '0xf4d3d9ecc611dcb361aae1548ff08792da4bf9d8a78b1398dbdc601e1e3b118e',
15
14
  };
@@ -13,7 +13,7 @@ import {
13
13
  import { bcs } from '@mysten/sui/bcs';
14
14
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
15
15
  import * as versioning from './versioning.js';
16
- const $moduleName = '@mysten/pas::account';
16
+ const $moduleName = '@pas/pas::account';
17
17
  export const Account = new MoveStruct({
18
18
  name: `${$moduleName}::Account`,
19
19
  fields: {
@@ -4,7 +4,7 @@
4
4
  import { type BcsType, bcs } from '@mysten/sui/bcs';
5
5
  import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
6
6
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
7
- const $moduleName = '@mysten/pas::clawback_funds';
7
+ const $moduleName = '@pas/pas::clawback_funds';
8
8
  export function ClawbackFunds<T extends BcsType<any>>(...typeParameters: [T]) {
9
9
  return new MoveStruct({
10
10
  name: `${$moduleName}::ClawbackFunds<${typeParameters[0].name as T['name']}>`,
@@ -4,7 +4,7 @@
4
4
  import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
5
5
  import { bcs } from '@mysten/sui/bcs';
6
6
  import { type Transaction } from '@mysten/sui/transactions';
7
- const $moduleName = '@mysten/pas::keys';
7
+ const $moduleName = '@pas/pas::keys';
8
8
  export const PolicyKey = new MoveTuple({
9
9
  name: `${$moduleName}::PolicyKey<phantom T>`,
10
10
  fields: [bcs.bool()],
@@ -15,7 +15,7 @@ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from
15
15
  import { bcs } from '@mysten/sui/bcs';
16
16
  import { type Transaction } from '@mysten/sui/transactions';
17
17
  import * as versioning from './versioning.js';
18
- const $moduleName = '@mysten/pas::namespace';
18
+ const $moduleName = '@pas/pas::namespace';
19
19
  export const Namespace = new MoveStruct({
20
20
  name: `${$moduleName}::Namespace`,
21
21
  fields: {
@@ -13,7 +13,7 @@ import * as vec_map from './deps/sui/vec_map.js';
13
13
  import * as vec_set from './deps/sui/vec_set.js';
14
14
  import * as type_name from './deps/std/type_name.js';
15
15
  import * as versioning from './versioning.js';
16
- const $moduleName = '@mysten/pas::policy';
16
+ const $moduleName = '@pas/pas::policy';
17
17
  export const Policy = new MoveStruct({
18
18
  name: `${$moduleName}::Policy<phantom T>`,
19
19
  fields: {
@@ -6,7 +6,7 @@ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from
6
6
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
7
7
  import * as vec_set from './deps/sui/vec_set.js';
8
8
  import * as type_name from './deps/std/type_name.js';
9
- const $moduleName = '@mysten/pas::request';
9
+ const $moduleName = '@pas/pas::request';
10
10
  /** A base request type. Examples: `Request<SendFunds<T>>` `Request<UnlockFunds<T>>` */
11
11
  export function Request<K extends BcsType<any>>(...typeParameters: [K]) {
12
12
  return new MoveStruct({
@@ -4,7 +4,7 @@
4
4
  import { type BcsType, bcs } from '@mysten/sui/bcs';
5
5
  import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
6
6
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
7
- const $moduleName = '@mysten/pas::send_funds';
7
+ const $moduleName = '@pas/pas::send_funds';
8
8
  /**
9
9
  * A transfer request that is generated once a send funds request is initialized.
10
10
  *
@@ -12,7 +12,7 @@
12
12
  import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
13
13
  import { bcs } from '@mysten/sui/bcs';
14
14
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
15
- const $moduleName = '@mysten/pas::templates';
15
+ const $moduleName = '@pas/pas::templates';
16
16
  export const PAS = new MoveStruct({
17
17
  name: `${$moduleName}::PAS`,
18
18
  fields: {
@@ -4,7 +4,7 @@
4
4
  import { type BcsType, bcs } from '@mysten/sui/bcs';
5
5
  import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
6
6
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
7
- const $moduleName = '@mysten/pas::unlock_funds';
7
+ const $moduleName = '@pas/pas::unlock_funds';
8
8
  /**
9
9
  * An unlock funds request that is generated once a Permissioned Funds Transfer is
10
10
  * initiated.
@@ -15,7 +15,7 @@ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from
15
15
  import { bcs } from '@mysten/sui/bcs';
16
16
  import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
17
17
  import * as vec_set from './deps/sui/vec_set.js';
18
- const $moduleName = '@mysten/pas::versioning';
18
+ const $moduleName = '@pas/pas::versioning';
19
19
  export const Versioning = new MoveStruct({
20
20
  name: `${$moduleName}::Versioning`,
21
21
  fields: {
@@ -16,7 +16,7 @@ import {
16
16
  type Transaction as Transaction_1,
17
17
  type TransactionArgument,
18
18
  } from '@mysten/sui/transactions';
19
- const $moduleName = '@mysten/ptb::ptb';
19
+ const $moduleName = '@pas/ptb::ptb';
20
20
  export const Command = new MoveTuple({
21
21
  name: `${$moduleName}::Command`,
22
22
  fields: [bcs.u8(), bcs.vector(bcs.u8())],
@@ -9,7 +9,7 @@ import {
9
9
  BcsEnum,
10
10
  BcsTuple,
11
11
  } from '@mysten/sui/bcs';
12
- import { normalizeSuiAddress } from '@mysten/sui/utils';
12
+ import { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';
13
13
  import { type TransactionArgument, isArgument } from '@mysten/sui/transactions';
14
14
  import { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';
15
15
 
@@ -159,10 +159,143 @@ export function normalizeMoveArguments(
159
159
  return normalizedArgs;
160
160
  }
161
161
 
162
+ /* -------------------------- Move type tags -------------------------- */
163
+
164
+ /** A type argument: a type tag string, or a BCS type whose name is a Move type. */
165
+ export type TypeArgument = string | BcsType<any>;
166
+
167
+ export interface TypeTagOptions {
168
+ package?: string;
169
+ typeArguments?: readonly TypeArgument[];
170
+ }
171
+
172
+ /**
173
+ * `typeArguments` is required when the type's name contains unfilled
174
+ * `phantom X` parameters (at any depth). Everything else — argument arity,
175
+ * position contents, and tag validity — is validated at runtime.
176
+ */
177
+ type TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}`
178
+ ? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]
179
+ : [options?: TypeTagOptions];
180
+
181
+ type ResolveTypeTagOptions<Name extends string> = {
182
+ client: ClientWithCoreApi;
183
+ } & (Name extends `${string}phantom ${string}`
184
+ ? TypeTagOptions & { typeArguments: readonly TypeArgument[] }
185
+ : TypeTagOptions);
186
+
187
+ const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
188
+
189
+ function splitTopLevelTypeArgs(inner: string): string[] {
190
+ const parts: string[] = [];
191
+ let depth = 0;
192
+ let current = '';
193
+ for (const char of inner) {
194
+ if (char === ',' && depth === 0) {
195
+ parts.push(current.trim());
196
+ current = '';
197
+ continue;
198
+ }
199
+ if (char === '<') depth++;
200
+ if (char === '>') depth--;
201
+ current += char;
202
+ }
203
+ if (current) parts.push(current.trim());
204
+ return parts;
205
+ }
206
+
207
+ function buildTypeTag(name: string, options: TypeTagOptions | undefined): string {
208
+ const lt = name.indexOf('<');
209
+ const base = lt === -1 ? name : name.slice(0, lt);
210
+
211
+ if (base.split('::').length !== 3) {
212
+ throw new PASClientError(`${name} is not a top-level Move type`);
213
+ }
214
+
215
+ let result = name;
216
+
217
+ if (options?.typeArguments) {
218
+ const baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));
219
+ const supplied = options.typeArguments.map((arg) => {
220
+ if (typeof arg === 'string') {
221
+ return arg;
222
+ }
223
+ if (arg && typeof arg.serialize === 'function' && typeof arg.name === 'string') {
224
+ return arg.name;
225
+ }
226
+ throw new PASClientError(`Invalid type argument ${stringify(arg)}`);
227
+ });
228
+
229
+ if (supplied.length !== baked.length) {
230
+ throw new PASClientError(
231
+ `Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,
232
+ );
233
+ }
234
+
235
+ result = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;
236
+ }
237
+
238
+ if (HAS_PHANTOM_REGEX.test(result)) {
239
+ throw new PASClientError(
240
+ options?.typeArguments
241
+ ? `A type argument contains an unfilled phantom parameter in ${result}`
242
+ : `Missing type arguments for ${result}`,
243
+ );
244
+ }
245
+
246
+ if (options?.package) {
247
+ const [, ...rest] = result.split('::');
248
+ result = [options.package, ...rest].join('::');
249
+ }
250
+
251
+ // fully validate address-only tags (MVR names can't be parsed as type tags)
252
+ if (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {
253
+ TypeTagSerializer.parseFromStr(result);
254
+ }
255
+
256
+ return result;
257
+ }
258
+
259
+ async function resolveBuiltTypeTag(
260
+ name: string,
261
+ options: { client: ClientWithCoreApi } & TypeTagOptions,
262
+ ): Promise<string> {
263
+ const { client, ...rest } = options;
264
+ const { type } = await client.core.mvr.resolveType({
265
+ type: buildTypeTag(name, rest),
266
+ });
267
+ return normalizeStructTag(type);
268
+ }
269
+
162
270
  export class MoveStruct<
163
271
  T extends Record<string, BcsType<any>>,
164
272
  const Name extends string = string,
165
273
  > extends BcsStruct<T, Name> {
274
+ /**
275
+ * Build the type tag for this struct.
276
+ *
277
+ * `typeArguments` is the full positional list, in Move declaration order, and
278
+ * is required when the struct has unfilled phantom parameters. The result may
279
+ * contain MVR names: those are valid in transaction `typeArguments`, but for
280
+ * queries or comparisons against on-chain data use `resolveTypeTag` instead.
281
+ */
282
+ typeTag(...args: TypeTagParams<Name>): string {
283
+ return buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);
284
+ }
285
+
286
+ /**
287
+ * Build the type tag for this struct, then resolve any MVR names through the
288
+ * client (using its configured overrides and the MVR API) and return the
289
+ * normalized, address-only form suitable for queries and comparisons against
290
+ * on-chain data.
291
+ */
292
+ async resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {
293
+ return resolveBuiltTypeTag(
294
+ this.name,
295
+ options as { client: ClientWithCoreApi } & TypeTagOptions,
296
+ );
297
+ }
298
+
166
299
  async get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
167
300
  objectId,
168
301
  ...options
@@ -217,16 +350,44 @@ export class MoveStruct<
217
350
  export class MoveEnum<
218
351
  T extends Record<string, BcsType<any> | null>,
219
352
  const Name extends string,
220
- > extends BcsEnum<T, Name> {}
353
+ > extends BcsEnum<T, Name> {
354
+ /** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */
355
+ typeTag(...args: TypeTagParams<Name>): string {
356
+ return buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);
357
+ }
358
+
359
+ /** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */
360
+ async resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {
361
+ return resolveBuiltTypeTag(
362
+ this.name,
363
+ options as { client: ClientWithCoreApi } & TypeTagOptions,
364
+ );
365
+ }
366
+ }
221
367
 
222
368
  export class MoveTuple<
223
369
  const T extends readonly BcsType<any>[],
224
370
  const Name extends string,
225
- > extends BcsTuple<T, Name> {}
371
+ > extends BcsTuple<T, Name> {
372
+ /** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */
373
+ typeTag(...args: TypeTagParams<Name>): string {
374
+ return buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);
375
+ }
376
+
377
+ /** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */
378
+ async resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {
379
+ return resolveBuiltTypeTag(
380
+ this.name,
381
+ options as { client: ClientWithCoreApi } & TypeTagOptions,
382
+ );
383
+ }
384
+ }
226
385
 
227
386
  function stringify(val: unknown) {
228
387
  if (typeof val === 'object') {
229
- return JSON.stringify(val, (val: unknown) => val);
388
+ return JSON.stringify(val, (_key, value) =>
389
+ typeof value === 'bigint' ? value.toString() : value,
390
+ );
230
391
  }
231
392
  if (typeof val === 'bigint') {
232
393
  return val.toString();