@hyperlane-xyz/deploy-sdk 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/core/core-artifact-reader.d.ts +67 -0
  2. package/dist/core/core-artifact-reader.d.ts.map +1 -0
  3. package/dist/core/core-artifact-reader.js +117 -0
  4. package/dist/core/core-artifact-reader.js.map +1 -0
  5. package/dist/core/core-artifact-reader.test.d.ts +2 -0
  6. package/dist/core/core-artifact-reader.test.d.ts.map +1 -0
  7. package/dist/core/core-artifact-reader.test.js +300 -0
  8. package/dist/core/core-artifact-reader.test.js.map +1 -0
  9. package/dist/core/core-writer.d.ts +42 -0
  10. package/dist/core/core-writer.d.ts.map +1 -0
  11. package/dist/core/core-writer.js +230 -0
  12. package/dist/core/core-writer.js.map +1 -0
  13. package/dist/core/core-writer.test.d.ts +2 -0
  14. package/dist/core/core-writer.test.d.ts.map +1 -0
  15. package/dist/core/core-writer.test.js +980 -0
  16. package/dist/core/core-writer.test.js.map +1 -0
  17. package/dist/hook/hook-reader.d.ts +5 -2
  18. package/dist/hook/hook-reader.d.ts.map +1 -1
  19. package/dist/hook/hook-reader.js +4 -3
  20. package/dist/hook/hook-reader.js.map +1 -1
  21. package/dist/hook/hook-writer.d.ts.map +1 -1
  22. package/dist/hook/hook-writer.js +2 -1
  23. package/dist/hook/hook-writer.js.map +1 -1
  24. package/dist/index.d.ts +7 -8
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +7 -8
  27. package/dist/index.js.map +1 -1
  28. package/dist/ism/generic-ism.d.ts.map +1 -1
  29. package/dist/ism/generic-ism.js +3 -40
  30. package/dist/ism/generic-ism.js.map +1 -1
  31. package/dist/warp/warp-reader.d.ts +0 -2
  32. package/dist/warp/warp-reader.d.ts.map +1 -1
  33. package/dist/warp/warp-reader.js +7 -5
  34. package/dist/warp/warp-reader.js.map +1 -1
  35. package/package.json +10 -10
  36. package/dist/AltVMCoreModule.d.ts +0 -94
  37. package/dist/AltVMCoreModule.d.ts.map +0 -1
  38. package/dist/AltVMCoreModule.js +0 -368
  39. package/dist/AltVMCoreModule.js.map +0 -1
  40. package/dist/AltVMCoreReader.d.ts +0 -18
  41. package/dist/AltVMCoreReader.d.ts.map +0 -1
  42. package/dist/AltVMCoreReader.js +0 -35
  43. package/dist/AltVMCoreReader.js.map +0 -1
  44. package/dist/core-module.d.ts +0 -5
  45. package/dist/core-module.d.ts.map +0 -1
  46. package/dist/core-module.js +0 -28
  47. package/dist/core-module.js.map +0 -1
