@layerzerolabs/dw-model 0.2.68 → 0.2.70
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/dist/372UIOTW.js +107 -0
- package/dist/372UIOTW.js.map +1 -0
- package/dist/{2XSWEWFA.cjs → FOB7D4D6.cjs} +15 -83
- package/dist/FOB7D4D6.cjs.map +1 -0
- package/dist/{MHBV7XHL.js → G43GXBX5.js} +2 -4
- package/dist/G43GXBX5.js.map +1 -0
- package/dist/GLPJHNSD.js +25 -0
- package/dist/GLPJHNSD.js.map +1 -0
- package/dist/{NJ2LWIGZ.cjs → HCK5GXNH.cjs} +2 -4
- package/dist/HCK5GXNH.cjs.map +1 -0
- package/dist/MR335VWI.cjs +29 -0
- package/dist/MR335VWI.cjs.map +1 -0
- package/dist/deploy/artifact.cjs +10 -10
- package/dist/deploy/artifact.d.ts +0 -6
- package/dist/deploy/artifact.d.ts.map +1 -1
- package/dist/deploy/artifact.js +1 -1
- package/dist/deploy/factoryInterfaces.cjs +8 -9
- package/dist/deploy/factoryInterfaces.d.ts +14 -168
- package/dist/deploy/factoryInterfaces.d.ts.map +1 -1
- package/dist/deploy/factoryInterfaces.js +2 -3
- package/dist/deploy/index.cjs +48 -80
- package/dist/deploy/index.js +3 -3
- package/dist/deploy/workflow.cjs +4 -37
- package/dist/deploy/workflow.d.ts +2 -283
- package/dist/deploy/workflow.d.ts.map +1 -1
- package/dist/deploy/workflow.js +1 -2
- package/dist/index.cjs +48 -80
- package/dist/index.js +3 -3
- package/dist/role-management/generator.d.ts +1 -1
- package/dist/role-management/schemata.d.ts +20 -20
- package/dist/role-management/schemata.d.ts.map +1 -1
- package/package.json +12 -9
- package/.turbo/turbo-build.log +0 -143
- package/.turbo/turbo-lint.log +0 -8
- package/.turbo/turbo-test.log +0 -16
- package/dist/2XSWEWFA.cjs.map +0 -1
- package/dist/DRX4MXDW.js +0 -87
- package/dist/DRX4MXDW.js.map +0 -1
- package/dist/FVBHJFVE.cjs +0 -99
- package/dist/FVBHJFVE.cjs.map +0 -1
- package/dist/KK5K3STO.js +0 -175
- package/dist/KK5K3STO.js.map +0 -1
- package/dist/MHBV7XHL.js.map +0 -1
- package/dist/NJ2LWIGZ.cjs.map +0 -1
- package/src/deploy/artifact.ts +0 -99
- package/src/deploy/factoryInterfaces.ts +0 -203
- package/src/deploy/index.ts +0 -5
- package/src/deploy/resourceBuilder.ts +0 -79
- package/src/deploy/resources.md +0 -84
- package/src/deploy/resources.ts +0 -205
- package/src/deploy/workflow.ts +0 -140
- package/src/index.ts +0 -4
- package/src/role-management/generator.ts +0 -17
- package/src/role-management/index.ts +0 -3
- package/src/role-management/schemata.ts +0 -180
- package/src/role-management/types.ts +0 -5
- package/src/upgrade/index.ts +0 -1
- package/src/upgrade/types.ts +0 -159
- package/src/wire/index.ts +0 -1
- package/src/wire/schemata.ts +0 -63
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -8
package/src/deploy/index.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { throwError } from '@layerzerolabs/common-error-utils';
|
|
4
|
-
import type { NormalizedHexString } from '@layerzerolabs/typescript-utils';
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
BaseContractResource,
|
|
8
|
-
BaseMeshResource,
|
|
9
|
-
baseResourceSchema,
|
|
10
|
-
ContractResourceReference,
|
|
11
|
-
MeshResourceReference,
|
|
12
|
-
withIntrinsicAddress,
|
|
13
|
-
} from './resources';
|
|
14
|
-
|
|
15
|
-
export type ContractResourceBuilderResult<Resource extends BaseContractResource> = {
|
|
16
|
-
ref: () => ContractResourceReference<Resource>;
|
|
17
|
-
build: () => Resource;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type MeshResourceBuilderResult<Resource extends BaseMeshResource> = {
|
|
21
|
-
ref: () => MeshResourceReference<Resource>;
|
|
22
|
-
build: () => Resource;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const createResourceBuilder =
|
|
26
|
-
<
|
|
27
|
-
T extends typeof baseResourceSchema,
|
|
28
|
-
U extends Omit<z.infer<T>, 'type' | 'resourceBaseType' | '_INTRINSIC_normalizedAddress'>,
|
|
29
|
-
>(
|
|
30
|
-
_resourceSchema: T,
|
|
31
|
-
{
|
|
32
|
-
resourceBaseType,
|
|
33
|
-
type,
|
|
34
|
-
}: {
|
|
35
|
-
resourceBaseType: 'CONTRACT' | 'MESH';
|
|
36
|
-
type: T['shape'] extends { type: z.ZodType<infer Type> } ? Type : undefined;
|
|
37
|
-
},
|
|
38
|
-
) =>
|
|
39
|
-
(
|
|
40
|
-
...args: T extends ReturnType<typeof withIntrinsicAddress>
|
|
41
|
-
? [
|
|
42
|
-
resource: U,
|
|
43
|
-
address: { nativeAddress: string } | { normalizedAddress: NormalizedHexString },
|
|
44
|
-
]
|
|
45
|
-
: [resource: U]
|
|
46
|
-
): z.infer<T> extends BaseContractResource
|
|
47
|
-
? ContractResourceBuilderResult<z.infer<T>>
|
|
48
|
-
: z.infer<T> extends BaseMeshResource
|
|
49
|
-
? MeshResourceBuilderResult<z.infer<T>>
|
|
50
|
-
: never => {
|
|
51
|
-
const resource = args[0];
|
|
52
|
-
if (resourceBaseType === 'CONTRACT') {
|
|
53
|
-
const _INTRINSIC_normalizedAddress: NormalizedHexString | undefined =
|
|
54
|
-
args[1] && 'nativeAddress' in args[1]
|
|
55
|
-
? throwError(
|
|
56
|
-
`Native address is currently not supported, use normalizedAddress instead`,
|
|
57
|
-
)
|
|
58
|
-
: args[1]?.normalizedAddress;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
ref: () => `#C_REF:${resource.id}` as any,
|
|
62
|
-
build: () => ({
|
|
63
|
-
...resource,
|
|
64
|
-
type,
|
|
65
|
-
resourceBaseType,
|
|
66
|
-
_INTRINSIC_normalizedAddress,
|
|
67
|
-
}),
|
|
68
|
-
} satisfies ContractResourceBuilderResult<any> as any;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (resourceBaseType === 'MESH') {
|
|
72
|
-
return {
|
|
73
|
-
ref: () => `#M_REF:${resource.id}` as any,
|
|
74
|
-
build: () => ({ ...resource, type, resourceBaseType }),
|
|
75
|
-
} satisfies MeshResourceBuilderResult<any> as any;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
throw new Error(`Can't handle resourceBaseType "${resourceBaseType}"`);
|
|
79
|
-
};
|
package/src/deploy/resources.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# On the resource model
|
|
2
|
-
|
|
3
|
-
## Background
|
|
4
|
-
|
|
5
|
-
We started with a schema defining the config and another schema defining the
|
|
6
|
-
interface of the activity factory that deploys contracts.
|
|
7
|
-
|
|
8
|
-
The first problem with this is the duplication. The second problem with this is that you necessarily require
|
|
9
|
-
the workflow to be able to transform between these two schemata. For example, if deploying an OFT LUA requires
|
|
10
|
-
that we know the token address, the workflow must now have bespoke handling to inject this parameter into the activity factory.
|
|
11
|
-
|
|
12
|
-
From here, you make the optimization of treating config as source of truth, and having activity factories receive the config,
|
|
13
|
-
and additional arguments that they require and that are only known at workflow time/don't need to be in the config.
|
|
14
|
-
|
|
15
|
-
This, still, requires custom workflow for any ordering of dependencies, injecting of addresses, and does not provide any way
|
|
16
|
-
to compose the deployment of multiple contracts.
|
|
17
|
-
|
|
18
|
-
## Resources
|
|
19
|
-
|
|
20
|
-
Resources, then, are a generalization of this idea. A resource, at its most basic, is a configuration of a contract,
|
|
21
|
-
which can be `resolve()`d and passed to an activity factory to deploy. The resolution step is completely generic,
|
|
22
|
-
simply injecting its references to other resources.
|
|
23
|
-
|
|
24
|
-
## Resource registry
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
resourceRegistry: (resourceId: string, resourceSubkey?: string) => RealID;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The resource registry is responsible for understanding the status of reification of your resources.
|
|
31
|
-
That is, the resource registry is the exclusive entity that holds the "address" of your "contracts".
|
|
32
|
-
|
|
33
|
-
"Address" here is not meant literally. Rather, it is a generalization, `RealID`. A RealID
|
|
34
|
-
is an identifier for a deployed resource. "Deployment" here is is not meant literally.
|
|
35
|
-
For example, pushing mesh resources to LZ metadata is a deployment. Deployment _is_, however,
|
|
36
|
-
whatever action creates the canonical identifier for the registry.
|
|
37
|
-
|
|
38
|
-
In summary,
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
config === resource
|
|
42
|
-
address === realID
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Resource subkeys are suffixes that identify optional additional RealIDs associated with the same resource.
|
|
46
|
-
For example, an OFT may have a proxy, an implementation, and a proxy admin. One of these is the canonical RealID.
|
|
47
|
-
The canonical RealID is whichever RealID identifies the semantic entity, in this case whichever contract can lzReceive,
|
|
48
|
-
in this case the proxy. Therefore, this resource has
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
<resourceId> -> <realId> (proxy contract)
|
|
52
|
-
<resourceId/impl> -> <realId> (implementation contract)
|
|
53
|
-
<resourceId/proxy-admin> -> <realId> (proxy admin contract)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
These additional realIds are _not_ identifiers for the resource, but are persisted for contexts in which they might be relevant.
|
|
57
|
-
For any consumer who is unaware of the context of proxies, they need only identify the resource by its ID to receive the "correct"
|
|
58
|
-
semantic RealID. Of course correct depends on the context, which is why this strategy should be used carefully.
|
|
59
|
-
|
|
60
|
-
## Artifact registry
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
artifactRegistry: (realId: string) => Artifact
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Artifacts are metadata associated with some realId.
|
|
67
|
-
For example,
|
|
68
|
-
|
|
69
|
-
- The time a contract was deployed
|
|
70
|
-
- The number of optimizers runs on that contract
|
|
71
|
-
- Whether a contract has been pushed to metadata
|
|
72
|
-
|
|
73
|
-
Each artifact is separate and identified by an `ArtifactType`.
|
|
74
|
-
|
|
75
|
-
## Deployment flow
|
|
76
|
-
|
|
77
|
-
Topologically sort all resources in consideration, then sequentially map resource type -> factory.
|
|
78
|
-
Collect deployment transactions per factory, save RealID and optionally artifacts.
|
|
79
|
-
|
|
80
|
-
## Wiring flow
|
|
81
|
-
|
|
82
|
-
For each resource in consideration, fetch its RealID, specialize the relevant factory and operate.
|
|
83
|
-
Generally this will not require any artifact, unless the factory in question needs to obtain an artifact for specific purposes.
|
|
84
|
-
If it does, this will happen via backchannel lookup and will be hidden from the workflow.
|
package/src/deploy/resources.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
import { normalizedHexSchema, type NormalizedHexString } from '@layerzerolabs/common-chain-model';
|
|
4
|
-
import { throwError } from '@layerzerolabs/common-error-utils';
|
|
5
|
-
import { chainNameSchema } from '@layerzerolabs/layerzero-definitions';
|
|
6
|
-
import type { IsAny } from '@layerzerolabs/typescript-utils';
|
|
7
|
-
|
|
8
|
-
import { upgradeableConfigSchema } from '../upgrade';
|
|
9
|
-
|
|
10
|
-
export const baseResourceSchema = z.object({
|
|
11
|
-
id: z.string(), // account-unique ID for this resource
|
|
12
|
-
resourceBaseType: z.string() as z.ZodString | z.ZodLiteral,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const baseMeshResourceSchema = z.object({
|
|
16
|
-
...baseResourceSchema.shape,
|
|
17
|
-
resourceBaseType: z.literal('MESH'),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const baseContractResourceSchema = z.object({
|
|
21
|
-
...baseResourceSchema.shape,
|
|
22
|
-
resourceBaseType: z.literal('CONTRACT'),
|
|
23
|
-
chainName: chainNameSchema,
|
|
24
|
-
upgradeConfig: upgradeableConfigSchema.optional(),
|
|
25
|
-
verifyContract: z.boolean().optional(),
|
|
26
|
-
|
|
27
|
-
chainConfig: z.any().optional(),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const withIntrinsicAddress = <T extends typeof baseContractResourceSchema>(
|
|
31
|
-
resourceSchema: T,
|
|
32
|
-
) =>
|
|
33
|
-
z.object({
|
|
34
|
-
...resourceSchema.shape,
|
|
35
|
-
_INTRINSIC_normalizedAddress: normalizedHexSchema,
|
|
36
|
-
}) as z.ZodObject<
|
|
37
|
-
T['shape'] & { _INTRINSIC_normalizedAddress: typeof normalizedHexSchema },
|
|
38
|
-
z.core.$strip
|
|
39
|
-
>;
|
|
40
|
-
|
|
41
|
-
export type BaseResource = z.infer<typeof baseResourceSchema>;
|
|
42
|
-
export type BaseMeshResource = z.infer<typeof baseMeshResourceSchema>;
|
|
43
|
-
export type BaseContractResource = z.infer<typeof baseContractResourceSchema>;
|
|
44
|
-
export type BaseIntrinsicAddressContractResource = z.infer<ReturnType<typeof withIntrinsicAddress>>;
|
|
45
|
-
|
|
46
|
-
// The actual expected runtime value for this type is #C_REF:${id}
|
|
47
|
-
export type ContractResourceReference<T extends BaseContractResource = BaseContractResource> = {
|
|
48
|
-
/** WARNING: these fields are not present at runtime */
|
|
49
|
-
__resourceReferenceType: T;
|
|
50
|
-
['__CONTRACT_RESOURCE_REFERENCE']: true;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const extractIdFromContractResourceReference = (ref: ContractResourceReference) =>
|
|
54
|
-
((ref as unknown as string).startsWith('#C_REF:') &&
|
|
55
|
-
(ref as unknown as string).slice('#C_REF:'.length)) ||
|
|
56
|
-
throwError(`Ref ${JSON.stringify(ref)} is not a contract resource ref`);
|
|
57
|
-
|
|
58
|
-
// Use z.ZodType<BaseContractResource> because we want to allow unions
|
|
59
|
-
export type ContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> = z.ZodType<
|
|
60
|
-
ContractResourceReference<z.infer<T>>
|
|
61
|
-
>;
|
|
62
|
-
|
|
63
|
-
export const contractResourceReferenceSchema: ContractResourceReferenceSchema<
|
|
64
|
-
z.ZodType<BaseContractResource>
|
|
65
|
-
// At runtime, we expect a string
|
|
66
|
-
> = z.string().meta({
|
|
67
|
-
id: 'contract-resource-dependency',
|
|
68
|
-
title: 'Contract dependency to any',
|
|
69
|
-
description: 'A reference to another contract resource (any)',
|
|
70
|
-
}) as unknown as z.ZodType<ContractResourceReference>;
|
|
71
|
-
|
|
72
|
-
let contractResourceDependencyForSchemaZodMetaIdIdx = 0;
|
|
73
|
-
export const contractResourceReferenceSchemaFor = <T extends z.ZodType<BaseContractResource>>(
|
|
74
|
-
// TODO: use resource parameter to generate a concrete schema
|
|
75
|
-
_resource: T,
|
|
76
|
-
): ContractResourceReferenceSchema<T> =>
|
|
77
|
-
z.string().meta({
|
|
78
|
-
id: `contract-resource-dependency-for-${++contractResourceDependencyForSchemaZodMetaIdIdx}`,
|
|
79
|
-
// We can't generate this properly yet because this function needs more information
|
|
80
|
-
// Will be fixed when we clean up the runtime dependency ID resolution
|
|
81
|
-
title: 'Contract dependency to (unknown)',
|
|
82
|
-
description: 'A reference to another contract resource (unknown)',
|
|
83
|
-
}) as unknown as z.ZodType<ContractResourceReference<z.infer<T>>>;
|
|
84
|
-
|
|
85
|
-
export type ResolvedContractResourceReference<T extends BaseContractResource> = {
|
|
86
|
-
id: string;
|
|
87
|
-
resource: T;
|
|
88
|
-
address: NormalizedHexString;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type ResolvedContractResourceReferenceSchema<T extends z.ZodType<BaseContractResource>> =
|
|
92
|
-
z.ZodType<ResolvedContractResourceReference<z.infer<T>>>;
|
|
93
|
-
|
|
94
|
-
export const resolvedContractResourceReferenceSchema: ResolvedContractResourceReferenceSchema<any> =
|
|
95
|
-
// TODO: replace with a concrete zod schema
|
|
96
|
-
z.custom<ResolvedContractResourceReference<any>>();
|
|
97
|
-
|
|
98
|
-
// The actual expected runtime value for this type is #M_REF:${id}
|
|
99
|
-
export type MeshResourceReference<T extends BaseMeshResource = BaseMeshResource> = {
|
|
100
|
-
/** WARNING: these fields are not present at runtime */
|
|
101
|
-
__resourceReferenceType: T;
|
|
102
|
-
['__MESH_RESOURCE_REFERENCE']: true;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export type MeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> = z.ZodType<
|
|
106
|
-
MeshResourceReference<z.infer<T>>
|
|
107
|
-
>;
|
|
108
|
-
|
|
109
|
-
export const meshResourceReferenceSchema: MeshResourceReferenceSchema<
|
|
110
|
-
typeof baseMeshResourceSchema
|
|
111
|
-
> = z.string().meta({
|
|
112
|
-
id: 'mesh-resource-dependency',
|
|
113
|
-
title: 'Mesh dependency to any',
|
|
114
|
-
description: 'A reference to another mesh resource (any)',
|
|
115
|
-
}) as unknown as z.ZodType<MeshResourceReference>;
|
|
116
|
-
|
|
117
|
-
let meshResourceDependencyForSchemaZodMetaIdIdx = 0;
|
|
118
|
-
export const meshResourceReferenceSchemaFor = <T extends typeof baseMeshResourceSchema>(
|
|
119
|
-
// TODO: use resource parameter to generate a concrete schema
|
|
120
|
-
_resource: T,
|
|
121
|
-
): MeshResourceReferenceSchema<T> =>
|
|
122
|
-
z.string().meta({
|
|
123
|
-
id: `mesh-resource-dependency-for-${++meshResourceDependencyForSchemaZodMetaIdIdx}`,
|
|
124
|
-
title: 'Mesh dependency to (unknown)',
|
|
125
|
-
description: 'A reference to another mesh resource (unknown)',
|
|
126
|
-
}) as unknown as z.ZodType<MeshResourceReference<z.infer<T>>>;
|
|
127
|
-
|
|
128
|
-
export type ResolvedMeshResourceReference<T extends BaseMeshResource> = {
|
|
129
|
-
id: string;
|
|
130
|
-
resource: T;
|
|
131
|
-
// TODO: is there any other resolved information we want to inject here?
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const extractIdFromMeshResourceReference = (ref: MeshResourceReference) =>
|
|
135
|
-
((ref as unknown as string).startsWith('#M_REF:') &&
|
|
136
|
-
(ref as unknown as string).slice('#M_REF:'.length)) ||
|
|
137
|
-
throwError(`Ref ${JSON.stringify(ref)} is not a mesh resource ref`);
|
|
138
|
-
|
|
139
|
-
export type ResolvedMeshResourceReferenceSchema<T extends typeof baseMeshResourceSchema> =
|
|
140
|
-
// TODO: replace with a concrete zod schema
|
|
141
|
-
z.ZodType<ResolvedMeshResourceReference<z.infer<T>>>;
|
|
142
|
-
|
|
143
|
-
export const resolvedMeshResourceReferenceSchema: ResolvedMeshResourceReferenceSchema<any> =
|
|
144
|
-
z.custom<ResolvedMeshResourceReference<any>>();
|
|
145
|
-
|
|
146
|
-
export type ResolvedResourceSchema<Resource extends typeof baseResourceSchema> = z.ZodObject<
|
|
147
|
-
{
|
|
148
|
-
[K in Exclude<
|
|
149
|
-
keyof Resource['shape'],
|
|
150
|
-
'_INTRINSIC_normalizedAddress'
|
|
151
|
-
>]: Resource['shape'][K] extends infer R extends z.ZodType
|
|
152
|
-
? R extends z.ZodAny
|
|
153
|
-
? R
|
|
154
|
-
: R extends z.ZodOptional<z.ZodAny>
|
|
155
|
-
? R
|
|
156
|
-
: R extends ContractResourceReferenceSchema<infer I>
|
|
157
|
-
? ResolvedContractResourceReferenceSchema<I>
|
|
158
|
-
: R extends z.ZodOptional<ContractResourceReferenceSchema<infer I>>
|
|
159
|
-
? z.ZodOptional<ResolvedContractResourceReferenceSchema<I>>
|
|
160
|
-
: R extends MeshResourceReferenceSchema<infer I>
|
|
161
|
-
? ResolvedMeshResourceReferenceSchema<I>
|
|
162
|
-
: R extends z.ZodOptional<MeshResourceReferenceSchema<infer I>>
|
|
163
|
-
? z.ZodOptional<ResolvedMeshResourceReferenceSchema<I>>
|
|
164
|
-
: R
|
|
165
|
-
: never;
|
|
166
|
-
},
|
|
167
|
-
z.core.$strip
|
|
168
|
-
>;
|
|
169
|
-
|
|
170
|
-
export type ResolvedResource<Resource extends BaseResource> = {
|
|
171
|
-
[K in Exclude<keyof Resource, '_INTRINSIC_normalizedAddress'>]: Resource[K] extends infer R
|
|
172
|
-
? R extends undefined
|
|
173
|
-
? R
|
|
174
|
-
: IsAny<R> extends true
|
|
175
|
-
? R
|
|
176
|
-
: IsAny<Exclude<R, undefined>> extends true
|
|
177
|
-
? R
|
|
178
|
-
: R extends ContractResourceReference<infer I>
|
|
179
|
-
? ResolvedContractResourceReference<I>
|
|
180
|
-
: R extends ContractResourceReference<infer I> | undefined
|
|
181
|
-
? ResolvedContractResourceReference<I> | undefined
|
|
182
|
-
: R extends MeshResourceReference<infer I>
|
|
183
|
-
? ResolvedMeshResourceReference<I>
|
|
184
|
-
: R extends MeshResourceReference<infer I> | undefined
|
|
185
|
-
? ResolvedMeshResourceReference<I> | undefined
|
|
186
|
-
: R
|
|
187
|
-
: never;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export const extractContractResourceReferences = <Resource extends BaseResource>(
|
|
191
|
-
resource: Resource,
|
|
192
|
-
) =>
|
|
193
|
-
Object.entries(resource).filter(
|
|
194
|
-
([, id]) => typeof id === 'string' && id.startsWith('#C_REF:'),
|
|
195
|
-
) as unknown as [prop: string, id: ContractResourceReference][];
|
|
196
|
-
|
|
197
|
-
export const extractMeshResourceReferences = <Resource extends BaseResource>(resource: Resource) =>
|
|
198
|
-
Object.entries(resource).filter(
|
|
199
|
-
([, id]) => typeof id === 'string' && id.startsWith('#M_REF:'),
|
|
200
|
-
) as unknown as [prop: string, id: MeshResourceReference][];
|
|
201
|
-
|
|
202
|
-
// TODO: implement runtime resolution — currently returns input schema as-is
|
|
203
|
-
export const createResolvedResourceSchema = <Resource extends typeof baseResourceSchema>(
|
|
204
|
-
resource: Resource,
|
|
205
|
-
) => resource as ResolvedResourceSchema<Resource>;
|
package/src/deploy/workflow.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { SuiObjectChange } from '@mysten/sui/client';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
import { successfulGatedTransactionSchema } from '@layerzerolabs/gated-transaction';
|
|
5
|
-
import { chainNameSchema } from '@layerzerolabs/layerzero-definitions';
|
|
6
|
-
import { functionSchema } from '@layerzerolabs/zod-utils';
|
|
7
|
-
|
|
8
|
-
import type { DeploymentArtifact, SolanaDeploymentArtifactExtraInfo } from './artifact';
|
|
9
|
-
import {
|
|
10
|
-
deploymentArtifactSchema,
|
|
11
|
-
fullDeploymentArtifactSchema,
|
|
12
|
-
identityOnlyDeploymentArtifactSchema,
|
|
13
|
-
verificationArtifactSchema,
|
|
14
|
-
} from './artifact';
|
|
15
|
-
|
|
16
|
-
// Re-export for transitive type dependencies
|
|
17
|
-
export type { SuiObjectChange };
|
|
18
|
-
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Deprecated types (to be removed)
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
|
|
23
|
-
/** @deprecated use SolanaDeploymentArtifact from this module or define inline */
|
|
24
|
-
export type SolanaDeploymentArtifact = Omit<DeploymentArtifact, 'extraDeploymentInfo'> & {
|
|
25
|
-
extraDeploymentInfo: SolanaDeploymentArtifactExtraInfo;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// Deployment activity base args schemas
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
export const getDeploymentBaseArgsSchema = z.object({ contractName: z.string() });
|
|
33
|
-
export type GetDeploymentBaseArgs = z.infer<typeof getDeploymentBaseArgsSchema>;
|
|
34
|
-
|
|
35
|
-
export const saveDeploymentBaseArgsSchema = z.object({
|
|
36
|
-
deploymentArtifact: identityOnlyDeploymentArtifactSchema,
|
|
37
|
-
});
|
|
38
|
-
export type SaveDeploymentBaseArgs = z.infer<typeof saveDeploymentBaseArgsSchema>;
|
|
39
|
-
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
// Verification activity base args schemas
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
export const getVerificationBaseArgsSchema = z.object({
|
|
45
|
-
contractName: z.string(),
|
|
46
|
-
});
|
|
47
|
-
export type GetVerificationBaseArgs = z.infer<typeof getVerificationBaseArgsSchema>;
|
|
48
|
-
|
|
49
|
-
export const extractVerificationArtifactBaseArgsSchema = z.object({
|
|
50
|
-
gtx: successfulGatedTransactionSchema(),
|
|
51
|
-
deploymentArtifact: fullDeploymentArtifactSchema,
|
|
52
|
-
nonVerifyable: z.boolean().optional(),
|
|
53
|
-
});
|
|
54
|
-
export type ExtractVerificationArtifactBaseArgs = z.infer<
|
|
55
|
-
typeof extractVerificationArtifactBaseArgsSchema
|
|
56
|
-
>;
|
|
57
|
-
|
|
58
|
-
export const saveVerificationBaseArgsSchema = z.object({
|
|
59
|
-
deploymentArtifact: fullDeploymentArtifactSchema,
|
|
60
|
-
verificationArtifact: verificationArtifactSchema,
|
|
61
|
-
});
|
|
62
|
-
export type SaveVerificationBaseArgs = z.infer<typeof saveVerificationBaseArgsSchema>;
|
|
63
|
-
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
// Combined deployment + verification activity schema
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
|
|
68
|
-
export const baseDeploymentSavingArtifactsSchema = z.object({
|
|
69
|
-
getDeployment: functionSchema({
|
|
70
|
-
input: z.tuple([getDeploymentBaseArgsSchema]),
|
|
71
|
-
output: z.promise(deploymentArtifactSchema.optional()),
|
|
72
|
-
}),
|
|
73
|
-
saveDeployment: functionSchema({
|
|
74
|
-
input: z.tuple([saveDeploymentBaseArgsSchema]),
|
|
75
|
-
output: z.promise(z.void()),
|
|
76
|
-
}),
|
|
77
|
-
getVerification: functionSchema({
|
|
78
|
-
input: z.tuple([getVerificationBaseArgsSchema]),
|
|
79
|
-
output: z.promise(z.any()),
|
|
80
|
-
}),
|
|
81
|
-
saveVerification: functionSchema({
|
|
82
|
-
input: z.tuple([saveVerificationBaseArgsSchema]),
|
|
83
|
-
output: z.promise(z.void()),
|
|
84
|
-
}),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
// Deploy workflow result schemas
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
|
-
|
|
91
|
-
const failedDeployment = z.object({
|
|
92
|
-
name: z.string(),
|
|
93
|
-
success: z.literal(false),
|
|
94
|
-
error: z.string(),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const successfulDeployment = z.object({
|
|
98
|
-
name: z.string(),
|
|
99
|
-
success: z.literal(true),
|
|
100
|
-
deploymentArtifact: deploymentArtifactSchema,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
export const deployWorkflowChainResultItemSchema = z.union([
|
|
104
|
-
failedDeployment,
|
|
105
|
-
successfulDeployment,
|
|
106
|
-
]);
|
|
107
|
-
|
|
108
|
-
export const deployWorkflowChainResultSchema = z.object({
|
|
109
|
-
results: z.array(deployWorkflowChainResultItemSchema).default([]),
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// ---------------------------------------------------------------------------
|
|
113
|
-
// Deploy workflow state schemas
|
|
114
|
-
// ---------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
export const deployWorkflowChainStateSchema = deployWorkflowChainResultSchema.extend({
|
|
117
|
-
srcChain: chainNameSchema.optional(),
|
|
118
|
-
status: z.union([z.literal('RUNNING'), z.literal('COMPLETE')]).default('RUNNING'),
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
export const deployWorkflowOrchestratorResultSchema = z.object({
|
|
122
|
-
stateByChain: z.partialRecord(chainNameSchema, deployWorkflowChainResultSchema).default({}),
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
export const deployWorkflowOrchestratorStateSchema = deployWorkflowOrchestratorResultSchema.extend({
|
|
126
|
-
status: z.union([z.literal('RUNNING'), z.literal('COMPLETE')]).default('RUNNING'),
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// ---------------------------------------------------------------------------
|
|
130
|
-
// Deploy workflow types
|
|
131
|
-
// ---------------------------------------------------------------------------
|
|
132
|
-
|
|
133
|
-
export type DeployWorkflowChainResultItem = z.infer<typeof deployWorkflowChainResultItemSchema>;
|
|
134
|
-
export type DeployWorkflowChainResult = z.infer<typeof deployWorkflowChainResultSchema>;
|
|
135
|
-
export type DeployWorkflowChainState = z.infer<typeof deployWorkflowChainStateSchema>;
|
|
136
|
-
export type DeployWorkflowOrchestratorResult = z.infer<
|
|
137
|
-
typeof deployWorkflowOrchestratorResultSchema
|
|
138
|
-
>;
|
|
139
|
-
|
|
140
|
-
export type DeployWorkflowOrchestratorState = z.infer<typeof deployWorkflowOrchestratorStateSchema>;
|
package/src/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CreateSetRoleTransactionsWithSpecializedInput, HasRoleWithSpecializedInput } from '.';
|
|
2
|
-
|
|
3
|
-
export const generateThrowCreateSetRoleTransactions =
|
|
4
|
-
(): CreateSetRoleTransactionsWithSpecializedInput => () => {
|
|
5
|
-
throw new Error('Not implemented');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const generateThrowHasRole = (): HasRoleWithSpecializedInput => () => {
|
|
9
|
-
throw new Error('Not implemented');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const generateThrowRoleManagement = () => {
|
|
13
|
-
return {
|
|
14
|
-
createSetRoleTransactions: generateThrowCreateSetRoleTransactions(),
|
|
15
|
-
hasRole: generateThrowHasRole(),
|
|
16
|
-
};
|
|
17
|
-
};
|