@layerzerolabs/dw-model 0.2.44 → 0.2.46

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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/upgrade/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACjC,iFAAiF;IACjF,IAAI,EAAE,SAAS,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;iBAGrC,CAAC;AAEH,oBAAY,WAAW;IAEnB,eAAe,oBAAoB;IAEnC,KAAK,UAAU;IAEf,YAAY,iBAAiB;CAChC;AAED,oBAAY,YAAY;IAEpB,0BAA0B,+BAA+B;IAEzD,wBAAwB,6BAA6B;IAErD,oCAAoC,yCAAyC;IAE7E,0BAA0B,+BAA+B;IAEzD,wBAAwB,6BAA6B;CACxD;AAED,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,YAAY,CAGrD,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,YAAY,CAIpD,CAAC;AAEH,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,YAAY,CAG/D,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,WAAW,YAAY,KAAG,OAA0C,CAAC;AAEjG,qEAAqE;AACrE,eAAO,MAAM,UAAU,GAAI,WAAW,YAAY,KAAG,OAAyC,CAAC;AAE/F,wFAAwF;AACxF,eAAO,MAAM,gCAAgC,GAAI,WAAW,YAAY,KAAG,OAC9B,CAAC;AAE9C,eAAO,MAAM,SAAS;;;;;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AuB,CAAC,CAAC;AAExE,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,GAAI,qBAAqB,SAAS,iBAAiB,EAAE,EACrF,uBAAuB,qBAAqB,EAC5C,oBAAoB,iBAAiB,KACtC,QAAQ,iBAAiB,IAAI,qBAAqB,CAAC,MAAM,CAoC3D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,qBAAqB,SAAS,iBAAiB,EAAE,EACjF,uBAAuB,qBAAqB,EAE5C,oBAAoB,iBAAiB,KACtC,QAAQ,iBAAiB,IAAI,qBAAqB,CAAC,MAAM,CAM3D,CAAC"}
@@ -1,4 +1,4 @@
1
- export { EvmProxyType, ProxyType, SEPARATE_PROXY_ADMIN_TYPES, TUP_PROXY_TYPES, UUPS_PROXY_TYPES, UpgradeType, codeUpgradeableConfigSchema, initializeDataResultSchema, isTupProxy, isUupsProxy, notUpgradeableConfigSchema, proxyConfigSchema, proxyTypeSchema, requiresSeparateProxyAdminDeploy, upgradeTypeSchema, upgradeableConfigSchema } from '../46VB3YIH.js';
1
+ export { EvmProxyType, ProxyType, SEPARATE_PROXY_ADMIN_TYPES, TUP_PROXY_TYPES, UUPS_PROXY_TYPES, UpgradeType, assertUpgradability, codeUpgradeableConfigSchema, initializeDataResultSchema, isTupProxy, isUupsProxy, notUpgradeableConfigSchema, proxyConfigSchema, proxyTypeSchema, requiresSeparateProxyAdminDeploy, upgradeTypeSchema, upgradeableConfigSchema, weakAssertUpgradability } from '../BZJPR5LC.js';
2
2
  import '../VUOMXK5T.js';
3
3
  //# sourceMappingURL=types.js.map
4
4
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/dw-model",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,19 +15,19 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "dependencies": {
17
17
  "zod": "4.3.5",
18
- "@layerzerolabs/layerzero-definitions": "0.2.44",
19
- "@layerzerolabs/common-chain-model": "0.2.44",
20
- "@layerzerolabs/typescript-utils": "0.2.44",
21
- "@layerzerolabs/common-error-utils": "0.2.44",
22
- "@layerzerolabs/zod-utils": "0.2.44",
23
- "@layerzerolabs/gated-transaction": "0.2.44"
18
+ "@layerzerolabs/common-chain-model": "0.2.46",
19
+ "@layerzerolabs/gated-transaction": "0.2.46",
20
+ "@layerzerolabs/common-error-utils": "0.2.46",
21
+ "@layerzerolabs/layerzero-definitions": "0.2.46",
22
+ "@layerzerolabs/typescript-utils": "0.2.46",
23
+ "@layerzerolabs/zod-utils": "0.2.46"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@mysten/sui": "^1.35.0",
27
27
  "tsup": "^8.4.0",
28
28
  "vitest": "^3.2.3",
29
- "@layerzerolabs/tsup-configuration": "0.2.44",
30
- "@layerzerolabs/typescript-configuration": "0.2.44"
29
+ "@layerzerolabs/typescript-configuration": "0.2.46",
30
+ "@layerzerolabs/tsup-configuration": "0.2.46"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "restricted",
@@ -1,27 +1,22 @@
1
1
  import z from 'zod';
