@galacticcouncil/xc-cfg 2.3.0-pr349-45f8efb → 2.3.0-pr349-73bbaa0

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 (32) hide show
  1. package/build/bridges/wormhole/index.d.ts +0 -1
  2. package/build/builders/ContractBuilder.d.ts +4 -18
  3. package/build/builders/ExtrinsicBuilder.d.ts +2 -10
  4. package/build/builders/extrinsics/evm.d.ts +4 -0
  5. package/build/builders/extrinsics/xcm/index.d.ts +0 -1
  6. package/build/builders/extrinsics/xcm/polkadotXcm.d.ts +0 -7
  7. package/build/builders/extrinsics/xcm/polkadotXcm.utils.d.ts +2 -145
  8. package/build/clients/index.d.ts +2 -1
  9. package/build/clients/ntt/NttEvmClient.d.ts +13 -0
  10. package/build/clients/ntt/NttSolanaClient.d.ts +22 -0
  11. package/build/clients/ntt/NttSuiClient.d.ts +13 -0
  12. package/build/clients/ntt/index.d.ts +18 -0
  13. package/build/clients/ntt/types.d.ts +45 -0
  14. package/build/clients/wormhole/ExecutorClient.d.ts +50 -0
  15. package/build/clients/wormhole/index.d.ts +1 -0
  16. package/build/configs/polkadot/hydration/templates.d.ts +10 -4
  17. package/build/index.cjs +1 -1
  18. package/build/index.mjs +1 -1
  19. package/build/validations/bridge/index.d.ts +1 -0
  20. package/build/validations/bridge/ntt.d.ts +5 -0
  21. package/build/validations/chain/hydration.d.ts +0 -4
  22. package/package.json +2 -2
  23. package/build/bridges/wormhole/executor/evm.d.ts +0 -3
  24. package/build/bridges/wormhole/executor/index.d.ts +0 -18
  25. package/build/bridges/wormhole/executor/solana.d.ts +0 -11
  26. package/build/bridges/wormhole/executor/sui.d.ts +0 -3
  27. package/build/bridges/wormhole/executor/types.d.ts +0 -22
  28. package/build/builders/extrinsics/xcm/ethereumXcm.d.ts +0 -4
  29. package/build/clients/executor.d.ts +0 -27
  30. /package/build/{bridges/wormhole/executor/index.spec.d.ts → builders/extrinsics/evm.spec.d.ts} +0 -0
  31. /package/build/{builders/ContractBuilder.spec.d.ts → clients/ntt/index.spec.d.ts} +0 -0
  32. /package/build/clients/{executor.spec.d.ts → wormhole/ExecutorClient.spec.d.ts} +0 -0
@@ -1,2 +1 @@
1
1
  export * from './constants';
2
- export * from './executor';
@@ -1,32 +1,18 @@
1
- import { ContractConfigBuilder, ContractConfigBuilderParams, ExtrinsicConfigBuilder } from '@galacticcouncil/xc-core';
2
1
  import { Erc20 } from './contracts/Erc20';
3
2
  import { PolkadotXcm } from './contracts/PolkadotXcm';
4
3
  import { Wormhole } from './contracts/Wormhole';
5
4
  export declare function ContractBuilder(): {
6
5
  Batch: () => {
7
- batchAll: (configs: ContractConfigBuilder[]) => ContractConfigBuilder;
6
+ batchAll: (configs: import("@galacticcouncil/xc-core").ContractConfigBuilder[]) => import("@galacticcouncil/xc-core").ContractConfigBuilder;
8
7
  };
9
8
  Erc20: typeof Erc20;
10
9
  Basejump: () => {
11
- bridgeViaWormhole: () => ContractConfigBuilder;
10
+ bridgeViaWormhole: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
12
11
  };
13
12
  PolkadotXcm: typeof PolkadotXcm;
14
13
  Snowbridge: () => {
15
- v2SendMessage: () => ContractConfigBuilder;
16
- sendToken: () => ContractConfigBuilder;
14
+ v2SendMessage: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
15
+ sendToken: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
17
16
  };
18
17
  Wormhole: typeof Wormhole;
19
18
  };
