@layerzerolabs/dw-model 0.2.45 → 0.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.turbo/turbo-build.log +102 -102
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/dist/{3BD3OCGS.js → 3GB3YEFM.js} +3 -3
  4. package/dist/{3BD3OCGS.js.map → 3GB3YEFM.js.map} +1 -1
  5. package/dist/{3CKHMU36.js → 3JL3PUIU.js} +3 -3
  6. package/dist/{3CKHMU36.js.map → 3JL3PUIU.js.map} +1 -1
  7. package/dist/{7MOCL6HP.js → 5OKHFG46.js} +4 -4
  8. package/dist/{7MOCL6HP.js.map → 5OKHFG46.js.map} +1 -1
  9. package/dist/{7W7RMRK7.cjs → 7DA753OB.cjs} +9 -9
  10. package/dist/{7W7RMRK7.cjs.map → 7DA753OB.cjs.map} +1 -1
  11. package/dist/{ECJRGALM.cjs → DE7P6XTU.cjs} +3 -3
  12. package/dist/{ECJRGALM.cjs.map → DE7P6XTU.cjs.map} +1 -1
  13. package/dist/{S5CHYZ3I.cjs → HH5WI3G5.cjs} +36 -2
  14. package/dist/HH5WI3G5.cjs.map +1 -0
  15. package/dist/{PUY2AOFE.cjs → IJZQPF4A.cjs} +6 -6
  16. package/dist/IJZQPF4A.cjs.map +1 -0
  17. package/dist/{6G3GY5VH.cjs → R4HLXLGU.cjs} +4 -4
  18. package/dist/{6G3GY5VH.cjs.map → R4HLXLGU.cjs.map} +1 -1
  19. package/dist/{KOUHMVGI.cjs → T6BMFWCI.cjs} +19 -19
  20. package/dist/{KOUHMVGI.cjs.map → T6BMFWCI.cjs.map} +1 -1
  21. package/dist/{RYSOAAMJ.js → XE5ATSYV.js} +8 -8
  22. package/dist/{RYSOAAMJ.js.map → XE5ATSYV.js.map} +1 -1
  23. package/dist/{46VB3YIH.js → YAEJZ74R.js} +36 -4
  24. package/dist/YAEJZ74R.js.map +1 -0
  25. package/dist/{IUFXXZ2R.js → YQCUJB6A.js} +5 -5
  26. package/dist/YQCUJB6A.js.map +1 -0
  27. package/dist/deploy/artifact.cjs +10 -10
  28. package/dist/deploy/artifact.js +1 -1
  29. package/dist/deploy/factoryInterfaces.cjs +9 -9
  30. package/dist/deploy/factoryInterfaces.js +3 -3
  31. package/dist/deploy/index.cjs +48 -48
  32. package/dist/deploy/index.js +6 -6
  33. package/dist/deploy/resourceBuilder.cjs +2 -2
  34. package/dist/deploy/resourceBuilder.js +1 -1
  35. package/dist/deploy/resources.cjs +17 -17
  36. package/dist/deploy/resources.js +2 -2
  37. package/dist/deploy/workflow.cjs +13 -13
  38. package/dist/deploy/workflow.js +2 -2
  39. package/dist/index.cjs +72 -64
  40. package/dist/index.js +6 -6
  41. package/dist/upgrade/index.cjs +25 -17
  42. package/dist/upgrade/index.js +1 -1
  43. package/dist/upgrade/types.cjs +25 -17
  44. package/dist/upgrade/types.d.ts +7 -12
  45. package/dist/upgrade/types.d.ts.map +1 -1
  46. package/dist/upgrade/types.js +1 -1
  47. package/package.json +9 -9
  48. package/src/deploy/artifact.ts +6 -6
  49. package/src/deploy/factoryInterfaces.ts +6 -6
  50. package/src/deploy/resourceBuilder.ts +1 -1
  51. package/src/deploy/resources.ts +6 -6
  52. package/src/upgrade/types.ts +61 -12
  53. package/dist/46VB3YIH.js.map +0 -1
  54. package/dist/IUFXXZ2R.js.map +0 -1
  55. package/dist/PUY2AOFE.cjs.map +0 -1
  56. package/dist/S5CHYZ3I.cjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/dw-model",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
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/common-chain-model": "0.2.45",
19
- "@layerzerolabs/common-error-utils": "0.2.45",
20
- "@layerzerolabs/typescript-utils": "0.2.45",
21
- "@layerzerolabs/gated-transaction": "0.2.45",
22
- "@layerzerolabs/layerzero-definitions": "0.2.45",
23
- "@layerzerolabs/zod-utils": "0.2.45"
18
+ "@layerzerolabs/common-chain-model": "0.2.47",
19
+ "@layerzerolabs/common-error-utils": "0.2.47",
20
+ "@layerzerolabs/layerzero-definitions": "0.2.47",
21
+ "@layerzerolabs/gated-transaction": "0.2.47",
22
+ "@layerzerolabs/typescript-utils": "0.2.47",
23
+ "@layerzerolabs/zod-utils": "0.2.47"
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.45",
30
- "@layerzerolabs/typescript-configuration": "0.2.45"
29
+ "@layerzerolabs/tsup-configuration": "0.2.47",
30
+ "@layerzerolabs/typescript-configuration": "0.2.47"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "restricted",
@@ -8,13 +8,13 @@ export type { ChainName };
8
8
  export type { SuiObjectChange };