2
2
 
3
3
  import { decimalStringSchema, hexSchema } from '@layerzerolabs/common-chain-model';
4
- import type { DecimalString, HexString } from '@layerzerolabs/typescript-utils';
5
-
6
- /**
7
- * Result type for `getInitializeData` function pointer.
8
- * Contains the encoded initialization data and an optional gas limit override.
9
- */
10
- export interface InitializeDataResult {
11
- /** Encoded initialization data (e.g., encodeFunctionData for initialize(...)) */
12
- data: HexString;
13
- /** Optional gas limit override for the initialization transaction */
14
- gasLimit?: DecimalString;
15
- }
4
+ import { assertUnreachable, NonRetryableError } from '@layerzerolabs/common-error-utils';
5
+ import type { Identity } from '@layerzerolabs/typescript-utils';
16
6
 
17
7
  /**
18
8
  * `InitializeDataResult` schema.
19
9
  */
20
10
  export const initializeDataResultSchema = z.object({
11
+ /** Encoded initialization data (e.g., encodeFunctionData for initialize(...)) */
21
12
  data: hexSchema,
13
+ /** Optional gas limit override for the initialization transaction */
22
14
  gasLimit: decimalStringSchema.optional(),
23
15
  });
24
16
 
17
+ export interface InitializeDataResult
18
+ extends Identity<z.infer<typeof initializeDataResultSchema>> {}
19
+
25
20
  export enum UpgradeType {
26
21
  // This doesn't necessarily prevent the contract from being upgraded
27
22
  NOT_UPGRADEABLE = 'NOT_UPGRADEABLE',
@@ -108,3 +103,57 @@ export const upgradeableConfigSchema = z.discriminatedUnion('upgradeType', [
108
103
  ]);
109
104
 
110
105
  export type UpgradeableConfig = z.infer<typeof upgradeableConfigSchema>;
106
+
107
+ /** @deprecated use assertUpgradability, ensure your config is nonoptional */
108
+ export const weakAssertUpgradability = <AllowedUpgradeConfigs extends UpgradeableConfig[]>(
109
+ allowedUpgradeConfigs: AllowedUpgradeConfigs,
110
+ upgradeableConfig?: UpgradeableConfig,
111
+ ): asserts upgradeableConfig is AllowedUpgradeConfigs[number] => {
112
+ if (!upgradeableConfig) {
113
+ return;
114
+ }
115
+
116
+ if (
117
+ allowedUpgradeConfigs.some((allowedConfig) => {
118
+ if (allowedConfig.upgradeType !== upgradeableConfig.upgradeType) {
119
+ return false;
120
+ }
121
+
122
+ if (allowedConfig.upgradeType === UpgradeType.NOT_UPGRADEABLE) {
123
+ return true;
124
+ }
125
+
126
+ if (allowedConfig.upgradeType === UpgradeType.CODE_UPGRADE) {
127
+ return true;
128
+ }
129
+
130
+ if (allowedConfig.upgradeType === UpgradeType.PROXY) {
131
+ return (
132
+ allowedConfig.proxyType ===
133
+ (upgradeableConfig as ProxyUpgradeableConfig).proxyType
134
+ );
135
+ }
136
+
137
+ assertUnreachable(allowedConfig);
138
+ })
139
+ ) {
140
+ // included in allowed array
141
+ return;
142
+ }
143
+
144
+ throw new NonRetryableError(
145
+ `Upgrade config ${JSON.stringify(upgradeableConfig)} is not compatible with any of the allowed upgrade configs ${JSON.stringify(allowedUpgradeConfigs)}`,
146
+ );
147
+ };
148
+
149
+ export const assertUpgradability = <AllowedUpgradeConfigs extends UpgradeableConfig[]>(
150
+ allowedUpgradeConfigs: AllowedUpgradeConfigs,
151
+ // eventually make this nonoptional once callers are upgraded
152
+ upgradeableConfig?: UpgradeableConfig,
153
+ ): asserts upgradeableConfig is AllowedUpgradeConfigs[number] => {
154
+ if (!upgradeableConfig) {
155
+ throw new NonRetryableError('Will not handle undefined upgrade config');
156
+ }
157
+
158
+ return weakAssertUpgradability(allowedUpgradeConfigs, upgradeableConfig);
159
+ };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/upgrade/types.ts"],"names":["initializeDataResultSchema","z","object","data","hexSchema","gasLimit","decimalStringSchema","optional","UpgradeType","EvmProxyType","UUPS_PROXY_TYPES","Set","TUP_PROXY_TYPES","SEPARATE_PROXY_ADMIN_TYPES","isUupsProxy","proxyType","has","isTupProxy","requiresSeparateProxyAdminDeploy","ProxyType","upgradeTypeSchema","enum","proxyTypeSchema","proxyConfigSchema","upgradeType","literal","notUpgradeableConfigSchema","codeUpgradeableConfigSchema","upgradeableConfigSchema","discriminatedUnion"],"mappings":";;;;AAmBO,IAAMA,0BAAAA,GAA6BC,EAAEC,MAAAA,CAAO;EAC/CC,IAAAA,EAAMC,SAAAA;AACNC,EAAAA,QAAAA,EAAUC,oBAAoBC,QAAAA;AAClC,CAAA;AAEO,IAAKC,WAAAA,6BAAAA,YAAAA,EAAAA;;;;AAAAA,EAAAA,OAAAA,YAAAA;;AASL,IAAKC,YAAAA,6BAAAA,aAAAA,EAAAA;;;;;;AAAAA,EAAAA,OAAAA,aAAAA;;AAcL,IAAMC,gBAAAA,uBAAkDC,GAAAA,CAAI;;;AAGlE,CAAA;AAGM,IAAMC,eAAAA,uBAAiDD,GAAAA,CAAI;;;;AAIjE,CAAA;AAGM,IAAME,0BAAAA,uBAA4DF,GAAAA,CAAI;;;AAG5E,CAAA;AAGM,IAAMG,8BAAc,MAAA,CAAA,CAACC,SAAAA,KAAqCL,gBAAAA,CAAiBM,GAAAA,CAAID,SAAAA,CAAAA,EAA3D,aAAA;AAGpB,IAAME,6BAAa,MAAA,CAAA,CAACF,SAAAA,KAAqCH,eAAAA,CAAgBI,GAAAA,CAAID,SAAAA,CAAAA,EAA1D,YAAA;AAGnB,IAAMG,mDAAmC,MAAA,CAAA,CAACH,SAAAA,KAC7CF,0BAAAA,CAA2BG,GAAAA,CAAID,SAAAA,CAAAA,EADa,kCAAA;AAGzC,IAAMI,SAAAA,GAAY;EACrB,GAAGV;AACP;AAIO,IAAMW,iBAAAA,GAAoBnB,CAAAA,CAAEoB,IAAAA,CAAKb,WAAAA;AAEjC,IAAMc,eAAAA,GAAkBrB,CAAAA,CAAEoB,IAAAA,CAAKF,SAAAA;AAC/B,IAAMI,iBAAAA,GAAoBtB,EAAEC,MAAAA,CAAO;EACtCsB,WAAAA,EAAavB,CAAAA,CAAEwB,QAAO,OAAA,CAAA;EACtBV,SAAAA,EAAWO;AACf,CAAA;AAIO,IAAMI,0BAAAA,GAA6BzB,EAAEC,MAAAA,CAAO;EAC/CsB,WAAAA,EAAavB,CAAAA,CAAEwB,QAAO,iBAAA;AAC1B,CAAA;AAIO,IAAME,2BAAAA,GAA8B1B,EAAEC,MAAAA,CAAO;EAChDsB,WAAAA,EAAavB,CAAAA,CAAEwB,QAAO,cAAA;AAC1B,CAAA;AAIO,IAAMG,uBAAAA,GAA0B3B,CAAAA,CAAE4B,kBAAAA,CAAmB,aAAA,EAAe;AACvEN,EAAAA,iBAAAA;AACAG,EAAAA,0BAAAA;AACAC,EAAAA;AACH,CAAA","file":"46VB3YIH.js","sourcesContent":["import z from 'zod';\n\nimport { decimalStringSchema, hexSchema } from '@layerzerolabs/common-chain-model';\nimport type { DecimalString, HexString } from '@layerzerolabs/typescript-utils';\n\n/**\n * Result type for `getInitializeData` function pointer.\n * Contains the encoded initialization data and an optional gas limit override.\n */\nexport interface InitializeDataResult {\n /** Encoded initialization data (e.g., encodeFunctionData for initialize(...)) */\n data: HexString;\n /** Optional gas limit override for the initialization transaction */\n gasLimit?: DecimalString;\n}\n\n/**\n * `InitializeDataResult` schema.\n */\nexport const initializeDataResultSchema = z.object({\n data: hexSchema,\n gasLimit: decimalStringSchema.optional(),\n});\n\nexport enum UpgradeType {\n // This doesn't necessarily prevent the contract from being upgraded\n NOT_UPGRADEABLE = 'NOT_UPGRADEABLE',\n // Deploy a separate 'proxy' contract that will route calls to a swappable implementation\n PROXY = 'PROXY',\n // This doesn't necessarily allow the contract to be upgraded\n CODE_UPGRADE = 'CODE_UPGRADE',\n}\n\nexport enum EvmProxyType {\n // TUP v5 https://docs.openzeppelin.com/contracts/5.x/api/proxy#transparentupgradeableproxy\n TRANSPARENT_UPGRADEABLE_V5 = 'TRANSPARENT_UPGRADEABLE_V5',\n // UUPS v5 https://docs.openzeppelin.com/contracts/5.x/api/proxy#uupsupgradeable\n UNIVERSAL_UPGRADEABLE_V5 = 'UNIVERSAL_UPGRADEABLE_V5',\n // OTUP v4 https://github.com/wighawag/hardhat-deploy/blob/v0.12.1/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\n OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4 = 'OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4',\n // TUP v4 https://docs.openzeppelin.com/contracts/4.x/api/proxy#TransparentUpgradeableProxy\n TRANSPARENT_UPGRADEABLE_V4 = 'TRANSPARENT_UPGRADEABLE_V4',\n // UUPS v4 https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable\n UNIVERSAL_UPGRADEABLE_V4 = 'UNIVERSAL_UPGRADEABLE_V4',\n}\n\n/** UUPS-based proxy types (no separate `ProxyAdmin`). */\nexport const UUPS_PROXY_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.UNIVERSAL_UPGRADEABLE_V4,\n EvmProxyType.UNIVERSAL_UPGRADEABLE_V5,\n]);\n\n/** TUP-based proxy types (have a `ProxyAdmin` with `getOwner`/`setOwner`). */\nexport const TUP_PROXY_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V4,\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V5,\n EvmProxyType.OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4,\n]);\n\n/** Proxy types that deploy a separate `ProxyAdmin` contract (v4 variants only). */\nexport const SEPARATE_PROXY_ADMIN_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V4,\n EvmProxyType.OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4,\n]);\n\n/** Whether the proxy type is UUPS (Universal Upgradeable Proxy Standard). */\nexport const isUupsProxy = (proxyType: EvmProxyType): boolean => UUPS_PROXY_TYPES.has(proxyType);\n\n/** Whether the proxy type is TUP (Transparent Upgradeable Proxy). */\nexport const isTupProxy = (proxyType: EvmProxyType): boolean => TUP_PROXY_TYPES.has(proxyType);\n\n/** Whether the proxy type requires a separate `ProxyAdmin` deployment (v4 variants). */\nexport const requiresSeparateProxyAdminDeploy = (proxyType: EvmProxyType): boolean =>\n SEPARATE_PROXY_ADMIN_TYPES.has(proxyType);\n\nexport const ProxyType = {\n ...EvmProxyType,\n};\n\nexport type ProxyType = (typeof ProxyType)[keyof typeof ProxyType];\n\nexport const upgradeTypeSchema = z.enum(UpgradeType);\n\nexport const proxyTypeSchema = z.enum(ProxyType);\nexport const proxyConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.PROXY),\n proxyType: proxyTypeSchema,\n});\n\nexport type ProxyUpgradeableConfig = z.infer<typeof proxyConfigSchema>;\n\nexport const notUpgradeableConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.NOT_UPGRADEABLE),\n});\n\nexport type NotUpgradeableConfig = z.infer<typeof notUpgradeableConfigSchema>;\n\nexport const codeUpgradeableConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.CODE_UPGRADE),\n});\n\nexport type CodeUpgradeableConfig = z.infer<typeof codeUpgradeableConfigSchema>;\n\nexport const upgradeableConfigSchema = z.discriminatedUnion('upgradeType', [\n proxyConfigSchema,\n notUpgradeableConfigSchema,\n codeUpgradeableConfigSchema,\n]);\n\nexport type UpgradeableConfig = z.infer<typeof upgradeableConfigSchema>;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/upgrade/types.ts"],"names":["initializeDataResultSchema","z","object","data","hexSchema","gasLimit","decimalStringSchema","optional","UpgradeType","EvmProxyType","UUPS_PROXY_TYPES","Set","TUP_PROXY_TYPES","SEPARATE_PROXY_ADMIN_TYPES","isUupsProxy","__name","proxyType","has","isTupProxy","requiresSeparateProxyAdminDeploy","ProxyType","upgradeTypeSchema","enum","proxyTypeSchema","proxyConfigSchema","upgradeType","literal","notUpgradeableConfigSchema","codeUpgradeableConfigSchema","upgradeableConfigSchema","discriminatedUnion"],"mappings":";;;;;;;;;;AAmBO,IAAMA,0BAAAA,GAA6BC,mBAAEC,MAAAA,CAAO;EAC/CC,IAAAA,EAAMC,0BAAAA;AACNC,EAAAA,QAAAA,EAAUC,qCAAoBC,QAAAA;AAClC,CAAA;AAEO,IAAKC,WAAAA,6BAAAA,YAAAA,EAAAA;;;;AAAAA,EAAAA,OAAAA,YAAAA;;AASL,IAAKC,YAAAA,6BAAAA,aAAAA,EAAAA;;;;;;AAAAA,EAAAA,OAAAA,aAAAA;;AAcL,IAAMC,gBAAAA,uBAAkDC,GAAAA,CAAI;;;AAGlE,CAAA;AAGM,IAAMC,eAAAA,uBAAiDD,GAAAA,CAAI;;;;AAIjE,CAAA;AAGM,IAAME,0BAAAA,uBAA4DF,GAAAA,CAAI;;;AAG5E,CAAA;AAGM,IAAMG,8BAAcC,mBAAA,CAAA,CAACC,SAAAA,KAAqCN,gBAAAA,CAAiBO,GAAAA,CAAID,SAAAA,CAAAA,EAA3D,aAAA;AAGpB,IAAME,6BAAaH,mBAAA,CAAA,CAACC,SAAAA,KAAqCJ,eAAAA,CAAgBK,GAAAA,CAAID,SAAAA,CAAAA,EAA1D,YAAA;AAGnB,IAAMG,mDAAmCJ,mBAAA,CAAA,CAACC,SAAAA,KAC7CH,0BAAAA,CAA2BI,GAAAA,CAAID,SAAAA,CAAAA,EADa,kCAAA;AAGzC,IAAMI,SAAAA,GAAY;EACrB,GAAGX;AACP;AAIO,IAAMY,iBAAAA,GAAoBpB,kBAAAA,CAAEqB,IAAAA,CAAKd,WAAAA;AAEjC,IAAMe,eAAAA,GAAkBtB,kBAAAA,CAAEqB,IAAAA,CAAKF,SAAAA;AAC/B,IAAMI,iBAAAA,GAAoBvB,mBAAEC,MAAAA,CAAO;EACtCuB,WAAAA,EAAaxB,kBAAAA,CAAEyB,QAAO,OAAA,CAAA;EACtBV,SAAAA,EAAWO;AACf,CAAA;AAIO,IAAMI,0BAAAA,GAA6B1B,mBAAEC,MAAAA,CAAO;EAC/CuB,WAAAA,EAAaxB,kBAAAA,CAAEyB,QAAO,iBAAA;AAC1B,CAAA;AAIO,IAAME,2BAAAA,GAA8B3B,mBAAEC,MAAAA,CAAO;EAChDuB,WAAAA,EAAaxB,kBAAAA,CAAEyB,QAAO,cAAA;AAC1B,CAAA;AAIO,IAAMG,uBAAAA,GAA0B5B,kBAAAA,CAAE6B,kBAAAA,CAAmB,aAAA,EAAe;AACvEN,EAAAA,iBAAAA;AACAG,EAAAA,0BAAAA;AACAC,EAAAA;AACH,CAAA","file":"S5CHYZ3I.cjs","sourcesContent":["import z from 'zod';\n\nimport { decimalStringSchema, hexSchema } from '@layerzerolabs/common-chain-model';\nimport type { DecimalString, HexString } from '@layerzerolabs/typescript-utils';\n\n/**\n * Result type for `getInitializeData` function pointer.\n * Contains the encoded initialization data and an optional gas limit override.\n */\nexport interface InitializeDataResult {\n /** Encoded initialization data (e.g., encodeFunctionData for initialize(...)) */\n data: HexString;\n /** Optional gas limit override for the initialization transaction */\n gasLimit?: DecimalString;\n}\n\n/**\n * `InitializeDataResult` schema.\n */\nexport const initializeDataResultSchema = z.object({\n data: hexSchema,\n gasLimit: decimalStringSchema.optional(),\n});\n\nexport enum UpgradeType {\n // This doesn't necessarily prevent the contract from being upgraded\n NOT_UPGRADEABLE = 'NOT_UPGRADEABLE',\n // Deploy a separate 'proxy' contract that will route calls to a swappable implementation\n PROXY = 'PROXY',\n // This doesn't necessarily allow the contract to be upgraded\n CODE_UPGRADE = 'CODE_UPGRADE',\n}\n\nexport enum EvmProxyType {\n // TUP v5 https://docs.openzeppelin.com/contracts/5.x/api/proxy#transparentupgradeableproxy\n TRANSPARENT_UPGRADEABLE_V5 = 'TRANSPARENT_UPGRADEABLE_V5',\n // UUPS v5 https://docs.openzeppelin.com/contracts/5.x/api/proxy#uupsupgradeable\n UNIVERSAL_UPGRADEABLE_V5 = 'UNIVERSAL_UPGRADEABLE_V5',\n // OTUP v4 https://github.com/wighawag/hardhat-deploy/blob/v0.12.1/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\n OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4 = 'OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4',\n // TUP v4 https://docs.openzeppelin.com/contracts/4.x/api/proxy#TransparentUpgradeableProxy\n TRANSPARENT_UPGRADEABLE_V4 = 'TRANSPARENT_UPGRADEABLE_V4',\n // UUPS v4 https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable\n UNIVERSAL_UPGRADEABLE_V4 = 'UNIVERSAL_UPGRADEABLE_V4',\n}\n\n/** UUPS-based proxy types (no separate `ProxyAdmin`). */\nexport const UUPS_PROXY_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.UNIVERSAL_UPGRADEABLE_V4,\n EvmProxyType.UNIVERSAL_UPGRADEABLE_V5,\n]);\n\n/** TUP-based proxy types (have a `ProxyAdmin` with `getOwner`/`setOwner`). */\nexport const TUP_PROXY_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V4,\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V5,\n EvmProxyType.OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4,\n]);\n\n/** Proxy types that deploy a separate `ProxyAdmin` contract (v4 variants only). */\nexport const SEPARATE_PROXY_ADMIN_TYPES: ReadonlySet<EvmProxyType> = new Set([\n EvmProxyType.TRANSPARENT_UPGRADEABLE_V4,\n EvmProxyType.OPTIMIZED_TRANSPARENT_UPGRADEABLE_V4,\n]);\n\n/** Whether the proxy type is UUPS (Universal Upgradeable Proxy Standard). */\nexport const isUupsProxy = (proxyType: EvmProxyType): boolean => UUPS_PROXY_TYPES.has(proxyType);\n\n/** Whether the proxy type is TUP (Transparent Upgradeable Proxy). */\nexport const isTupProxy = (proxyType: EvmProxyType): boolean => TUP_PROXY_TYPES.has(proxyType);\n\n/** Whether the proxy type requires a separate `ProxyAdmin` deployment (v4 variants). */\nexport const requiresSeparateProxyAdminDeploy = (proxyType: EvmProxyType): boolean =>\n SEPARATE_PROXY_ADMIN_TYPES.has(proxyType);\n\nexport const ProxyType = {\n ...EvmProxyType,\n};\n\nexport type ProxyType = (typeof ProxyType)[keyof typeof ProxyType];\n\nexport const upgradeTypeSchema = z.enum(UpgradeType);\n\nexport const proxyTypeSchema = z.enum(ProxyType);\nexport const proxyConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.PROXY),\n proxyType: proxyTypeSchema,\n});\n\nexport type ProxyUpgradeableConfig = z.infer<typeof proxyConfigSchema>;\n\nexport const notUpgradeableConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.NOT_UPGRADEABLE),\n});\n\nexport type NotUpgradeableConfig = z.infer<typeof notUpgradeableConfigSchema>;\n\nexport const codeUpgradeableConfigSchema = z.object({\n upgradeType: z.literal(UpgradeType.CODE_UPGRADE),\n});\n\nexport type CodeUpgradeableConfig = z.infer<typeof codeUpgradeableConfigSchema>;\n\nexport const upgradeableConfigSchema = z.discriminatedUnion('upgradeType', [\n proxyConfigSchema,\n notUpgradeableConfigSchema,\n codeUpgradeableConfigSchema,\n]);\n\nexport type UpgradeableConfig = z.infer<typeof upgradeableConfigSchema>;\n"]}