@recoillink/deploy-sdk 0.0.0-stage → 11.0.1
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/LICENSE.md +193 -0
- package/dist/AltVMFileSubmitter.d.ts +12 -0
- package/dist/AltVMFileSubmitter.d.ts.map +1 -0
- package/dist/AltVMFileSubmitter.js +35 -0
- package/dist/AltVMFileSubmitter.js.map +1 -0
- package/dist/AltVMFileSubmitter.test.d.ts +2 -0
- package/dist/AltVMFileSubmitter.test.d.ts.map +1 -0
- package/dist/AltVMFileSubmitter.test.js +46 -0
- package/dist/AltVMFileSubmitter.test.js.map +1 -0
- package/dist/AltVMJsonRpcSubmitter.d.ts +2 -0
- package/dist/AltVMJsonRpcSubmitter.d.ts.map +1 -0
- package/dist/AltVMJsonRpcSubmitter.js +2 -0
- package/dist/AltVMJsonRpcSubmitter.js.map +1 -0
- package/dist/core/core-artifact-reader.d.ts +67 -0
- package/dist/core/core-artifact-reader.d.ts.map +1 -0
- package/dist/core/core-artifact-reader.js +118 -0
- package/dist/core/core-artifact-reader.js.map +1 -0
- package/dist/core/core-artifact-reader.test.d.ts +2 -0
- package/dist/core/core-artifact-reader.test.d.ts.map +1 -0
- package/dist/core/core-artifact-reader.test.js +310 -0
- package/dist/core/core-artifact-reader.test.js.map +1 -0
- package/dist/core/core-writer.d.ts +43 -0
- package/dist/core/core-writer.d.ts.map +1 -0
- package/dist/core/core-writer.js +238 -0
- package/dist/core/core-writer.js.map +1 -0
- package/dist/core/core-writer.test.d.ts +2 -0
- package/dist/core/core-writer.test.d.ts.map +1 -0
- package/dist/core/core-writer.test.js +1315 -0
- package/dist/core/core-writer.test.js.map +1 -0
- package/dist/fee/fee-reader.d.ts +25 -0
- package/dist/fee/fee-reader.d.ts.map +1 -0
- package/dist/fee/fee-reader.js +35 -0
- package/dist/fee/fee-reader.js.map +1 -0
- package/dist/fee/fee-writer.d.ts +31 -0
- package/dist/fee/fee-writer.d.ts.map +1 -0
- package/dist/fee/fee-writer.js +45 -0
- package/dist/fee/fee-writer.js.map +1 -0
- package/dist/hook/hook-reader.d.ts +41 -0
- package/dist/hook/hook-reader.d.ts.map +1 -0
- package/dist/hook/hook-reader.js +52 -0
- package/dist/hook/hook-reader.js.map +1 -0
- package/dist/hook/hook-writer.d.ts +101 -0
- package/dist/hook/hook-writer.d.ts.map +1 -0
- package/dist/hook/hook-writer.js +140 -0
- package/dist/hook/hook-writer.js.map +1 -0
- package/dist/hook/hook-writer.test.d.ts +2 -0
- package/dist/hook/hook-writer.test.d.ts.map +1 -0
- package/dist/hook/hook-writer.test.js +70 -0
- package/dist/hook/hook-writer.test.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/ism/generic-ism-context.test.d.ts +2 -0
- package/dist/ism/generic-ism-context.test.d.ts.map +1 -0
- package/dist/ism/generic-ism-context.test.js +112 -0
- package/dist/ism/generic-ism-context.test.js.map +1 -0
- package/dist/ism/generic-ism-writer.d.ts +62 -0
- package/dist/ism/generic-ism-writer.d.ts.map +1 -0
- package/dist/ism/generic-ism-writer.js +100 -0
- package/dist/ism/generic-ism-writer.js.map +1 -0
- package/dist/ism/generic-ism.d.ts +43 -0
- package/dist/ism/generic-ism.d.ts.map +1 -0
- package/dist/ism/generic-ism.js +105 -0
- package/dist/ism/generic-ism.js.map +1 -0
- package/dist/ism/generic-ism.test.d.ts +2 -0
- package/dist/ism/generic-ism.test.d.ts.map +1 -0
- package/dist/ism/generic-ism.test.js +145 -0
- package/dist/ism/generic-ism.test.js.map +1 -0
- package/dist/ism/routing-ism.d.ts +21 -0
- package/dist/ism/routing-ism.d.ts.map +1 -0
- package/dist/ism/routing-ism.js +149 -0
- package/dist/ism/routing-ism.js.map +1 -0
- package/dist/protocol.d.ts +3 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +38 -0
- package/dist/protocol.js.map +1 -0
- package/dist/protocol.test.d.ts +2 -0
- package/dist/protocol.test.d.ts.map +1 -0
- package/dist/protocol.test.js +14 -0
- package/dist/protocol.test.js.map +1 -0
- package/dist/utils/validation.d.ts +46 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +132 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/validation.test.d.ts +2 -0
- package/dist/utils/validation.test.d.ts.map +1 -0
- package/dist/utils/validation.test.js +160 -0
- package/dist/utils/validation.test.js.map +1 -0
- package/dist/warp/warp-reader.d.ts +57 -0
- package/dist/warp/warp-reader.d.ts.map +1 -0
- package/dist/warp/warp-reader.js +135 -0
- package/dist/warp/warp-reader.js.map +1 -0
- package/dist/warp/warp-writer.d.ts +67 -0
- package/dist/warp/warp-writer.d.ts.map +1 -0
- package/dist/warp/warp-writer.js +381 -0
- package/dist/warp/warp-writer.js.map +1 -0
- package/dist/warp/warp-writer.test.d.ts +2 -0
- package/dist/warp/warp-writer.test.d.ts.map +1 -0
- package/dist/warp/warp-writer.test.js +1855 -0
- package/dist/warp/warp-writer.test.js.map +1 -0
- package/package.json +54 -3
- package/README.md +0 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { ProtocolType } from '@recoillink/provider-sdk';
|
|
3
|
+
import { UnsupportedIsmTypeError, validateIsmConfig, validateIsmType, } from './validation.js';
|
|
4
|
+
describe('validateIsmType', () => {
|
|
5
|
+
it('accepts compositeIsm on Sealevel', () => {
|
|
6
|
+
expect(() => {
|
|
7
|
+
validateIsmType('compositeIsm', 'solanamainnet', 'configuration', ProtocolType.Sealevel);
|
|
8
|
+
}).to.not.throw();
|
|
9
|
+
});
|
|
10
|
+
for (const protocol of [
|
|
11
|
+
ProtocolType.Radix,
|
|
12
|
+
ProtocolType.Aleo,
|
|
13
|
+
ProtocolType.Cosmos,
|
|
14
|
+
ProtocolType.CosmosNative,
|
|
15
|
+
ProtocolType.Starknet,
|
|
16
|
+
]) {
|
|
17
|
+
it(`rejects compositeIsm on ${protocol}`, () => {
|
|
18
|
+
expect(() => {
|
|
19
|
+
validateIsmType('compositeIsm', 'somechain', 'configuration', protocol);
|
|
20
|
+
}).to.throw(UnsupportedIsmTypeError);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
it('accepts routingMessageIdMultisigIsm on Sealevel', () => {
|
|
24
|
+
expect(() => {
|
|
25
|
+
validateIsmType('routingMessageIdMultisigIsm', 'solanamainnet', 'configuration', ProtocolType.Sealevel);
|
|
26
|
+
}).to.not.throw();
|
|
27
|
+
});
|
|
28
|
+
for (const protocol of [
|
|
29
|
+
ProtocolType.Radix,
|
|
30
|
+
ProtocolType.Aleo,
|
|
31
|
+
ProtocolType.Cosmos,
|
|
32
|
+
ProtocolType.CosmosNative,
|
|
33
|
+
ProtocolType.Starknet,
|
|
34
|
+
]) {
|
|
35
|
+
it(`rejects routingMessageIdMultisigIsm on ${protocol}`, () => {
|
|
36
|
+
expect(() => {
|
|
37
|
+
validateIsmType('routingMessageIdMultisigIsm', 'somechain', 'configuration', protocol);
|
|
38
|
+
}).to.throw(UnsupportedIsmTypeError);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
it('rejects messageIdMultisigIsm on Sealevel with a pointer to routingMessageIdMultisigIsm', () => {
|
|
42
|
+
expect(() => {
|
|
43
|
+
validateIsmType('messageIdMultisigIsm', 'solanamainnet', 'configuration', ProtocolType.Sealevel);
|
|
44
|
+
}).to.throw(UnsupportedIsmTypeError, /messageIdMultisigIsm is unsupported on sealevel, use routingMessageIdMultisigIsm instead/);
|
|
45
|
+
});
|
|
46
|
+
it('does not list messageIdMultisigIsm as supported on Sealevel', () => {
|
|
47
|
+
expect(() => {
|
|
48
|
+
validateIsmType('notARealIsm', 'solanamainnet', 'configuration', ProtocolType.Sealevel);
|
|
49
|
+
}).to.throw(UnsupportedIsmTypeError, /Supported types: (?!.*\bmessageIdMultisigIsm\b)/);
|
|
50
|
+
});
|
|
51
|
+
for (const protocol of [
|
|
52
|
+
ProtocolType.Radix,
|
|
53
|
+
ProtocolType.Aleo,
|
|
54
|
+
ProtocolType.Cosmos,
|
|
55
|
+
ProtocolType.CosmosNative,
|
|
56
|
+
ProtocolType.Starknet,
|
|
57
|
+
]) {
|
|
58
|
+
it(`still accepts messageIdMultisigIsm on ${protocol}`, () => {
|
|
59
|
+
expect(() => {
|
|
60
|
+
validateIsmType('messageIdMultisigIsm', 'somechain', 'configuration', protocol);
|
|
61
|
+
}).to.not.throw();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
it('accepts messageIdMultisigIsm when no protocol is given', () => {
|
|
65
|
+
expect(() => {
|
|
66
|
+
validateIsmType('messageIdMultisigIsm', 'somechain');
|
|
67
|
+
}).to.not.throw();
|
|
68
|
+
});
|
|
69
|
+
it('accepts protocol-agnostic ISM types on any Alt-VM protocol', () => {
|
|
70
|
+
expect(() => {
|
|
71
|
+
validateIsmType('testIsm', 'somechain', 'configuration', ProtocolType.Radix);
|
|
72
|
+
}).to.not.throw();
|
|
73
|
+
});
|
|
74
|
+
it('rejects unknown ISM types', () => {
|
|
75
|
+
expect(() => {
|
|
76
|
+
validateIsmType('notARealIsm', 'somechain', 'configuration', ProtocolType.Sealevel);
|
|
77
|
+
}).to.throw(UnsupportedIsmTypeError);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('validateIsmType legacy calls (no protocol)', () => {
|
|
81
|
+
it('accepts a 2-arg call (chain only, default context)', () => {
|
|
82
|
+
expect(() => {
|
|
83
|
+
validateIsmType('testIsm', 'somechain');
|
|
84
|
+
}).to.not.throw();
|
|
85
|
+
});
|
|
86
|
+
it('accepts a 3-arg call with an explicit context string in the old position', () => {
|
|
87
|
+
expect(() => {
|
|
88
|
+
validateIsmType('testIsm', 'somechain', 'core config');
|
|
89
|
+
}).to.not.throw();
|
|
90
|
+
});
|
|
91
|
+
it('rejects compositeIsm with a clear "protocol required" error when protocol is omitted', () => {
|
|
92
|
+
// compositeIsm never existed as a supported type before protocol
|
|
93
|
+
// awareness was added — there's no legacy call shape to preserve
|
|
94
|
+
// permissiveness for. Omitting protocol must still reject it (just
|
|
95
|
+
// with a clearer reason), not silently accept it for every protocol.
|
|
96
|
+
expect(() => {
|
|
97
|
+
validateIsmType('compositeIsm', 'somechain', 'core config');
|
|
98
|
+
}).to.throw(UnsupportedIsmTypeError, /requires the chain's protocol/);
|
|
99
|
+
});
|
|
100
|
+
it('still rejects a genuinely unsupported type with no protocol given', () => {
|
|
101
|
+
expect(() => {
|
|
102
|
+
validateIsmType('notARealIsm', 'somechain', 'core config');
|
|
103
|
+
}).to.throw(UnsupportedIsmTypeError);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('validateIsmConfig', () => {
|
|
107
|
+
it('rejects compositeIsm nested in a domainRoutingIsm on a non-Sealevel chain', () => {
|
|
108
|
+
const config = {
|
|
109
|
+
type: 'domainRoutingIsm',
|
|
110
|
+
owner: '0x0',
|
|
111
|
+
domains: {
|
|
112
|
+
ethereum: {
|
|
113
|
+
type: 'compositeIsm',
|
|
114
|
+
owner: '0x0',
|
|
115
|
+
root: { type: 'test', accept: true },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
expect(() => {
|
|
120
|
+
validateIsmConfig(config, 'somechain', 'configuration', ProtocolType.Radix);
|
|
121
|
+
}).to.throw(UnsupportedIsmTypeError);
|
|
122
|
+
});
|
|
123
|
+
it('accepts a legacy 2-arg call with no context/protocol', () => {
|
|
124
|
+
expect(() => {
|
|
125
|
+
validateIsmConfig({ type: 'testIsm' }, 'somechain');
|
|
126
|
+
}).to.not.throw();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('validateIsmConfig routingMessageIdMultisigIsm', () => {
|
|
130
|
+
const V1 = '0x1111111111111111111111111111111111111111';
|
|
131
|
+
const V2 = '0x2222222222222222222222222222222222222222';
|
|
132
|
+
const cases = [
|
|
133
|
+
{
|
|
134
|
+
name: 'accepts a valid domain',
|
|
135
|
+
domains: { validators: [V1, V2], threshold: 2 },
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'rejects an invalid domain, labelled with domain, chain and context',
|
|
139
|
+
domains: { validators: [V1], threshold: 2 },
|
|
140
|
+
error: /^routingMessageIdMultisigIsm domain 'ethereum' on solanamainnet in configuration.*threshold 2/,
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
for (const c of cases) {
|
|
144
|
+
it(c.name, () => {
|
|
145
|
+
const config = {
|
|
146
|
+
type: 'routingMessageIdMultisigIsm',
|
|
147
|
+
owner: 'owner',
|
|
148
|
+
domains: { ethereum: c.domains },
|
|
149
|
+
};
|
|
150
|
+
const run = () => {
|
|
151
|
+
validateIsmConfig(config, 'solanamainnet', 'configuration', ProtocolType.Sealevel);
|
|
152
|
+
};
|
|
153
|
+
if (c.error)
|
|
154
|
+
expect(run).to.throw(c.error);
|
|
155
|
+
else
|
|
156
|
+
expect(run).to.not.throw();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
//# sourceMappingURL=validation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.test.js","sourceRoot":"","sources":["../../src/utils/validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,GAAG,EAAE;YACV,eAAe,CACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,CAAC,QAAQ,CACtB,CAAC;QACJ,CAAC,CAAC,CAAC,EAAE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AAC,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;SAChD;QACD;YACE,IAAI,EAAE,oEAAoE;YAC1E,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;YAC3C,KAAK,EACH,+FAA+F;SAClG;KACF,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE;YACd,MAAM,MAAM,GAAc;gBACxB,IAAI,EAAE,6BAA6B;gBACnC,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;aACjC,CAAC;YACF,MAAM,GAAG,GAAG,GAAG,EAAE;gBACf,iBAAiB,CACf,MAAM,EACN,eAAe,EACf,eAAe,EACf,YAAY,CAAC,QAAQ,CACtB,CAAC;YACJ,CAAC,CAAC;YACF,IAAI,CAAC,CAAC,KAAK;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;;gBACtC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ChainMetadataForAltVM } from '@recoillink/provider-sdk';
|
|
2
|
+
import { ArtifactReader } from '@recoillink/provider-sdk/artifact';
|
|
3
|
+
import { ChainLookup } from '@recoillink/provider-sdk/chain';
|
|
4
|
+
import { DeployedWarpAddress, DeployedWarpArtifact, DerivedWarpConfig, IRawWarpArtifactManager, WarpArtifactConfig } from '@recoillink/provider-sdk/warp';
|
|
5
|
+
import { IsmReader } from '../ism/generic-ism.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generic Warp Token Reader that can read any warp token type by detecting its type
|
|
8
|
+
* and expanding nested ISM artifacts if present.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WarpTokenReader implements ArtifactReader<WarpArtifactConfig, DeployedWarpAddress> {
|
|
11
|
+
protected readonly artifactManager: IRawWarpArtifactManager;
|
|
12
|
+
protected readonly chainMetadata: ChainMetadataForAltVM;
|
|
13
|
+
protected readonly chainLookup: ChainLookup;
|
|
14
|
+
protected readonly ismReader: IsmReader;
|
|
15
|
+
constructor(artifactManager: IRawWarpArtifactManager, chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup);
|
|
16
|
+
read(address: string): Promise<DeployedWarpArtifact>;
|
|
17
|
+
/**
|
|
18
|
+
* Expands an ISM artifact by recursively reading it if underived.
|
|
19
|
+
* Returns undefined if no ISM is configured.
|
|
20
|
+
*/
|
|
21
|
+
private expandIsmArtifact;
|
|
22
|
+
/**
|
|
23
|
+
* Expands a Hook artifact by recursively reading it if underived.
|
|
24
|
+
* Returns undefined if no Hook is configured.
|
|
25
|
+
*/
|
|
26
|
+
private expandHookArtifact;
|
|
27
|
+
/**
|
|
28
|
+
* Expands a Fee artifact by reading it if underived.
|
|
29
|
+
* Builds FeeReadContext from the warp config's remote routers and CC routers.
|
|
30
|
+
* Returns undefined only when no feeArtifact is provided. Deployed artifacts
|
|
31
|
+
* are returned as-is. Underived artifacts are read via the fee reader.
|
|
32
|
+
* Throws if a fee artifact exists but the protocol has no fee artifact manager.
|
|
33
|
+
*/
|
|
34
|
+
private expandFeeArtifact;
|
|
35
|
+
/**
|
|
36
|
+
* Backward compatibility method that converts DeployedWarpArtifact to DerivedWarpConfig.
|
|
37
|
+
* This allows WarpTokenReader to be used as a drop-in replacement for the old AltVMWarpRouteReader.
|
|
38
|
+
*/
|
|
39
|
+
deriveWarpConfig(address: string): Promise<DerivedWarpConfig>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Factory function to create a WarpTokenReader instance.
|
|
43
|
+
* This helper centralizes the creation of artifact managers and warp token readers,
|
|
44
|
+
* making it easier to instantiate readers across the codebase.
|
|
45
|
+
*
|
|
46
|
+
* @param chainMetadata Chain metadata for the target chain (protocol type is extracted from metadata.protocol)
|
|
47
|
+
* @param chainLookup Chain lookup interface for resolving chain names and domain IDs
|
|
48
|
+
* @returns A WarpTokenReader instance
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const reader = createWarpTokenReader(chainMetadata, chainLookup);
|
|
53
|
+
* const warpConfig = await reader.read(warpTokenAddress);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function createWarpTokenReader(chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup): WarpTokenReader;
|
|
57
|
+
//# sourceMappingURL=warp-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp-reader.d.ts","sourceRoot":"","sources":["../../src/warp/warp-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,cAAc,EAGf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAgB7D,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAGnB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAE,SAAS,EAAmB,MAAM,uBAAuB,CAAC;AAEnE;;;GAGG;AACH,qBAAa,eAAgB,YAAW,cAAc,CACpD,kBAAkB,EAClB,mBAAmB,CACpB;IAIG,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,uBAAuB;IAC3D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,qBAAqB;IACvD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW;IAL7C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAExC,YACqB,eAAe,EAAE,uBAAuB,EACxC,aAAa,EAAE,qBAAqB,EACpC,WAAW,EAAE,WAAW,EAG5C;IAEK,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmCzD;IAED;;;OAGG;YACW,iBAAiB;IAuB/B;;;OAGG;YACW,kBAAkB;IAwBhC;;;;;;OAMG;YACW,iBAAiB;IA2B/B;;;OAGG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAGlE;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EACpC,WAAW,EAAE,WAAW,GACvB,eAAe,CAMjB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { getProtocolProvider, } from '@recoillink/provider-sdk';
|
|
2
|
+
import { assert } from '@recoillink/utils';
|
|
3
|
+
import { isArtifactDeployed, isArtifactUnderived, } from '@recoillink/provider-sdk/artifact';
|
|
4
|
+
import { buildFeeReadContextFromWarpArtifactConfig, warpArtifactToDerivedConfig, } from '@recoillink/provider-sdk/warp';
|
|
5
|
+
import { createFeeReader } from '../fee/fee-reader.js';
|
|
6
|
+
import { createHookReader } from '../hook/hook-reader.js';
|
|
7
|
+
import { createIsmReader } from '../ism/generic-ism.js';
|
|
8
|
+
/**
|
|
9
|
+
* Generic Warp Token Reader that can read any warp token type by detecting its type
|
|
10
|
+
* and expanding nested ISM artifacts if present.
|
|
11
|
+
*/
|
|
12
|
+
export class WarpTokenReader {
|
|
13
|
+
artifactManager;
|
|
14
|
+
chainMetadata;
|
|
15
|
+
chainLookup;
|
|
16
|
+
ismReader;
|
|
17
|
+
constructor(artifactManager, chainMetadata, chainLookup) {
|
|
18
|
+
this.artifactManager = artifactManager;
|
|
19
|
+
this.chainMetadata = chainMetadata;
|
|
20
|
+
this.chainLookup = chainLookup;
|
|
21
|
+
this.ismReader = createIsmReader(chainMetadata, chainLookup);
|
|
22
|
+
}
|
|
23
|
+
async read(address) {
|
|
24
|
+
// Read warp token via artifactManager - detects type and returns raw config
|
|
25
|
+
const rawArtifact = await this.artifactManager.readWarpToken(address);
|
|
26
|
+
// Create hook reader with mailbox context from the warp config
|
|
27
|
+
const hookReader = createHookReader(this.chainMetadata, this.chainLookup, {
|
|
28
|
+
mailbox: rawArtifact.config.mailbox,
|
|
29
|
+
});
|
|
30
|
+
// Expand nested ISM artifact if present
|
|
31
|
+
const expandedIsmArtifact = await this.expandIsmArtifact(rawArtifact.config.interchainSecurityModule);
|
|
32
|
+
// Expand nested Hook artifact if present
|
|
33
|
+
const expandedHookArtifact = await this.expandHookArtifact(hookReader, rawArtifact.config.hook);
|
|
34
|
+
// Expand nested Fee artifact if present
|
|
35
|
+
const expandedFeeArtifact = await this.expandFeeArtifact(rawArtifact.config, rawArtifact.config.fee);
|
|
36
|
+
return {
|
|
37
|
+
...rawArtifact,
|
|
38
|
+
config: {
|
|
39
|
+
...rawArtifact.config,
|
|
40
|
+
interchainSecurityModule: expandedIsmArtifact,
|
|
41
|
+
hook: expandedHookArtifact,
|
|
42
|
+
fee: expandedFeeArtifact,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Expands an ISM artifact by recursively reading it if underived.
|
|
48
|
+
* Returns undefined if no ISM is configured.
|
|
49
|
+
*/
|
|
50
|
+
async expandIsmArtifact(ismArtifact) {
|
|
51
|
+
if (!ismArtifact) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
// If ISM is underived (just an address), read it recursively to get full config
|
|
55
|
+
if (isArtifactUnderived(ismArtifact)) {
|
|
56
|
+
return this.ismReader.read(ismArtifact.deployed.address);
|
|
57
|
+
}
|
|
58
|
+
// If already a full deployed artifact, use as-is
|
|
59
|
+
if (isArtifactDeployed(ismArtifact)) {
|
|
60
|
+
return ismArtifact;
|
|
61
|
+
}
|
|
62
|
+
// NEW state should not occur in read artifacts
|
|
63
|
+
throw new Error(`Unexpected ISM artifact state 'new' when reading warp token ISM configuration`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Expands a Hook artifact by recursively reading it if underived.
|
|
67
|
+
* Returns undefined if no Hook is configured.
|
|
68
|
+
*/
|
|
69
|
+
async expandHookArtifact(hookReader, hookArtifact) {
|
|
70
|
+
if (!hookArtifact) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
// If Hook is underived (just an address), read it recursively to get full config
|
|
74
|
+
if (isArtifactUnderived(hookArtifact)) {
|
|
75
|
+
return hookReader.read(hookArtifact.deployed.address);
|
|
76
|
+
}
|
|
77
|
+
// If already a full deployed artifact, use as-is
|
|
78
|
+
if (isArtifactDeployed(hookArtifact)) {
|
|
79
|
+
return hookArtifact;
|
|
80
|
+
}
|
|
81
|
+
// NEW state should not occur in read artifacts
|
|
82
|
+
throw new Error(`Unexpected Hook artifact state 'new' when reading warp token Hook configuration`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Expands a Fee artifact by reading it if underived.
|
|
86
|
+
* Builds FeeReadContext from the warp config's remote routers and CC routers.
|
|
87
|
+
* Returns undefined only when no feeArtifact is provided. Deployed artifacts
|
|
88
|
+
* are returned as-is. Underived artifacts are read via the fee reader.
|
|
89
|
+
* Throws if a fee artifact exists but the protocol has no fee artifact manager.
|
|
90
|
+
*/
|
|
91
|
+
async expandFeeArtifact(warpConfig, feeArtifact) {
|
|
92
|
+
if (!feeArtifact) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
if (isArtifactDeployed(feeArtifact)) {
|
|
96
|
+
return feeArtifact;
|
|
97
|
+
}
|
|
98
|
+
if (isArtifactUnderived(feeArtifact)) {
|
|
99
|
+
const context = buildFeeReadContextFromWarpArtifactConfig(warpConfig);
|
|
100
|
+
const feeReader = createFeeReader(this.chainMetadata, context);
|
|
101
|
+
assert(feeReader, `Fee artifact present on warp config but protocol ${this.chainMetadata.protocol} has no fee artifact manager`);
|
|
102
|
+
return feeReader.read(feeArtifact.deployed.address);
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Unexpected Fee artifact state 'new' when reading warp token Fee configuration`);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Backward compatibility method that converts DeployedWarpArtifact to DerivedWarpConfig.
|
|
108
|
+
* This allows WarpTokenReader to be used as a drop-in replacement for the old AltVMWarpRouteReader.
|
|
109
|
+
*/
|
|
110
|
+
async deriveWarpConfig(address) {
|
|
111
|
+
const artifact = await this.read(address);
|
|
112
|
+
return warpArtifactToDerivedConfig(artifact, this.chainLookup);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Factory function to create a WarpTokenReader instance.
|
|
117
|
+
* This helper centralizes the creation of artifact managers and warp token readers,
|
|
118
|
+
* making it easier to instantiate readers across the codebase.
|
|
119
|
+
*
|
|
120
|
+
* @param chainMetadata Chain metadata for the target chain (protocol type is extracted from metadata.protocol)
|
|
121
|
+
* @param chainLookup Chain lookup interface for resolving chain names and domain IDs
|
|
122
|
+
* @returns A WarpTokenReader instance
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const reader = createWarpTokenReader(chainMetadata, chainLookup);
|
|
127
|
+
* const warpConfig = await reader.read(warpTokenAddress);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export function createWarpTokenReader(chainMetadata, chainLookup) {
|
|
131
|
+
const protocolProvider = getProtocolProvider(chainMetadata.protocol);
|
|
132
|
+
const artifactManager = protocolProvider.createWarpArtifactManager(chainMetadata);
|
|
133
|
+
return new WarpTokenReader(artifactManager, chainMetadata, chainLookup);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=warp-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp-reader.js","sourceRoot":"","sources":["../../src/warp/warp-reader.ts"],"names":[],"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
|
+
import { ChainMetadataForAltVM } from '@recoillink/provider-sdk';
|
|
2
|
+
import { ISigner } from '@recoillink/provider-sdk/altvm';
|
|
3
|
+
import { ArtifactNew, ArtifactWriter } from '@recoillink/provider-sdk/artifact';
|
|
4
|
+
import { ChainLookup } from '@recoillink/provider-sdk/chain';
|
|
5
|
+
import { AnnotatedTx, TxReceipt } from '@recoillink/provider-sdk/module';
|
|
6
|
+
import { DeployedWarpAddress, DeployedWarpArtifact, IRawWarpArtifactManager, WarpArtifactConfig } from '@recoillink/provider-sdk/warp';
|
|
7
|
+
import { HookWriter } from '../hook/hook-writer.js';
|
|
8
|
+
import { IsmWriter } from '../ism/generic-ism-writer.js';
|
|
9
|
+
import { WarpTokenReader } from './warp-reader.js';
|
|
10
|
+
/**
|
|
11
|
+
* Factory function to create a WarpTokenWriter instance.
|
|
12
|
+
*
|
|
13
|
+
* @param chainMetadata Chain metadata for the target chain
|
|
14
|
+
* @param chainLookup Chain lookup interface for resolving chain names and domain IDs
|
|
15
|
+
* @param signer Signer interface for signing transactions
|
|
16
|
+
* @returns A WarpTokenWriter instance
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const writer = createWarpTokenWriter(chainMetadata, chainLookup, signer);
|
|
21
|
+
* const [deployed, receipts] = await writer.create(warpArtifact);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createWarpTokenWriter(chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup, signer: ISigner<AnnotatedTx, TxReceipt>): WarpTokenWriter;
|
|
25
|
+
/**
|
|
26
|
+
* WarpTokenWriter handles creation and updates of warp tokens using the Artifact API.
|
|
27
|
+
* It delegates to protocol-specific artifact writers for individual warp token types.
|
|
28
|
+
*
|
|
29
|
+
* Key features:
|
|
30
|
+
* - Extends WarpTokenReader to inherit read() functionality
|
|
31
|
+
* - Works with pure Artifact API (WarpArtifactConfig)
|
|
32
|
+
* - Handles nested ISM deployment after warp token deployment
|
|
33
|
+
* - Delegates to typed writers from artifact manager for specific warp token types
|
|
34
|
+
* - Protocol-agnostic through artifact manager abstraction
|
|
35
|
+
*/
|
|
36
|
+
export declare class WarpTokenWriter extends WarpTokenReader implements ArtifactWriter<WarpArtifactConfig, DeployedWarpAddress> {
|
|
37
|
+
protected readonly artifactManager: IRawWarpArtifactManager;
|
|
38
|
+
protected readonly chainMetadata: ChainMetadataForAltVM;
|
|
39
|
+
protected readonly chainLookup: ChainLookup;
|
|
40
|
+
protected readonly signer: ISigner<AnnotatedTx, TxReceipt>;
|
|
41
|
+
protected readonly ismWriter: IsmWriter;
|
|
42
|
+
protected readonly hookWriterFactory: (mailbox: string) => HookWriter;
|
|
43
|
+
constructor(artifactManager: IRawWarpArtifactManager, chainMetadata: ChainMetadataForAltVM, chainLookup: ChainLookup, signer: ISigner<AnnotatedTx, TxReceipt>);
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new warp token by deploying it on-chain.
|
|
46
|
+
* If the warp token has a new nested ISM artifact, deploys it after the
|
|
47
|
+
* router so its config can use the router address.
|
|
48
|
+
*
|
|
49
|
+
* @param artifact The warp token configuration to deploy
|
|
50
|
+
* @returns A tuple of [deployed artifact, transaction receipts]
|
|
51
|
+
*/
|
|
52
|
+
create(artifact: ArtifactNew<WarpArtifactConfig>): Promise<[DeployedWarpArtifact, TxReceipt[]]>;
|
|
53
|
+
/**
|
|
54
|
+
* Updates an existing warp token to match the desired configuration.
|
|
55
|
+
* Warp tokens are mutable - supports remote router enrollment/unenrollment,
|
|
56
|
+
* ISM updates, and owner changes.
|
|
57
|
+
*
|
|
58
|
+
* The protocol-specific writer will read the current on-chain state and compare
|
|
59
|
+
* with the expected config to generate the necessary update transactions.
|
|
60
|
+
*
|
|
61
|
+
* @param artifact The desired warp token state (must include deployed address)
|
|
62
|
+
* @returns Array of transactions needed to perform the update
|
|
63
|
+
* @throws Error if the token type cannot be changed (e.g., collateral -> synthetic)
|
|
64
|
+
*/
|
|
65
|
+
update(artifact: DeployedWarpArtifact): Promise<AnnotatedTx[]>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=warp-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp-writer.d.ts","sourceRoot":"","sources":["../../src/warp/warp-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EACL,WAAW,EAGX,cAAc,EAIf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAsB7D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EAEvB,kBAAkB,EAGnB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,EAAE,UAAU,EAAoB,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAmB,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EACpC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,GACtC,eAAe,CAWjB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eACX,SAAQ,eACR,YAAW,cAAc,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;uBAMpC,eAAe,EAAE,uBAAuB;uBACxC,aAAa,EAAE,qBAAqB;uBACpC,WAAW,EAAE,WAAW;IACpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;IAP5D,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;I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