9
9
 
10
10
  export enum ArtifactType {
11
- // should merge deployment, verification artifacts
11
+ // Should merge deployment, verification artifacts
12
12
 
13
- // full record from deployment on-chain
13
+ // Full record from deployment on-chain
14
14
  DEPLOYMENT = 'deployment',
15
- // information to verify contracts
15
+ // Information to verify contracts
16
16
  VERIFICATION = 'verification',
17
- // record of a successful push to lz metadata
17
+ // Record of a successful push to lz metadata
18
18
  METADATA = 'metadata',
19
19
  }
20
20
 
@@ -58,7 +58,7 @@ export type FullDeploymentArtifact = z.infer<typeof fullDeploymentArtifactSchema
58
58
 
59
59
  // TODO: riley — decide whether to migrate stored identity-only artifacts to full artifacts and collapse this union into fullDeploymentArtifactSchema
60
60
  export const deploymentArtifactSchema = z.union([
61
- // check this first since it's a superset
61
+ // Check this first since it's a superset
62
62
  fullDeploymentArtifactSchema,
63
63
  identityOnlyDeploymentArtifactSchema,
64
64
  ]);
@@ -72,7 +72,7 @@ export type VerificationArtifact = z.infer<typeof verificationArtifactSchema>;
72
72
  export const metadataArtifactSchema = z.object({
73
73
  jobId: z.string(),
74
74
  pushedAt: z.number(),
75
- // we can type this fully but probably needs to happen later
75
+ // We can type this fully but probably needs to happen later
76
76
  metadataResources: z.array(z.any()),
77
77
  });
78
78
 
@@ -10,11 +10,11 @@ import { getVerificationBaseArgsSchema, saveVerificationBaseArgsSchema } from '.
10
10
 
11
11
  export const resourceRefSchema = z.object({
12
12
  resourceId: z.string(),
13
- // some resources can have multiple realIDs, leave this undefined for the default
13
+ // Some resources can have multiple realIDs, leave this undefined for the default
14
14
  resourceSubKey: z.string().optional(),
15
15
  });
16
16
 
17
- // the real realID that might exist
17
+ // The real realID that might exist
18
18
  export const realIdSchema = z.object({
19
19
  realIdKey: z.string(),
20
20
  // some realIDs are scoped to a chain, some aren't
@@ -30,7 +30,7 @@ export const artifactRegistryActivityFactorySchema = z.object({
30
30
  }),
31
31
  ]),
32
32
  output: z.promise(artifactWithTypeSchema.optional()),
33
- // typing to make it generic on artifact type
33
+ // Typing to make it generic on artifact type
34
34
  }) as z.ZodType<