@@ -0,0 +1,67 @@
1
+ import { ChainMetadataForAltVM } from '@hyperlane-xyz/provider-sdk';
2
+ import { ArtifactReader } from '@hyperlane-xyz/provider-sdk/artifact';
3
+ import { ChainLookup } from '@hyperlane-xyz/provider-sdk/chain';
4
+ import { DerivedCoreConfig } from '@hyperlane-xyz/provider-sdk/core';
5
+ import { DeployedMailboxAddress, DeployedMailboxArtifact, IRawMailboxArtifactManager, MailboxOnChain } from '@hyperlane-xyz/provider-sdk/mailbox';
6
+ import { Logger } from '@hyperlane-xyz/utils';
7
+ import { HookReader } from '../hook/hook-reader.js';
8
+ import { IsmReader } from '../ism/generic-ism.js';
9
+ /**
10
+ * Factory function to create a CoreArtifactReader instance.
11
+ * Follows pattern of createHookReader() and createIsmReader().
12
+ *
13
+ * @param chainMetadata Chain metadata for target chain
14
+ * @param chainLookup Chain lookup for domain resolution
15
+ * @returns CoreArtifactReader instance
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const reader = createCoreReader(chainMetadata, chainLookup);
20
+ * const coreConfig = await reader.deriveCoreConfig(mailboxAddress);
21
+ * ```
22
+ */
23
+ export declare function createCoreReader(chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup): CoreArtifactReader;
24
+ /**
25
+ * Core Artifact Reader - composite artifact reader that orchestrates mailbox, ISM, and hook readers.
26
+ *
27
+ * This implements the artifact API pattern at the "composite" level in deploy-sdk.
28
+ * It takes a mailbox address and returns a fully expanded MailboxOnChain artifact with
29
+ * all nested ISM and hook configurations read from the chain.
30
+ *
31
+ * Architecture:
32
+ * - Raw level: IRawMailboxArtifactManager (protocol-specific, in radix-sdk, cosmos-sdk, etc.)
33
+ * - Composite level: CoreArtifactReader (this class, in deploy-sdk)
34
+ *
35
+ * The raw mailbox reader returns UNDERIVED ISM/hook references (just addresses).
36
+ * This composite reader expands them into full DEPLOYED artifacts with complete configs.
37
+ */
38
+ export declare class CoreArtifactReader implements ArtifactReader<MailboxOnChain, DeployedMailboxAddress> {
39
+ protected readonly mailboxArtifactManager: IRawMailboxArtifactManager;
40
+ protected readonly chainMetadata: ChainMetadataForAltVM;
41
+ protected readonly chainLookup: ChainLookup;
42
+ protected readonly logger: Logger;
43
+ protected readonly ismReader: IsmReader;
44
+ protected readonly hookReaderFactory: (mailbox: string) => HookReader;
45
+ constructor(mailboxArtifactManager: IRawMailboxArtifactManager, chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup);
46
+ /**
47
+ * Read mailbox configuration and expand all nested ISM/hook configs.
48
+ *
49
+ * Takes a mailbox address, reads the raw mailbox config (which has UNDERIVED ISM/hook references),
50
+ * then recursively reads and expands all nested ISM and hook artifacts.
51
+ *
52
+ * @param mailboxAddress The deployed mailbox address
53
+ * @returns Fully expanded mailbox artifact with all nested configs in DEPLOYED state
54
+ */
55
+ read(mailboxAddress: string): Promise<DeployedMailboxArtifact>;
56
+ /**
57
+ * Backward compatibility method: convert deployed mailbox artifact to DerivedCoreConfig.
58
+ *
59
+ * This allows CoreArtifactReader to be used as a drop-in replacement for AltVMCoreReader.
60
+ * Existing code expects the deriveCoreConfig() method returning DerivedCoreConfig format.
61
+ *
62
+ * @param mailboxAddress The deployed mailbox address
63
+ * @returns DerivedCoreConfig in the legacy format
64
+ */
65
+ deriveCoreConfig(mailboxAddress: string): Promise<DerivedCoreConfig>;
66
+ }
67
+ //# sourceMappingURL=core-artifact-reader.d.ts.map
@@ -0,0 +1 @@
1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Ac,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAwCpE;;;;;;;;OAQG;IACG,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAQ3E"}
@@ -0,0 +1,117 @@
1
+ import { getProtocolProvider, } from '@hyperlane-xyz/provider-sdk';
2
+ import { ArtifactState, } from '@hyperlane-xyz/provider-sdk/artifact';
3
+ import { hookArtifactToDerivedConfig } from '@hyperlane-xyz/provider-sdk/hook';
4
+ import { mailboxArtifactToDerivedCoreConfig, } from '@hyperlane-xyz/provider-sdk/mailbox';
5
+ import { isEmptyAddress, rootLogger } from '@hyperlane-xyz/utils';
6
+ import { createHookReader } from '../hook/hook-reader.js';
7
+ import { createIsmReader } from '../ism/generic-ism.js';
8
+ import { ismArtifactToDerivedConfig } from '@hyperlane-xyz/provider-sdk/ism';
9
+ /**
10
+ * Factory function to create a CoreArtifactReader instance.
11
+ * Follows pattern of createHookReader() and createIsmReader().
12
+ *
13
+ * @param chainMetadata Chain metadata for target chain
14
+ * @param chainLookup Chain lookup for domain resolution
15
+ * @returns CoreArtifactReader instance
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const reader = createCoreReader(chainMetadata, chainLookup);
20
+ * const coreConfig = await reader.deriveCoreConfig(mailboxAddress);
21
+ * ```
22
+ */
23
+ export function createCoreReader(chainMetadata, chainLookup) {
24
+ const protocolProvider = getProtocolProvider(chainMetadata.protocol);
25
+ const mailboxArtifactManager = protocolProvider.createMailboxArtifactManager(chainMetadata);
26
+ return new CoreArtifactReader(mailboxArtifactManager, chainMetadata, chainLookup);
27
+ }
28
+ /**
29
+ * Core Artifact Reader - composite artifact reader that orchestrates mailbox, ISM, and hook readers.
30
+ *
31
+ * This implements the artifact API pattern at the "composite" level in deploy-sdk.
32
+ * It takes a mailbox address and returns a fully expanded MailboxOnChain artifact with
33
+ * all nested ISM and hook configurations read from the chain.
34
+ *
35
+ * Architecture:
36
+ * - Raw level: IRawMailboxArtifactManager (protocol-specific, in radix-sdk, cosmos-sdk, etc.)
37
+ * - Composite level: CoreArtifactReader (this class, in deploy-sdk)
38
+ *
39
+ * The raw mailbox reader returns UNDERIVED ISM/hook references (just addresses).
40
+ * This composite reader expands them into full DEPLOYED artifacts with complete configs.
41
+ */
42
+ export class CoreArtifactReader {
43
+ mailboxArtifactManager;
44
+ chainMetadata;
45
+ chainLookup;
46
+ logger = rootLogger.child({
47
+ module: CoreArtifactReader.name,
48
+ });
49
+ ismReader;
50
+ hookReaderFactory;
51
+ constructor(mailboxArtifactManager, chainMetadata, chainLookup) {
52
+ this.mailboxArtifactManager = mailboxArtifactManager;
53
+ this.chainMetadata = chainMetadata;
54
+ this.chainLookup = chainLookup;
55
+ this.ismReader = createIsmReader(this.chainMetadata, this.chainLookup);
56
+ this.hookReaderFactory = (mailbox) => createHookReader(this.chainMetadata, this.chainLookup, { mailbox });
57
+ }
58
+ /**
59
+ * Read mailbox configuration and expand all nested ISM/hook configs.
60
+ *
61
+ * Takes a mailbox address, reads the raw mailbox config (which has UNDERIVED ISM/hook references),
62
+ * then recursively reads and expands all nested ISM and hook artifacts.
63
+ *
64
+ * @param mailboxAddress The deployed mailbox address
65
+ * @returns Fully expanded mailbox artifact with all nested configs in DEPLOYED state
66
+ */
67
+ async read(mailboxAddress) {
68
+ // 1. Read raw mailbox config - returns UNDERIVED ISM/hook references (just addresses)
69
+ const rawMailbox = await this.mailboxArtifactManager.readMailbox(mailboxAddress);
70
+ // 2. Expand nested ISM and hooks using specialized readers
71
+ // Hook reader is created per-read with mailbox context (needed for SVM hook detection)
72
+ // Skip reading when address is empty (undefined, null, empty string, or zeroish)
73
+ const hookReader = this.hookReaderFactory(mailboxAddress);
74
+ const defaultIsmAddr = rawMailbox.config.defaultIsm.deployed.address;
75
+ const defaultHookAddr = rawMailbox.config.defaultHook.deployed.address;
76
+ const requiredHookAddr = rawMailbox.config.requiredHook.deployed.address;
77
+ const [defaultIsmArtifact, defaultHookArtifact, requiredHookArtifact] = await Promise.all([
78
+ isEmptyAddress(defaultIsmAddr)
79
+ ? rawMailbox.config.defaultIsm
80
+ : this.ismReader.read(defaultIsmAddr),
81
+ isEmptyAddress(defaultHookAddr)
82
+ ? rawMailbox.config.defaultHook
83
+ : hookReader.read(defaultHookAddr),
84
+ isEmptyAddress(requiredHookAddr)
85
+ ? rawMailbox.config.requiredHook
86
+ : hookReader.read(requiredHookAddr),
87
+ ]);
88
+ // 3. Return fully expanded mailbox artifact
89
+ return {
90
+ artifactState: ArtifactState.DEPLOYED,
91
+ config: {
92
+ owner: rawMailbox.config.owner,
93
+ defaultIsm: defaultIsmArtifact,
94
+ defaultHook: defaultHookArtifact,
95
+ requiredHook: requiredHookArtifact,
96
+ },
97
+ deployed: rawMailbox.deployed,
98
+ };
99
+ }
100
+ /**
101
+ * Backward compatibility method: convert deployed mailbox artifact to DerivedCoreConfig.
102
+ *
103
+ * This allows CoreArtifactReader to be used as a drop-in replacement for AltVMCoreReader.
104
+ * Existing code expects the deriveCoreConfig() method returning DerivedCoreConfig format.
105
+ *
106
+ * @param mailboxAddress The deployed mailbox address
107
+ * @returns DerivedCoreConfig in the legacy format
108
+ */
109
+ async deriveCoreConfig(mailboxAddress) {
110
+ const artifact = await this.read(mailboxAddress);
111
+ return mailboxArtifactToDerivedCoreConfig(artifact, this.chainLookup, {
112
+ ismArtifactToDerivedConfig,
113
+ hookArtifactToDerivedConfig,
114
+ });
115
+ }
116
+ }
117
+ //# sourceMappingURL=core-artifact-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-artifact-reader.js","sourceRoot":"","sources":["../../src/core/core-artifact-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,aAAa,GACd,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAKL,kCAAkC,GACnC,MAAM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ACnC;YACD,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,gBAAgB,CAAC,cAAsB;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEjD,OAAO,kCAAkC,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE;YACpE,0BAA0B;YAC1B,2BAA2B;SAC5B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=core-artifact-reader.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-artifact-reader.test.d.ts","sourceRoot":"","sources":["../../src/core/core-artifact-reader.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,300 @@
1
+ import { expect } from 'chai';
2
+ import sinon from 'sinon';
3
+ import { hasProtocol, registerProtocol, } from '@hyperlane-xyz/provider-sdk';
4
+ import { ArtifactState } from '@hyperlane-xyz/provider-sdk/artifact';
5
+ import { ZERO_ADDRESS_HEX_32 } from '@hyperlane-xyz/utils';
6
+ import { CoreArtifactReader } from './core-artifact-reader.js';
7
+ // Test protocol
8
+ const TestProtocol = 'test-core-reader';
9
+ const mockProtocolProvider = {
10
+ createProvider: sinon.stub(),
11
+ createSigner: sinon.stub(),
12
+ createSubmitter: sinon.stub(),
13
+ createIsmArtifactManager: sinon.stub(),
14
+ createHookArtifactManager: sinon.stub(),
15
+ createMailboxArtifactManager: sinon.stub(),
16
+ createValidatorAnnounceArtifactManager: sinon.stub(),
17
+ getMinGas: sinon.stub(),
18
+ createWarpArtifactManager: sinon.stub(),
19
+ };
20
+ if (!hasProtocol(TestProtocol)) {
21
+ registerProtocol(TestProtocol, () => mockProtocolProvider);
22
+ }
23
+ describe('CoreArtifactReader', () => {
24
+ const mockMailboxAddress = '0xMAILBOX';
25
+ const mockIsmAddress = '0xISM';
26
+ const mockDefaultHookAddress = '0xDEFAULTHOOK';
27
+ const mockRequiredHookAddress = '0xREQUIREDHOOK';
28
+ const mockOwner = '0xOWNER';
29
+ const mockDomainId = 1;
30
+ const chainName = 'test-chain';
31
+ let readMailboxStub;
32
+ let mailboxArtifactManager;
33
+ let chainLookup;
34
+ let chainMetadata;
35
+ let coreReader;
36
+ const mockRawMailbox = {
37
+ artifactState: ArtifactState.DEPLOYED,
38
+ config: {
39
+ owner: mockOwner,
40
+ defaultIsm: {
41
+ artifactState: ArtifactState.UNDERIVED,
42
+ deployed: { address: mockIsmAddress },
43
+ },
44
+ defaultHook: {
45
+ artifactState: ArtifactState.UNDERIVED,
46
+ deployed: { address: mockDefaultHookAddress },
47
+ },
48
+ requiredHook: {
49
+ artifactState: ArtifactState.UNDERIVED,
50
+ deployed: { address: mockRequiredHookAddress },
51
+ },
52
+ },
53
+ deployed: { address: mockMailboxAddress, domainId: mockDomainId },
54
+ };
55
+ const mockExpandedIsm = {
56
+ artifactState: ArtifactState.DEPLOYED,
57
+ config: {
58
+ type: 'merkleRootMultisigIsm',
59
+ validators: ['0xVALIDATOR1'],
60
+ threshold: 1,
61
+ },
62
+ deployed: { address: mockIsmAddress },
63
+ };
64
+ const mockExpandedDefaultHook = {
65
+ artifactState: ArtifactState.DEPLOYED,
66
+ config: {
67
+ type: 'merkleTreeHook',
68
+ },
69
+ deployed: { address: mockDefaultHookAddress },
70
+ };
71
+ const mockExpandedRequiredHook = {
72
+ artifactState: ArtifactState.DEPLOYED,
73
+ config: {
74
+ type: 'interchainGasPaymaster',
75
+ owner: mockOwner,
76
+ beneficiary: '0xBENEFICIARY',
77
+ oracleKey: '0xORACLE',
78
+ overhead: {},
79
+ oracleConfig: {},
80
+ },
81
+ deployed: { address: mockRequiredHookAddress },
82
+ };
83
+ let mockIsmReader;
84
+ let mockHookReader;
85
+ beforeEach(() => {
86
+ readMailboxStub = sinon
87
+ .stub()
88
+ .resolves(mockRawMailbox);
89
+ mailboxArtifactManager = {
90
+ readMailbox: readMailboxStub,
91
+ createReader: sinon.stub(),
92
+ createWriter: sinon.stub(),
93
+ };
94
+ chainMetadata = {
95
+ name: chainName,
96
+ domainId: mockDomainId,
97
+ protocol: TestProtocol,
98
+ chainId: mockDomainId,
99
+ };
100
+ chainLookup = {
101
+ getChainMetadata: sinon
102
+ .stub()
103
+ .returns(chainMetadata),
104
+ getChainName: sinon.stub().returns(chainName),
105
+ getDomainId: sinon
106
+ .stub()
107
+ .returns(mockDomainId),
108
+ getKnownChainNames: sinon.stub().returns([chainName]),
109
+ };
110
+ mockIsmReader = {
111
+ read: sinon.stub(),
112
+ };
113
+ mockHookReader = {
114
+ read: sinon.stub(),
115
+ };
116
+ coreReader = Object.create(CoreArtifactReader.prototype);
117
+ Object.assign(coreReader, {
118
+ mailboxArtifactManager,
119
+ chainMetadata,
120
+ chainLookup,
121
+ ismReader: mockIsmReader,
122
+ hookReaderFactory: () => mockHookReader,
123
+ });
124
+ });
125
+ afterEach(() => {
126
+ sinon.restore();
127
+ });
128
+ describe('read', () => {
129
+ it('should read mailbox and expand nested ISM/hook artifacts', async () => {
130
+ // ARRANGE
131
+ mockIsmReader.read.resolves(mockExpandedIsm);
132
+ mockHookReader.read
133
+ .onFirstCall()
134
+ .resolves(mockExpandedDefaultHook)
135
+ .onSecondCall()
136
+ .resolves(mockExpandedRequiredHook);
137
+ // ACT
138
+ const result = await coreReader.read(mockMailboxAddress);
139
+ // ASSERT
140
+ expect(result.artifactState).to.equal(ArtifactState.DEPLOYED);
141
+ expect(result.config.owner).to.equal(mockOwner);
142
+ expect(result.deployed.address).to.equal(mockMailboxAddress);
143
+ expect(result.deployed.domainId).to.equal(mockDomainId);
144
+ expect(result.config.defaultIsm).to.deep.equal(mockExpandedIsm);
145
+ expect(result.config.defaultHook).to.deep.equal(mockExpandedDefaultHook);
146
+ expect(result.config.requiredHook).to.deep.equal(mockExpandedRequiredHook);
147
+ sinon.assert.calledOnceWithExactly(readMailboxStub, mockMailboxAddress);
148
+ sinon.assert.calledOnceWithExactly(mockIsmReader.read, mockIsmAddress);
149
+ sinon.assert.calledWith(mockHookReader.read.firstCall, mockDefaultHookAddress);
150
+ sinon.assert.calledWith(mockHookReader.read.secondCall, mockRequiredHookAddress);
151
+ });
152
+ it('should read ISM and hooks in parallel via Promise.all', async () => {
153
+ // ARRANGE
154
+ const callOrder = [];
155
+ mockIsmReader.read.callsFake(async () => {
156
+ callOrder.push('ism');
157
+ return mockExpandedIsm;
158
+ });
159
+ mockHookReader.read.callsFake(async (address) => {
160
+ if (address === mockDefaultHookAddress) {
161
+ callOrder.push('defaultHook');
162
+ return mockExpandedDefaultHook;
163
+ }
164
+ callOrder.push('requiredHook');
165
+ return mockExpandedRequiredHook;
166
+ });
167
+ // ACT
168
+ await coreReader.read(mockMailboxAddress);
169
+ // ASSERT
170
+ expect(callOrder).to.have.lengthOf(3);
171
+ expect(callOrder).to.include.members([
172
+ 'ism',
173
+ 'defaultHook',
174
+ 'requiredHook',
175
+ ]);
176
+ });
177
+ it('should propagate mailbox reading errors', async () => {
178
+ // ARRANGE
179
+ const error = new Error('Failed to read mailbox');
180
+ readMailboxStub.rejects(error);
181
+ // ACT & ASSERT
182
+ await expect(coreReader.read(mockMailboxAddress)).to.be.rejectedWith('Failed to read mailbox');
183
+ });
184
+ it('should skip ISM/hook reader expansion for zero-address artifacts', async () => {
185
+ // ARRANGE
186
+ const zeroAddressMailbox = {
187
+ artifactState: ArtifactState.DEPLOYED,
188
+ config: {
189
+ owner: mockOwner,
190
+ defaultIsm: {
191
+ artifactState: ArtifactState.UNDERIVED,
192
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
193
+ },
194
+ defaultHook: {
195
+ artifactState: ArtifactState.UNDERIVED,
196
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
197
+ },
198
+ requiredHook: {
199
+ artifactState: ArtifactState.UNDERIVED,
200
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
201
+ },
202
+ },
203
+ deployed: { address: mockMailboxAddress, domainId: mockDomainId },
204
+ };
205
+ readMailboxStub.resolves(zeroAddressMailbox);
206
+ mockIsmReader.read.resolves(mockExpandedIsm);
207
+ mockHookReader.read.resolves(mockExpandedDefaultHook);
208
+ // ACT
209
+ const result = await coreReader.read(mockMailboxAddress);
210
+ // ASSERT
211
+ expect(result.artifactState).to.equal(ArtifactState.DEPLOYED);
212
+ expect(result.config.owner).to.equal(mockOwner);
213
+ // Nested artifacts should remain UNDERIVED (not expanded)
214
+ expect(result.config.defaultIsm.artifactState).to.equal(ArtifactState.UNDERIVED);
215
+ expect(result.config.defaultHook.artifactState).to.equal(ArtifactState.UNDERIVED);
216
+ expect(result.config.requiredHook.artifactState).to.equal(ArtifactState.UNDERIVED);
217
+ // Readers should NOT have been called
218
+ sinon.assert.notCalled(mockIsmReader.read);
219
+ sinon.assert.notCalled(mockHookReader.read);
220
+ });
221
+ it('should propagate ISM reader errors', async () => {
222
+ // ARRANGE
223
+ const error = new Error('ISM read failed');
224
+ mockIsmReader.read.rejects(error);
225
+ mockHookReader.read.resolves(mockExpandedDefaultHook);
226
+ // ACT & ASSERT
227
+ await expect(coreReader.read(mockMailboxAddress)).to.be.rejectedWith('ISM read failed');
228
+ });
229
+ it('should propagate hook reader errors', async () => {
230
+ // ARRANGE
231
+ const error = new Error('Hook read failed');
232
+ mockIsmReader.read.resolves(mockExpandedIsm);
233
+ mockHookReader.read.rejects(error);
234
+ // ACT & ASSERT
235
+ await expect(coreReader.read(mockMailboxAddress)).to.be.rejectedWith('Hook read failed');
236
+ });
237
+ });
238
+ describe('deriveCoreConfig', () => {
239
+ it('should convert artifact to DerivedCoreConfig format', async () => {
240
+ // ARRANGE
241
+ mockIsmReader.read.resolves(mockExpandedIsm);
242
+ mockHookReader.read
243
+ .onFirstCall()
244
+ .resolves(mockExpandedDefaultHook)
245
+ .onSecondCall()
246
+ .resolves(mockExpandedRequiredHook);
247
+ // ACT
248
+ const result = await coreReader.deriveCoreConfig(mockMailboxAddress);
249
+ // ASSERT
250
+ expect(result.owner).to.equal(mockOwner);
251
+ expect(result.defaultIsm).to.be.an('object');
252
+ expect(result.defaultHook).to.be.an('object');
253
+ expect(result.requiredHook).to.be.an('object');
254
+ sinon.assert.calledOnce(readMailboxStub);
255
+ sinon.assert.calledOnce(mockIsmReader.read);
256
+ expect(mockHookReader.read.callCount).to.equal(2);
257
+ });
258
+ it('should propagate read errors', async () => {
259
+ // ARRANGE
260
+ const error = new Error('Mailbox read failed');
261
+ readMailboxStub.rejects(error);
262
+ // ACT & ASSERT
263
+ await expect(coreReader.deriveCoreConfig(mockMailboxAddress)).to.be.rejectedWith('Mailbox read failed');
264
+ });
265
+ it('should return ZERO_ADDRESS_HEX_32 for zero-address ISM/hooks', async () => {
266
+ // ARRANGE
267
+ const zeroAddressMailbox = {
268
+ artifactState: ArtifactState.DEPLOYED,
269
+ config: {
270
+ owner: mockOwner,
271
+ defaultIsm: {
272
+ artifactState: ArtifactState.UNDERIVED,
273
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
274
+ },
275
+ defaultHook: {
276
+ artifactState: ArtifactState.UNDERIVED,
277
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
278
+ },
279
+ requiredHook: {
280
+ artifactState: ArtifactState.UNDERIVED,
281
+ deployed: { address: ZERO_ADDRESS_HEX_32 },
282
+ },
283
+ },
284
+ deployed: { address: mockMailboxAddress, domainId: mockDomainId },
285
+ };
286
+ readMailboxStub.resolves(zeroAddressMailbox);
287
+ // ACT
288
+ const result = await coreReader.deriveCoreConfig(mockMailboxAddress);
289
+ // ASSERT
290
+ expect(result.owner).to.equal(mockOwner);
291
+ expect(result.defaultIsm).to.equal(ZERO_ADDRESS_HEX_32);
292
+ expect(result.defaultHook).to.equal(ZERO_ADDRESS_HEX_32);
293
+ expect(result.requiredHook).to.equal(ZERO_ADDRESS_HEX_32);
294
+ // Readers should NOT have been called
295
+ sinon.assert.notCalled(mockIsmReader.read);
296
+ sinon.assert.notCalled(mockHookReader.read);
297
+ });
298
+ });
299
+ });
300
+ //# sourceMappingURL=core-artifact-reader.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-artifact-reader.test.js","sourceRoot":"","sources":["../../src/core/core-artifact-reader.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAEL,WAAW,EACX,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAYrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,gBAAgB;AAChB,MAAM,YAAY,GAAG,kBAAkC,CAAC;AAExD,MAAM,oBAAoB,GAAqB;IAC7C,cAAc,EAAE,KAAK,CAAC,IAAI,EAAE;IAC5B,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE;IAC1B,eAAe,EAAE,KAAK,CAAC,IAAI,EAAE;IAC7B,wBAAwB,EAAE,KAAK,CAAC,IAAI,EAAE;IACtC,yBAAyB,EAAE,KAAK,CAAC,IAAI,EAAE;IACvC,4BAA4B,EAAE,KAAK,CAAC,IAAI,EAAE;IAC1C,sCAAsC,EAAE,KAAK,CAAC,IAAI,EAAE;IACpD,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE;IACvB,yBAAyB,EAAE,KAAK,CAAC,IAAI,EAAE;CACxC,CAAC;AAEF,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;IAC/B,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;AAC7D,CAAC;AAED,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,kBAAkB,GAAG,WAAW,CAAC;IACvC,MAAM,cAAc,GAAG,OAAO,CAAC;IAC/B,MAAM,sBAAsB,GAAG,eA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,aAAa,EAAE,aAAa,CAAC,SAAS;wBACtC,QAAQ,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;qBAC3C;oBACD,YAAY,EAAE;wBACZ,aAAa,EAAE,aAAa,CAAC,SAAS;wBACtC,QAAQ,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;qBAC3C;iBACF;gBACD,QAAQ,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,YAAY,EAAE;aAClE,CAAC;YAEF,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;YAE7C,MAAM;YACN,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;YAErE,SAAS;YACT,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACxD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACzD,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAE1D,sCAAsC;YACtC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC3C,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { ChainMetadataForAltVM } from '@hyperlane-xyz/provider-sdk';
2
+ import { ISigner } from '@hyperlane-xyz/provider-sdk/altvm';
3
+ import { ArtifactDeployed, ArtifactNew } from '@hyperlane-xyz/provider-sdk/artifact';
4
+ import { ChainLookup } from '@hyperlane-xyz/provider-sdk/chain';
5
+ import { DeployedMailboxAddress, DeployedMailboxArtifact, IRawMailboxArtifactManager, MailboxArtifactConfig } from '@hyperlane-xyz/provider-sdk/mailbox';
6
+ import { AnnotatedTx, TxReceipt } from '@hyperlane-xyz/provider-sdk/module';
7
+ import { DeployedValidatorAnnounceArtifact, IRawValidatorAnnounceArtifactManager } from '@hyperlane-xyz/provider-sdk/validator-announce';
8
+ import { Logger } from '@hyperlane-xyz/utils';
9
+ import { CoreArtifactReader } from './core-artifact-reader.js';
10
+ export declare function createCoreWriter(chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup, signer: ISigner<AnnotatedTx, TxReceipt>): CoreWriter;
11
+ /**
12
+ * Orchestrates core deployment (mailbox, ISM, hooks, validator announce)
13
+ * using the Artifact API. Extends CoreArtifactReader for read().
14
+ *
15
+ * Does not implement ArtifactWriter<MailboxArtifactConfig, DeployedMailboxAddress>
16
+ * because create() returns a composite result (mailbox + validator announce) rather
17
+ * than a single [ArtifactDeployed, TxReceipt[]] tuple. The update() signature does
18
+ * conform to the standard pattern.
19
+ */
20
+ export declare class CoreWriter extends CoreArtifactReader {
21
+ protected readonly validatorAnnounceArtifactManager: IRawValidatorAnnounceArtifactManager | null;
22
+ protected readonly signer: ISigner<AnnotatedTx, TxReceipt>;
23
+ protected readonly logger: Logger;
24
+ private readonly ismWriter;
25
+ constructor(mailboxArtifactManager: IRawMailboxArtifactManager, validatorAnnounceArtifactManager: IRawValidatorAnnounceArtifactManager | null, chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup, signer: ISigner<AnnotatedTx, TxReceipt>);
26
+ create(artifact: ArtifactNew<MailboxArtifactConfig>): Promise<[
27
+ {
28
+ mailbox: DeployedMailboxArtifact;
29
+ validatorAnnounce: DeployedValidatorAnnounceArtifact | null;
30
+ },
31
+ TxReceipt[]
32
+ ]>;
33
+ /**
34
+ * Returns mailbox update transactions for the caller to submit.
35
+ * Note: may perform on-chain writes as a side effect when sub-components
36
+ * (ISM, hooks) require fresh deployment via `create()`.
37
+ */
38
+ update(expectedArtifact: ArtifactDeployed<MailboxArtifactConfig, DeployedMailboxAddress>): Promise<AnnotatedTx[]>;
39
+ private deployOrUpdateIsm;
40
+ private deployOrUpdateHook;
41
+ }
42
+ //# sourceMappingURL=core-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-writer.d.ts","sourceRoot":"","sources":["../../src/core/core-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAEL,gBAAgB,EAChB,WAAW,EAMZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAahE,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EAEtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EACL,iCAAiC,EACjC,oCAAoC,EAErC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,MAAM,EAAmC,MAAM,sBAAsB,CAAC;AAK/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,qBAAqB,EACpC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,GACtC,UAAU,CAgBZ;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,kBAAkB;IAS9C,SAAS,CAAC,QAAQ,CAAC,gCAAgC,EAAE,oCAAoC,GAAG,IAAI;IAGhG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;IAX5D,SAAS,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