20
- /**
21
- * Contract counterpart of {@link ExtrinsicDecorator} - attaches an extrinsic
22
- * to run ahead of the call.
23
- *
24
- * Where the extrinsic decorator can wrap both sides in `Utility.batch_all`
25
- * itself, a contract call is not a substrate call: the batching happens later,
26
- * once the platform knows the origin is ss58 and has wrapped the call in
27
- * `EVM.call`. So this only carries the extrinsic on the config and leaves the
28
- * assembly to {@link SubstrateEvm}.
29
- */
30
- export declare function ContractDecorator(predicate: (params: ContractConfigBuilderParams) => boolean, extrinsic: ExtrinsicConfigBuilder): {
31
- prior: (config: ContractConfigBuilder) => ContractConfigBuilder;
32
- };
@@ -11,8 +11,8 @@ export declare function ExtrinsicBuilder(): {
11
11
  balances: () => {
12
12
  transferAll: (keepAlive?: boolean) => ExtrinsicConfigBuilder;
13
13
  };
14
- ethereumXcm: () => {
15
- transact: (config: import("@galacticcouncil/xc-core").ContractConfigBuilder) => ExtrinsicConfigBuilder;
14
+ evm: () => {
15
+ call: (contract: import("@galacticcouncil/xc-core").ContractConfigBuilder) => ExtrinsicConfigBuilder;
16
16
  };
17
17
  polkadotXcm: () => {
18
18
  limitedReserveTransferAssets: () => ExtrinsicConfigBuilder;
@@ -29,14 +29,6 @@ export declare function ExtrinsicBuilder(): {
29
29
  viaSnowbridge: () => ExtrinsicConfigBuilder;
30
30
  };
31
31
  };
32
- send: () => {
33
- transact: (opts: {
34
- fee: number;
35
- }) => ExtrinsicConfigBuilder;
36
- transferAsset: (opts: {
37
- fee: number;
38
- }) => ExtrinsicConfigBuilder;
39
- };
40
32
  };
41
33
  router: () => {
42
34
  buy: (opts: {
@@ -0,0 +1,4 @@
1
+ import { ContractConfigBuilder, ExtrinsicConfigBuilder } from '@galacticcouncil/xc-core';
2
+ export declare const evm: () => {
3
+ call: (contract: ContractConfigBuilder) => ExtrinsicConfigBuilder;
4
+ };
@@ -1,4 +1,3 @@
1
- export { ethereumXcm } from './ethereumXcm';
2
1
  export { polkadotXcm } from './polkadotXcm';
3
2
  export { xTokens } from './xTokens';
4
3
  export * from './builder';
@@ -5,9 +5,6 @@ type TransferOpts = {
5
5
  transferType: XcmTransferType;
6
6
  executionFee?: number;
7
7
  };
8
- type TransactOpts = {
9
- fee: number;
10
- };
11
8
  declare function execute(messageBuilder: XcmMessageBuilder): ExtrinsicConfigBuilder;
12
9
  declare function execute(): {
13
10
  viaSnowbridge: () => ExtrinsicConfigBuilder;
@@ -19,9 +16,5 @@ export declare const polkadotXcm: () => {
19
16
  transferAssets: () => ExtrinsicConfigBuilder;
20
17
  transferAssetsUsingTypeAndThen: (opts: TransferOpts) => ExtrinsicConfigBuilder;
21
18
  execute: typeof execute;
22
- send: () => {
23
- transact: (opts: TransactOpts) => ExtrinsicConfigBuilder;
24
- transferAsset: (opts: TransactOpts) => ExtrinsicConfigBuilder;
25
- };
26
19
  };
27
20
  export {};
@@ -1,6 +1,6 @@
1
- import { Asset, Parachain, TxWeight } from '@galacticcouncil/xc-core';
1
+ import { Asset, Parachain } from '@galacticcouncil/xc-core';
2
2
  import { SizedHex } from 'polkadot-api';
3
- import { XcmV3Junctions, XcmV3Junction, XcmV3MultiassetFungibility, XcmV4Instruction, XcmV4AssetAssetFilter, XcmV3WeightLimit, XcmV2OriginKind } from '@galacticcouncil/descriptors';
3
+ import { XcmV3Junctions, XcmV3Junction, XcmV4Instruction, XcmV4AssetAssetFilter } from '@galacticcouncil/descriptors';
4
4
  import { XcmTransferType, XcmVersion } from './types';
5
5
  export declare const isSnowbridgeTransfer: (assetLocation: any) => boolean;
6
6
  export declare const toDest: (version: XcmVersion, source: Parachain, destination: Parachain) => {
@@ -201,146 +201,3 @@ export declare const toReserveXcmOnDest: (version: XcmVersion, account: any, des
201
201
  type: "DepositReserveAsset";
202
202
  }))[];
203
203
  };
204
- /**
205
- * Instructions are executed in 3 steps:
206
- *
207
- * 1) WithdrawAsset - Withdraw fee asset from the target account
208
- * 2) BuyExecution - Buy execution with the fee asset
209
- * 3) Transact - Destination (Transact) chain call execution
210
- *
211
- * Note that DepositAsset using AllCounted and not All, since All
212
- * has too high of a gas requirement.
213
- *
214
- * @param version - XCM Version
215
- * @param account - destination account (receiver)
216
- * @param transactFeeLocation - transact fee xcm location
217
- * @param transactFeeAmount - transact fee amount
218
- * @param transactCall - transact calldata
219
- * @param transactWeight - transact weight
220
- * @returns xcm transact message instructions
221
- */
222
- export declare const toTransactMessage: (version: XcmVersion, account: any, transactFeeLocation: {
223
- parents: number;
224
- interior: XcmV3Junctions;
225
- }, transactFeeAmount: any, transactCall: Uint8Array, transactWeight: TxWeight) => {
226
- type: XcmVersion;
227
- value: (({
228
- type: "BuyExecution";
229
- value: {
230
- fees: {
231
- id: {
232
- parents: number;
233
- interior: XcmV3Junctions;
234
- };
235
- fun: XcmV3MultiassetFungibility;
236
- };
237
- weight_limit: XcmV3WeightLimit;
238
- };
239
- } & {
240
- type: "BuyExecution";
241
- }) | ({
242
- type: "DepositAsset";
243
- value: {
244
- assets: XcmV4AssetAssetFilter;
245
- beneficiary: {
246
- parents: number;
247
- interior: XcmV3Junctions;
248
- };
249
- };
250
- } & {
251
- type: "DepositAsset";
252
- }) | ({
253
- type: "WithdrawAsset";
254
- value: {
255
- id: {
256
- parents: number;
257
- interior: XcmV3Junctions;
258
- };
259
- fun: XcmV3MultiassetFungibility;
260
- }[];
261
- } & {
262
- type: "WithdrawAsset";
263
- }) | ({
264
- type: "Transact";
265
- value: {
266
- call: Uint8Array<ArrayBufferLike>;
267
- origin_kind: XcmV2OriginKind;
268
- require_weight_at_most: {
269
- ref_time: bigint;
270
- proof_size: bigint;
271
- };
272
- };
273
- } & {
274
- type: "Transact";
275
- }) | ({
276
- type: "RefundSurplus";
277
- value: undefined;
278
- } & {
279
- type: "RefundSurplus";
280
- }))[];
281
- };
282
- export declare const toTransferMessage: (version: XcmVersion, account: any, transferAssetLocation: {
283
- parents: number;
284
- interior: XcmV3Junctions;
285
- }, transferAssetAmount: any, transferFeeAmount: any, receiver: any) => {
286
- type: XcmVersion;
287
- value: (({
288
- type: "BuyExecution";
289
- value: {
290
- fees: {
291
- id: {
292
- parents: number;
293
- interior: XcmV3Junctions;
294
- };
295
- fun: XcmV3MultiassetFungibility;
296
- };
297
- weight_limit: XcmV3WeightLimit;
298
- };
299
- } & {
300
- type: "BuyExecution";
301
- }) | ({
302
- type: "DepositAsset";
303
- value: {
304
- assets: XcmV4AssetAssetFilter;
305
- beneficiary: {
306
- parents: number;
307
- interior: XcmV3Junctions;
308
- };
309
- };
310
- } & {
311
- type: "DepositAsset";
312
- }) | ({
313
- type: "WithdrawAsset";
314
- value: {
315
- id: {
316
- parents: number;
317
- interior: XcmV3Junctions;
318
- };
319
- fun: XcmV3MultiassetFungibility;
320
- }[];
321
- } & {
322
- type: "WithdrawAsset";
323
- }) | ({
324
- type: "RefundSurplus";
325
- value: undefined;
326
- } & {
327
- type: "RefundSurplus";
328
- }) | ({
329
- type: "TransferAsset";
330
- value: {
331
- assets: {
332
- id: {
333
- parents: number;
334
- interior: XcmV3Junctions;
335
- };
336
- fun: XcmV3MultiassetFungibility;
337
- }[];
338
- beneficiary: {
339
- parents: number;
340
- interior: XcmV3Junctions;
341
- };
342
- };
343
- } & {
344
- type: "TransferAsset";
345
- }))[];
346
- };
@@ -1,3 +1,4 @@
1
1
  export * from './base';
2
2
  export * from './chain';
3
- export * from './executor';
3
+ export * from './ntt';
4
+ export * from './wormhole';
@@ -0,0 +1,13 @@
1
+ import { AnyChain, AnyEvmChain, Asset } from '@galacticcouncil/xc-core';
2
+ import { ExecutorBudget } from '../wormhole';
3
+ import { NttClient, NttRateLimit } from './types';
4
+ export declare class NttEvmClient implements NttClient {
5
+ private readonly chain;
6
+ private readonly asset?;
7
+ constructor(chain: AnyEvmChain, asset?: Asset | undefined);
8
+ getOutboundLimit(): Promise<NttRateLimit>;
9
+ getInboundLimit(from: AnyChain): Promise<NttRateLimit>;
10
+ /** An evm redeem holds nothing - receiveMessage moves no value. */
11
+ getRedeemBudget(): Promise<ExecutorBudget>;
12
+ private getLimit;
13
+ }
@@ -0,0 +1,22 @@
1
+ import { AnyChain, Asset, SolanaChain } from '@galacticcouncil/xc-core';
2
+ import { ExecutorBudget } from '../wormhole';
3
+ import { NttClient, NttRateLimit } from './types';
4
+ export declare class NttSolanaClient implements NttClient {
5
+ private readonly chain;
6
+ private readonly asset?;
7
+ constructor(chain: SolanaChain, asset?: Asset | undefined);
8
+ getOutboundLimit(): Promise<NttRateLimit>;
9
+ getInboundLimit(from: AnyChain): Promise<NttRateLimit>;
10
+ /**
11
+ * An svm redeem mints into the recipient's associated token account and the
12
+ * relayer opens it when missing, so its rent is charged only then -
13
+ * mirroring upstream, which adds it on `getAccountInfo(ata) === null`.
14
+ *
15
+ * Budgeting it unconditionally would be simpler, but the executor charges
16
+ * source native for lamports it fronts, so every transfer to an existing
17
+ * account would pay for rent nobody spends.
18
+ */
19
+ getRedeemBudget(recipient?: string): Promise<ExecutorBudget>;
20
+ private getLimit;
21
+ private rateLimitPda;
22
+ }
@@ -0,0 +1,13 @@
1
+ import { AnyChain, Asset, SuiChain } from '@galacticcouncil/xc-core';
2
+ import { ExecutorBudget } from '../wormhole';
3
+ import { NttClient, NttRateLimit } from './types';
4
+ export declare class NttSuiClient implements NttClient {
5
+ private readonly chain;
6
+ private readonly asset?;
7
+ constructor(chain: SuiChain, asset?: Asset | undefined);
8
+ getOutboundLimit(): Promise<NttRateLimit>;
9
+ getInboundLimit(from: AnyChain): Promise<NttRateLimit>;
10
+ /** A sui redeem holds nothing - the coin is minted to the recipient. */
11
+ getRedeemBudget(): Promise<ExecutorBudget>;
12
+ private getLimit;
13
+ }
@@ -0,0 +1,18 @@
1
+ import { AnyChain, Asset } from '@galacticcouncil/xc-core';
2
+ import { NttEvmClient } from './NttEvmClient';
3
+ import { NttSolanaClient } from './NttSolanaClient';
4
+ import { NttSuiClient } from './NttSuiClient';
5
+ import { NttClient } from './types';
6
+ export * from './types';
7
+ export { NttEvmClient, NttSolanaClient, NttSuiClient };
8
+ /**
9
+ * Ntt deployment on a chain, for an asset.
10
+ *
11
+ * Keyed on the chain the question is about, not the direction of travel:
12
+ * hydration -> sui asks sui for both the inbound limit and the redeem budget,
13
+ * and it is sui's answer that binds.
14
+ *
15
+ * @param asset - omit only when the budget is wanted and the destination asset
16
+ * is not resolved yet; the rate limits need it.
17
+ */
18
+ export declare function nttClient(chain: AnyChain, asset?: Asset): NttClient;
@@ -0,0 +1,45 @@
1
+ import { AnyChain, Asset, NttTokenDef } from '@galacticcouncil/xc-core';
2
+ import { ExecutorBudget } from '../wormhole';
3
+ /**
4
+ * Rate limit of one direction of an ntt manager.
5
+ *
6
+ * `capacity` is the headroom right now - the manager refills it linearly over
7
+ * `windowMs`. A `windowMs` of 0 means the direction is not metered at all.
8
+ */
9
+ export interface NttRateLimit {
10
+ capacity: bigint;
11
+ limit: bigint;
12
+ windowMs: number;
13
+ capacityAtLastTx: bigint;
14
+ lastTxMs: number;
15
+ }
16
+ /**
17
+ * The ntt deployment on one chain, for one asset.
18
+ *
19
+ * Both halves of a transfer read the same deployment: the rate limits decide
20
+ * whether it is allowed through, the redeem budget decides what delivering it
21
+ * costs. Keyed on the chain the question is about - an inbound limit and a
22
+ * redeem budget are both destination-side.
23
+ */
24
+ export interface NttClient {
25
+ getOutboundLimit(): Promise<NttRateLimit>;
26
+ getInboundLimit(from: AnyChain): Promise<NttRateLimit>;
27
+ /**
28
+ * What the Executor must reserve to redeem this transfer.
29
+ *
30
+ * @param recipient - whose accounts the redeem may have to open. Without it
31
+ * the budget assumes the worst case rather than reading chain.
32
+ */
33
+ getRedeemBudget(recipient?: string): Promise<ExecutorBudget>;
34
+ }
35
+ export declare const UNMETERED: NttRateLimit;
36
+ /**
37
+ * Deployment for the asset this client was built for.
38
+ *
39
+ * Resolved per call rather than in the constructor: a redeem budget on an evm
40
+ * or sui destination never reads the registry, so constructing a client for an
41
+ * unregistered asset must not throw on its own.
42
+ */
43
+ export declare function nttDef(chain: AnyChain, asset?: Asset): NttTokenDef;
44
+ /** Mirrors the manager's linear refill (rate_limit::capacity_at). */
45
+ export declare function capacityAt(limit: bigint, capacityAtLastTx: bigint, lastTxTimestamp: bigint, now: bigint, duration: bigint): bigint;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * What the Executor is asked to reserve to deliver on a destination.
3
+ *
4
+ * `gasLimit` budgets execution, `msgValue` budgets what the executor must
5
+ * hold. Both are destination units - evm gas, svm compute units, sui MIST -
6
+ * so neither has a value that is meaningful across chains.
7
+ */
8
+ export interface ExecutorBudget {
9
+ gasLimit: bigint;
10
+ msgValue: bigint;
11
+ }
12
+ export type ExecutorQuote = {
13
+ /** Quoter-signed cost attestation, passed through to the shim. */
14
+ signedQuote: `0x${string}`;
15
+ /** What the Executor charges for delivery, in source chain native. */
16
+ estimatedCost: bigint;
17
+ /** Serialized delivery request the quote was priced for. */
18
+ relayInstructions: `0x${string}`;
19
+ };
20
+ /**
21
+ * Off-chain Executor quoting service.
22
+ *
23
+ * A signed quote carries its own expiry (an hour, currently) and the executor
24
+ * rejects a stale one, so quotes are reused only while comfortably live.
25
+ */
26
+ export declare class ExecutorClient {
27
+ /** Live quotes, keyed by what they were priced for. */
28
+ private readonly quotes;
29
+ /**
30
+ * Price the delivery of one NTT transfer.
31
+ *
32
+ * @param srcWormholeId - source chain wormhole id
33
+ * @param dstWormholeId - destination chain wormhole id
34
+ * @param budget - what the executor must reserve on the destination, from
35
+ * {@link ExecutorBudget}. Both halves are keyed here: a quote is only
36
+ * honoured for the instructions it priced.
37
+ */
38
+ quote(srcWormholeId: number, dstWormholeId: number, budget: ExecutorBudget): Promise<ExecutorQuote>;
39
+ }
40
+ /**
41
+ * Shared instance - always quote through this, never a fresh client.
42
+ *
43
+ * The route's fee builder quotes to size the funding and the contract builder
44
+ * quotes to spend it, and those two numbers have to be the same one. Quoting
45
+ * twice lets the destination gas price move in between - observed drift was
46
+ * 807e9 wei against a 9e9 margin - and the transfer then reverts underfunded.
47
+ * Separate instances would each hold their own cache and reintroduce exactly
48
+ * that.
49
+ */
50
+ export declare const executorClient: ExecutorClient;
@@ -0,0 +1 @@
1
+ export * from './ExecutorClient';
@@ -8,6 +8,12 @@ export declare function toHubTemplate(asset: Asset, hub: Parachain): AssetRoute;
8
8
  export declare function toHubExtTemplate(asset: Asset): AssetRoute;
9
9
  export declare function toKusamaHubTemplate(asset: Asset, destFee: number, executionFee: number): AssetRoute;
10
10
  export declare function toParaErc20Template(asset: Asset, destination: AnyParachain, transferType?: XcmTransferType): AssetRoute;
11
+ /**
12
+ * Both signer origins are served, and the route declares a config for each:
13
+ * an ss58 signer takes the `extrinsic` (evm calls wrapped in `EVM.call`, one
14
+ * signature, fee quoted by the runtime in the sender's fee currency), an h160
15
+ * signer takes the `contract` and signs plain evm transactions.
16
+ */
11
17
  export declare function viaNttTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
12
18
  /**
13
19
  * Executor-delivered variant, offered alongside the self-redeem route above
@@ -22,10 +28,10 @@ export declare function viaNttTemplate(assetIn: Asset, assetOut: Asset, to: AnyC
22
28
  * would both name the wrong balance and resolve to 12 decimals.
23
29
  *
24
30
  * A sender holding no weth buys it first: the same destination fee swap the
25
- * xcm routes use, batched ahead of the call. Only an ss58 origin needs it -
26
- * that one pays its extrinsic fee in hdx and can hold zero weth. An h160 has
27
- * nothing to batch into, but pays its own gas in weth, so it already holds
28
- * some.
31
+ * xcm routes use, batched ahead of the calls. Only an ss58 origin needs it -
32
+ * that one pays its extrinsic fee in hdx and can hold zero weth, and is the
33
+ * origin whose config is an extrinsic in the first place. An h160 has nothing
34
+ * to batch into, but pays its own gas in weth, so it already holds some.
29
35
  */
30
36
  export declare function viaNttExecutorTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;
31
37
  export declare function viaSnowbridgeTemplate(assetIn: Asset, assetOut: Asset, to: AnyChain): AssetRoute;