35
35
  <Type extends ArtifactType>(args: {
36
36
  artifactType: Type;
@@ -48,9 +48,9 @@ export const artifactRegistryActivityFactorySchema = z.object({
48
48
  output: z.promise(z.void()),
49
49
  }),
50
50
 
51
- // these internally are the same as getArtifact/saveArtifact, just specific argument shapes to match
52
- // the function pointer expected by the DeployOrchestratorWorkflow
53
- // we can refactor DeployOrchestratorWorkflow to remove this
51
+ // These internally are the same as getArtifact/saveArtifact, just specific argument shapes to match
52
+ // the function pointer expected by the `DeployOrchestratorWorkflow`
53
+ // We can refactor `DeployOrchestratorWorkflow` to remove this
54
54
  getDeployment: functionSchema({
55
55
  input: z.tuple([
56
56
  z.object({
@@ -75,5 +75,5 @@ export const createResourceBuilder =
75
75
  } satisfies MeshResourceBuilderResult<any> as any;
76
76
  }
77
77
 
78
- throw new Error(`Can't handle resouceBaseType "${resourceBaseType}"`);
78
+ throw new Error(`Can't handle resourceBaseType "${resourceBaseType}"`);
79
79
  };
@@ -44,7 +44,7 @@ export type BaseMeshResource = z.infer<typeof baseMeshResourceSchema>;
44
44
  export type BaseContractResource = z.infer<typeof baseContractResourceSchema>;
45
45
  export type BaseIntrinsicAddressContractResource = z.infer<ReturnType<typeof withIntrinsicAddress>>;
46
46
 
47
- // the actual expected runtime value for this type is #C_REF:${id}
47
+ // The actual expected runtime value for this type is #C_REF:${id}
48
48
  export type ContractResourceReference<T extends BaseContractResource = BaseContractResource> = {
49
49
  /** WARNING: these fields are not present at runtime */
50
50
  __resourceReferenceType: T;
@@ -56,14 +56,14 @@ export const extractIdFromContractResourceReference = (ref: ContractResourceRefe
56
56
  (ref as unknown as string).slice('#C_REF:'.length)) ||
57
57
  throwError(`Ref ${JSON.stringify(ref)} is not a contract resource ref`);
58
58
 
59
- // use z.ZodType<BaseContractResource> because want to allow unions
59
+ // Use z.ZodType<BaseContractResource> because we want to allow unions
60
60
  export type ContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> = z.ZodType<
61
61
  ContractResourceReference<z.infer<T>>
62
62
  >;
63
63
 
64
64
  export const contractResourceReferenceSchema: ContractResourceReferenceSchema<
65
65
  z.ZodType<BaseContractResource>
66
- // at runtime, we expect a string
66
+ // At runtime, we expect a string
67
67
  > = z.string().meta({
68
68
  id: 'contract-resource-dependency',
69
69
  title: 'Contract dependency to any',
@@ -77,8 +77,8 @@ export const contractResourceReferenceSchemaFor = <T extends z.ZodType<BaseContr
77
77
  ): ContractResourceReferenceSchema<T> =>
78
78
  z.string().meta({
79
79
  id: `contract-resource-dependency-for-${++contractResourceDependencyForSchemaZodMetaIdIdx}`,
80
- // we can't generate this properly yet because this function needs more information
81
- // will be fixed when we clean up the runtime of dependencies id
80
+ // We can't generate this properly yet because this function needs more information
81
+ // Will be fixed when we clean up the runtime dependency ID resolution
82
82
  title: 'Contract dependency to (unknown)',
83
83
  description: 'A reference to another contract resource (unknown)',
84
84
  }) as unknown as z.ZodType<ContractResourceReference<z.infer<T>>>;
@@ -96,7 +96,7 @@ export const resolvedContractResourceReferenceSchema: ResolvedContractResourceRe
96
96
  // FIXME could be a real schema
97
97
  z.custom<ResolvedContractResourceReference<any>>();
98
98
 
99
- // the actual expected runtime value for this type is #M_REF:${id}
99
+ // The actual expected runtime value for this type is #M_REF:${id}
100
100
  export type MeshResourceReference<T extends BaseMeshResource = BaseMeshResource> = {
101
101
  /** WARNING: these fields are not present at runtime */
102
102
  __resourceReferenceType: T;
@@ -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/deploy/resources.ts"],"names":["baseResourceSchema","z","object","id","string","name","optional","resourceBaseType","baseMeshResourceSchema","shape","literal","baseContractResourceSchema","chainName","enum","ChainName","upgradeConfig","upgradeableConfigSchema","verifyContract","boolean","chainConfig","any","withIntrinsicAddress","resourceSchema","_INTRINSIC_normalizedAddress","normalizedHexSchema","extractIdFromContractResourceReference","ref","startsWith","slice","length","throwError","JSON","stringify","contractResourceReferenceSchema","meta","title","description","contractResourceDependencyForSchemaZodMetaIdIdx","contractResourceReferenceSchemaFor","_resource","resolvedContractResourceReferenceSchema","custom","meshResourceReferenceSchema","meshResourceDependencyForSchemaZodMetaIdIdx","meshResourceReferenceSchemaFor","extractIdFromMeshResourceReference","resolvedMeshResourceReferenceSchema","extractContractResourceReferences","resource","Object","entries","filter","extractMeshResourceReferences","createResolvedResourceSchema"],"mappings":";;;;;;;AASO,IAAMA,kBAAAA,GAAqBC,EAAEC,MAAAA,CAAO;AACvCC,EAAAA,EAAAA,EAAIF,EAAEG,MAAAA,EAAM;EACZC,IAAAA,EAAMJ,CAAAA,CAAEG,MAAAA,EAAM,CAAGE,QAAAA,EAAQ;AACzBC,EAAAA,gBAAAA,EAAkBN,EAAEG,MAAAA;AACxB,CAAA;AAEO,IAAMI,sBAAAA,GAAyBP,EAAEC,MAAAA,CAAO;AAC3C,EAAA,GAAGF,kBAAAA,CAAmBS,KAAAA;EACtBF,gBAAAA,EAAkBN,CAAAA,CAAES,QAAQ,MAAA;AAChC,CAAA;AAEO,IAAMC,0BAAAA,GAA6BV,EAAEC,MAAAA,CAAO;AAC/C,EAAA,GAAGF,kBAAAA,CAAmBS,KAAAA;EACtBF,gBAAAA,EAAkBN,CAAAA,CAAES,QAAQ,UAAA,CAAA;EAC5BE,SAAAA,EAAWX,CAAAA,CAAEY,KAAKC,SAAAA,CAAAA;AAClBC,EAAAA,aAAAA,EAAeC,wBAAwBV,QAAAA,EAAQ;EAC/CW,cAAAA,EAAgBhB,CAAAA,CAAEiB,OAAAA,EAAO,CAAGZ,QAAAA,EAAQ;EAEpCa,WAAAA,EAAalB,CAAAA,CAAEmB,GAAAA,EAAG,CAAGd,QAAAA;AACzB,CAAA;AAEO,IAAMe,oBAAAA,mBAAuB,MAAA,CAAA,CAChCC,cAAAA,KAEArB,CAAA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C,2CAAAA,CAAAA,CAAAA;EACtCR,KAAAA,EAAO,8BAAA;EACPC,WAAAA,EAAa;AACjB,CAAA,CAAA,EAR0C,gCAAA;AAgBvC,IAAMS,qDAAqC,MAAA,CAAA,CAACnB,GAAAA,KAC7CA,IAA0BC,UAAAA,CAAW,SAAA,KAClCD,GAAAA,CAA0BE,KAAAA,CAAM,UAAUC,MAAM,CAAA,IACrDC,WAAW,CAAA,IAAA,EAAOC,IAAAA,CAAKC,UAAUN,GAAAA,CAAAA,6BAAiC,CAAA,EAHpB,oCAAA;AAS3C,IAAMoB,mCAAAA,GACT7C,EAAEwC,MAAAA;AA8CC,IAAMM,iCAAAA,2BACTC,QAAAA,KAEAC,MAAAA,CAAOC,QAAQF,QAAAA,CAAAA,CAAUG,OACrB,CAAC,GAAGhD,EAAAA,CAAAA,KAAQ,OAAOA,EAAAA,KAAO,QAAA,IAAYA,GAAGwB,UAAAA,CAAW,SAAA,CAAA,CAAA,EAJX,mCAAA;AAO1C,IAAMyB,6BAAAA,2BAAgEJ,QAAAA,KACzEC,MAAAA,CAAOC,QAAQF,QAAAA,CAAAA,CAAUG,OACrB,CAAC,GAAGhD,EAAAA,CAAAA,KAAQ,OAAOA,EAAAA,KAAO,QAAA,IAAYA,GAAGwB,UAAAA,CAAW,SAAA,CAAA,CAAA,EAFf,+BAAA;AAMtC,IAAM0B,4BAAAA,mBAA+B,MAAA,CAAA,CACxCL,QAAAA,KACCA,QAAAA,EAFuC,8BAAA","file":"IUFXXZ2R.js","sourcesContent":["import z from 'zod';\n\nimport { normalizedHexSchema, type NormalizedHexString } from '@layerzerolabs/common-chain-model';\nimport { throwError } from '@layerzerolabs/common-error-utils';\nimport { ChainName } from '@layerzerolabs/layerzero-definitions';\nimport type { IsAny } from '@layerzerolabs/typescript-utils';\n\nimport { upgradeableConfigSchema } from '../upgrade';\n\nexport const baseResourceSchema = z.object({\n id: z.string(), // account-unique ID for this resource\n name: z.string().optional(), // display name for this resource\n resourceBaseType: z.string() as z.ZodString | z.ZodLiteral,\n});\n\nexport const baseMeshResourceSchema = z.object({\n ...baseResourceSchema.shape,\n resourceBaseType: z.literal('MESH'),\n});\n\nexport const baseContractResourceSchema = z.object({\n ...baseResourceSchema.shape,\n resourceBaseType: z.literal('CONTRACT'),\n chainName: z.enum(ChainName),\n upgradeConfig: upgradeableConfigSchema.optional(),\n verifyContract: z.boolean().optional(),\n\n chainConfig: z.any().optional(),\n});\n\nexport const withIntrinsicAddress = <T extends typeof baseContractResourceSchema>(\n resourceSchema: T,\n) =>\n z.object({\n ...resourceSchema.shape,\n _INTRINSIC_normalizedAddress: normalizedHexSchema,\n }) as z.ZodObject<\n T['shape'] & { _INTRINSIC_normalizedAddress: typeof normalizedHexSchema },\n z.core.$strip\n >;\n\nexport type BaseResource = z.infer<typeof baseResourceSchema>;\nexport type BaseMeshResource = z.infer<typeof baseMeshResourceSchema>;\nexport type BaseContractResource = z.infer<typeof baseContractResourceSchema>;\nexport type BaseIntrinsicAddressContractResource = z.infer<ReturnType<typeof withIntrinsicAddress>>;\n\n// the actual expected runtime value for this type is #C_REF:${id}\nexport type ContractResourceReference<T extends BaseContractResource = BaseContractResource> = {\n /** WARNING: these fields are not present at runtime */\n __resourceReferenceType: T;\n ['__CONTRACT_RESOURCE_REFERENCE']: true;\n};\n\nexport const extractIdFromContractResourceReference = (ref: ContractResourceReference) =>\n ((ref as unknown as string).startsWith('#C_REF:') &&\n (ref as unknown as string).slice('#C_REF:'.length)) ||\n throwError(`Ref ${JSON.stringify(ref)} is not a contract resource ref`);\n\n// use z.ZodType<BaseContractResource> because want to allow unions\nexport type ContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> = z.ZodType<\n ContractResourceReference<z.infer<T>>\n>;\n\nexport const contractResourceReferenceSchema: ContractResourceReferenceSchema<\n z.ZodType<BaseContractResource>\n // at runtime, we expect a string\n> = z.string().meta({\n id: 'contract-resource-dependency',\n title: 'Contract dependency to any',\n description: 'A reference to another contract resource (any)',\n}) as unknown as z.ZodType<ContractResourceReference>;\n\nlet contractResourceDependencyForSchemaZodMetaIdIdx = 0;\nexport const contractResourceReferenceSchemaFor = <T extends z.ZodType<BaseContractResource>>(\n // FIXME use this to generate a real schema\n _resource: T,\n): ContractResourceReferenceSchema<T> =>\n z.string().meta({\n id: `contract-resource-dependency-for-${++contractResourceDependencyForSchemaZodMetaIdIdx}`,\n // we can't generate this properly yet because this function needs more information\n // will be fixed when we clean up the runtime of dependencies id\n title: 'Contract dependency to (unknown)',\n description: 'A reference to another contract resource (unknown)',\n }) as unknown as z.ZodType<ContractResourceReference<z.infer<T>>>;\n\nexport type ResolvedContractResourceReference<T extends BaseContractResource> = {\n id: string;\n resource: T;\n address: NormalizedHexString;\n};\n\nexport type ResolvedContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> =\n z.ZodType<ResolvedContractResourceReference<z.infer<T>>>;\n\nexport const resolvedContractResourceReferenceSchema: ResolvedContractResourceReferenceSchema<any> =\n // FIXME could be a real schema\n z.custom<ResolvedContractResourceReference<any>>();\n\n// the actual expected runtime value for this type is #M_REF:${id}\nexport type MeshResourceReference<T extends BaseMeshResource = BaseMeshResource> = {\n /** WARNING: these fields are not present at runtime */\n __resourceReferenceType: T;\n ['__MESH_RESOURCE_REFERENCE']: true;\n};\n\nexport type MeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> = z.ZodType<\n MeshResourceReference<z.infer<T>>\n>;\n\nexport const meshResourceReferenceSchema: MeshResourceReferenceSchema<\n typeof baseMeshResourceSchema\n> = z.string().meta({\n id: 'mesh-resource-dependency',\n title: 'Mesh dependency to any',\n description: 'A reference to another mesh resource (any)',\n}) as unknown as z.ZodType<MeshResourceReference>;\n\nlet meshResourceDependencyForSchemaZodMetaIdIdx = 0;\nexport const meshResourceReferenceSchemaFor = <T extends typeof baseMeshResourceSchema>(\n // FIXME use this to generate a real schema\n _resource: T,\n): MeshResourceReferenceSchema<T> =>\n z.string().meta({\n id: `mesh-resource-dependency-for-${++meshResourceDependencyForSchemaZodMetaIdIdx}`,\n title: 'Mesh dependency to (unknown)',\n description: 'A reference to another mesh resource (unknown)',\n }) as unknown as z.ZodType<MeshResourceReference<z.infer<T>>>;\n\nexport type ResolvedMeshResourceReference<T extends BaseMeshResource> = {\n id: string;\n resource: T;\n // TODO: is there any other resolved information we want to inject here?\n};\n\nexport const extractIdFromMeshResourceReference = (ref: MeshResourceReference) =>\n ((ref as unknown as string).startsWith('#M_REF:') &&\n (ref as unknown as string).slice('#M_REF:'.length)) ||\n throwError(`Ref ${JSON.stringify(ref)} is not a mesh resource ref`);\n\nexport type ResolvedMeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> =\n // FIXME could be a real schema\n z.ZodType<ResolvedMeshResourceReference<z.infer<T>>>;\n\nexport const resolvedMeshResourceReferenceSchema: ResolvedMeshResourceReferenceSchema<any> =\n z.custom<ResolvedMeshResourceReference<any>>();\n\nexport type ResolvedResourceSchema<Resource extends typeof baseResourceSchema> = z.ZodObject<\n {\n [K in Exclude<\n keyof Resource['shape'],\n '_INTRINSIC_normalizedAddress'\n >]: Resource['shape'][K] extends infer R extends z.ZodType\n ? R extends z.ZodAny\n ? R\n : R extends z.ZodOptional<z.ZodAny>\n ? R\n : R extends ContractResourceReferenceSchema<infer I>\n ? ResolvedContractResourceReferenceSchema<I>\n : R extends z.ZodOptional<ContractResourceReferenceSchema<infer I>>\n ? z.ZodOptional<ResolvedContractResourceReferenceSchema<I>>\n : R extends MeshResourceReferenceSchema<infer I>\n ? ResolvedMeshResourceReferenceSchema<I>\n : R extends z.ZodOptional<MeshResourceReferenceSchema<infer I>>\n ? z.ZodOptional<ResolvedMeshResourceReferenceSchema<I>>\n : R\n : never;\n },\n z.core.$strip\n>;\n\nexport type ResolvedResource<Resource extends BaseResource> = {\n [K in Exclude<keyof Resource, '_INTRINSIC_normalizedAddress'>]: Resource[K] extends infer R\n ? R extends undefined\n ? R\n : IsAny<R> extends true\n ? R\n : IsAny<Exclude<R, undefined>> extends true\n ? R\n : R extends ContractResourceReference<infer I>\n ? ResolvedContractResourceReference<I>\n : R extends ContractResourceReference<infer I> | undefined\n ? ResolvedContractResourceReference<I> | undefined\n : R extends MeshResourceReference<infer I>\n ? ResolvedMeshResourceReference<I>\n : R extends MeshResourceReference<infer I> | undefined\n ? ResolvedMeshResourceReference<I> | undefined\n : R\n : never;\n};\n\nexport const extractContractResourceReferences = <Resource extends BaseResource>(\n resource: Resource,\n) =>\n Object.entries(resource).filter(\n ([, id]) => typeof id === 'string' && id.startsWith('#C_REF:'),\n ) as unknown as [prop: string, id: ContractResourceReference][];\n\nexport const extractMeshResourceReferences = <Resource extends BaseResource>(resource: Resource) =>\n Object.entries(resource).filter(\n ([, id]) => typeof id === 'string' && id.startsWith('#M_REF:'),\n ) as unknown as [prop: string, id: MeshResourceReference][];\n\n// FIXME implement runtime\nexport const createResolvedResourceSchema = <Resource extends typeof baseResourceSchema>(\n resource: Resource,\n) => resource as ResolvedResourceSchema<Resource>;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deploy/resources.ts"],"names":["baseResourceSchema","z","object","id","string","name","optional","resourceBaseType","baseMeshResourceSchema","shape","literal","baseContractResourceSchema","chainName","enum","ChainName","upgradeConfig","upgradeableConfigSchema","verifyContract","boolean","chainConfig","any","withIntrinsicAddress","__name","resourceSchema","_INTRINSIC_normalizedAddress","normalizedHexSchema","extractIdFromContractResourceReference","ref","startsWith","slice","length","throwError","JSON","stringify","contractResourceReferenceSchema","meta","title","description","contractResourceDependencyForSchemaZodMetaIdIdx","contractResourceReferenceSchemaFor","_resource","resolvedContractResourceReferenceSchema","custom","meshResourceReferenceSchema","meshResourceDependencyForSchemaZodMetaIdIdx","meshResourceReferenceSchemaFor","extractIdFromMeshResourceReference","resolvedMeshResourceReferenceSchema","extractContractResourceReferences","resource","Object","entries","filter","extractMeshResourceReferences","createResolvedResourceSchema"],"mappings":";;;;;;;;;;;;;AASO,IAAMA,kBAAAA,GAAqBC,mBAAEC,MAAA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CAAAA,GACT9C,mBAAEyC,MAAAA;AA8CC,IAAMM,iCAAAA,wCACTC,QAAAA,KAEAC,MAAAA,CAAOC,QAAQF,QAAAA,CAAAA,CAAUG,OACrB,CAAC,GAAGjD,EAAAA,CAAAA,KAAQ,OAAOA,EAAAA,KAAO,QAAA,IAAYA,GAAGyB,UAAAA,CAAW,SAAA,CAAA,CAAA,EAJX,mCAAA;AAO1C,IAAMyB,6BAAAA,wCAAgEJ,QAAAA,KACzEC,MAAAA,CAAOC,QAAQF,QAAAA,CAAAA,CAAUG,OACrB,CAAC,GAAGjD,EAAAA,CAAAA,KAAQ,OAAOA,EAAAA,KAAO,QAAA,IAAYA,GAAGyB,UAAAA,CAAW,SAAA,CAAA,CAAA,EAFf,+BAAA;AAMtC,IAAM0B,4BAAAA,mBAA+BhC,mBAAA,CAAA,CACxC2B,QAAAA,KACCA,QAAAA,EAFuC,8BAAA","file":"PUY2AOFE.cjs","sourcesContent":["import z from 'zod';\n\nimport { normalizedHexSchema, type NormalizedHexString } from '@layerzerolabs/common-chain-model';\nimport { throwError } from '@layerzerolabs/common-error-utils';\nimport { ChainName } from '@layerzerolabs/layerzero-definitions';\nimport type { IsAny } from '@layerzerolabs/typescript-utils';\n\nimport { upgradeableConfigSchema } from '../upgrade';\n\nexport const baseResourceSchema = z.object({\n id: z.string(), // account-unique ID for this resource\n name: z.string().optional(), // display name for this resource\n resourceBaseType: z.string() as z.ZodString | z.ZodLiteral,\n});\n\nexport const baseMeshResourceSchema = z.object({\n ...baseResourceSchema.shape,\n resourceBaseType: z.literal('MESH'),\n});\n\nexport const baseContractResourceSchema = z.object({\n ...baseResourceSchema.shape,\n resourceBaseType: z.literal('CONTRACT'),\n chainName: z.enum(ChainName),\n upgradeConfig: upgradeableConfigSchema.optional(),\n verifyContract: z.boolean().optional(),\n\n chainConfig: z.any().optional(),\n});\n\nexport const withIntrinsicAddress = <T extends typeof baseContractResourceSchema>(\n resourceSchema: T,\n) =>\n z.object({\n ...resourceSchema.shape,\n _INTRINSIC_normalizedAddress: normalizedHexSchema,\n }) as z.ZodObject<\n T['shape'] & { _INTRINSIC_normalizedAddress: typeof normalizedHexSchema },\n z.core.$strip\n >;\n\nexport type BaseResource = z.infer<typeof baseResourceSchema>;\nexport type BaseMeshResource = z.infer<typeof baseMeshResourceSchema>;\nexport type BaseContractResource = z.infer<typeof baseContractResourceSchema>;\nexport type BaseIntrinsicAddressContractResource = z.infer<ReturnType<typeof withIntrinsicAddress>>;\n\n// the actual expected runtime value for this type is #C_REF:${id}\nexport type ContractResourceReference<T extends BaseContractResource = BaseContractResource> = {\n /** WARNING: these fields are not present at runtime */\n __resourceReferenceType: T;\n ['__CONTRACT_RESOURCE_REFERENCE']: true;\n};\n\nexport const extractIdFromContractResourceReference = (ref: ContractResourceReference) =>\n ((ref as unknown as string).startsWith('#C_REF:') &&\n (ref as unknown as string).slice('#C_REF:'.length)) ||\n throwError(`Ref ${JSON.stringify(ref)} is not a contract resource ref`);\n\n// use z.ZodType<BaseContractResource> because want to allow unions\nexport type ContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> = z.ZodType<\n ContractResourceReference<z.infer<T>>\n>;\n\nexport const contractResourceReferenceSchema: ContractResourceReferenceSchema<\n z.ZodType<BaseContractResource>\n // at runtime, we expect a string\n> = z.string().meta({\n id: 'contract-resource-dependency',\n title: 'Contract dependency to any',\n description: 'A reference to another contract resource (any)',\n}) as unknown as z.ZodType<ContractResourceReference>;\n\nlet contractResourceDependencyForSchemaZodMetaIdIdx = 0;\nexport const contractResourceReferenceSchemaFor = <T extends z.ZodType<BaseContractResource>>(\n // FIXME use this to generate a real schema\n _resource: T,\n): ContractResourceReferenceSchema<T> =>\n z.string().meta({\n id: `contract-resource-dependency-for-${++contractResourceDependencyForSchemaZodMetaIdIdx}`,\n // we can't generate this properly yet because this function needs more information\n // will be fixed when we clean up the runtime of dependencies id\n title: 'Contract dependency to (unknown)',\n description: 'A reference to another contract resource (unknown)',\n }) as unknown as z.ZodType<ContractResourceReference<z.infer<T>>>;\n\nexport type ResolvedContractResourceReference<T extends BaseContractResource> = {\n id: string;\n resource: T;\n address: NormalizedHexString;\n};\n\nexport type ResolvedContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> =\n z.ZodType<ResolvedContractResourceReference<z.infer<T>>>;\n\nexport const resolvedContractResourceReferenceSchema: ResolvedContractResourceReferenceSchema<any> =\n // FIXME could be a real schema\n z.custom<ResolvedContractResourceReference<any>>();\n\n// the actual expected runtime value for this type is #M_REF:${id}\nexport type MeshResourceReference<T extends BaseMeshResource = BaseMeshResource> = {\n /** WARNING: these fields are not present at runtime */\n __resourceReferenceType: T;\n ['__MESH_RESOURCE_REFERENCE']: true;\n};\n\nexport type MeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> = z.ZodType<\n MeshResourceReference<z.infer<T>>\n>;\n\nexport const meshResourceReferenceSchema: MeshResourceReferenceSchema<\n typeof baseMeshResourceSchema\n> = z.string().meta({\n id: 'mesh-resource-dependency',\n title: 'Mesh dependency to any',\n description: 'A reference to another mesh resource (any)',\n}) as unknown as z.ZodType<MeshResourceReference>;\n\nlet meshResourceDependencyForSchemaZodMetaIdIdx = 0;\nexport const meshResourceReferenceSchemaFor = <T extends typeof baseMeshResourceSchema>(\n // FIXME use this to generate a real schema\n _resource: T,\n): MeshResourceReferenceSchema<T> =>\n z.string().meta({\n id: `mesh-resource-dependency-for-${++meshResourceDependencyForSchemaZodMetaIdIdx}`,\n title: 'Mesh dependency to (unknown)',\n description: 'A reference to another mesh resource (unknown)',\n }) as unknown as z.ZodType<MeshResourceReference<z.infer<T>>>;\n\nexport type ResolvedMeshResourceReference<T extends BaseMeshResource> = {\n id: string;\n resource: T;\n // TODO: is there any other resolved information we want to inject here?\n};\n\nexport const extractIdFromMeshResourceReference = (ref: MeshResourceReference) =>\n ((ref as unknown as string).startsWith('#M_REF:') &&\n (ref as unknown as string).slice('#M_REF:'.length)) ||\n throwError(`Ref ${JSON.stringify(ref)} is not a mesh resource ref`);\n\nexport type ResolvedMeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> =\n // FIXME could be a real schema\n z.ZodType<ResolvedMeshResourceReference<z.infer<T>>>;\n\nexport const resolvedMeshResourceReferenceSchema: ResolvedMeshResourceReferenceSchema<any> =\n z.custom<ResolvedMeshResourceReference<any>>();\n\nexport type ResolvedResourceSchema<Resource extends typeof baseResourceSchema> = z.ZodObject<\n {\n [K in Exclude<\n keyof Resource['shape'],\n '_INTRINSIC_normalizedAddress'\n >]: Resource['shape'][K] extends infer R extends z.ZodType\n ? R extends z.ZodAny\n ? R\n : R extends z.ZodOptional<z.ZodAny>\n ? R\n : R extends ContractResourceReferenceSchema<infer I>\n ? ResolvedContractResourceReferenceSchema<I>\n : R extends z.ZodOptional<ContractResourceReferenceSchema<infer I>>\n ? z.ZodOptional<ResolvedContractResourceReferenceSchema<I>>\n : R extends MeshResourceReferenceSchema<infer I>\n ? ResolvedMeshResourceReferenceSchema<I>\n : R extends z.ZodOptional<MeshResourceReferenceSchema<infer I>>\n ? z.ZodOptional<ResolvedMeshResourceReferenceSchema<I>>\n : R\n : never;\n },\n z.core.$strip\n>;\n\nexport type ResolvedResource<Resource extends BaseResource> = {\n [K in Exclude<keyof Resource, '_INTRINSIC_normalizedAddress'>]: Resource[K] extends infer R\n ? R extends undefined\n ? R\n : IsAny<R> extends true\n ? R\n : IsAny<Exclude<R, undefined>> extends true\n ? R\n : R extends ContractResourceReference<infer I>\n ? ResolvedContractResourceReference<I>\n : R extends ContractResourceReference<infer I> | undefined\n ? ResolvedContractResourceReference<I> | undefined\n : R extends MeshResourceReference<infer I>\n ? ResolvedMeshResourceReference<I>\n : R extends MeshResourceReference<infer I> | undefined\n ? ResolvedMeshResourceReference<I> | undefined\n : R\n : never;\n};\n\nexport const extractContractResourceReferences = <Resource extends BaseResource>(\n resource: Resource,\n) =>\n Object.entries(resource).filter(\n ([, id]) => typeof id === 'string' && id.startsWith('#C_REF:'),\n ) as unknown as [prop: string, id: ContractResourceReference][];\n\nexport const extractMeshResourceReferences = <Resource extends BaseResource>(resource: Resource) =>\n Object.entries(resource).filter(\n ([, id]) => typeof id === 'string' && id.startsWith('#M_REF:'),\n ) as unknown as [prop: string, id: MeshResourceReference][];\n\n// FIXME implement runtime\nexport const createResolvedResourceSchema = <Resource extends typeof baseResourceSchema>(\n resource: Resource,\n) => resource as ResolvedResourceSchema<Resource>;\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"]}