@xyo-network/chain-bridge 1.19.6 → 1.19.8
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/node/config/getGateway.d.ts.map +1 -1
- package/dist/node/index.mjs +353 -351
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/manifest/getIterableMap.d.ts +10 -0
- package/dist/node/manifest/getIterableMap.d.ts.map +1 -0
- package/dist/node/manifest/getModuleLocator.d.ts.map +1 -1
- package/dist/node/manifest/getNode.d.ts.map +1 -1
- package/dist/node/manifest/getServices.d.ts.map +1 -1
- package/dist/node/queue/flows/createXl1ToEthBridgeJob.d.ts +6 -0
- package/dist/node/queue/flows/createXl1ToEthBridgeJob.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts +3 -0
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts.map +1 -0
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts +6 -0
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts.map +1 -0
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts +3 -0
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts.map +1 -0
- package/dist/node/queue/workers/WorkerDescription.d.ts +2 -1
- package/dist/node/queue/workers/WorkerDescription.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts +3 -0
- package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -0
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts +3 -0
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -0
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts +3 -0
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -0
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts +3 -0
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -0
- package/dist/node/queue/workers/createWorkers.d.ts +2 -1
- package/dist/node/queue/workers/createWorkers.d.ts.map +1 -1
- package/dist/node/queue/workers/index.d.ts +7 -7
- package/dist/node/queue/workers/util/index.d.ts +3 -0
- package/dist/node/queue/workers/util/index.d.ts.map +1 -0
- package/dist/node/queue/workers/util/submitEthTransaction.d.ts +5 -0
- package/dist/node/queue/workers/util/submitEthTransaction.d.ts.map +1 -0
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts +43 -0
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts.map +1 -0
- package/dist/node/server/{flowProducer.d.ts → addFlowProducer.d.ts} +1 -1
- package/dist/node/server/addFlowProducer.d.ts.map +1 -0
- package/dist/node/server/addWorkers.d.ts +4 -0
- package/dist/node/server/addWorkers.d.ts.map +1 -0
- package/dist/node/server/index.d.ts +0 -2
- package/dist/node/server/index.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts +22 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts +81 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts +72 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts +81 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts.map +1 -1
- package/dist/node/server/server.d.ts.map +1 -1
- package/dist/node/services/IBridgeServiceCollection.d.ts +2 -1
- package/dist/node/services/IBridgeServiceCollection.d.ts.map +1 -1
- package/dist/node/util/calculateBridgeFees.d.ts +1 -1
- package/dist/node/util/calculateBridgeFees.d.ts.map +1 -1
- package/dist/node/util/getConfigFromEnv.d.ts +6 -0
- package/dist/node/util/getConfigFromEnv.d.ts.map +1 -0
- package/dist/node/util/index.d.ts +1 -0
- package/dist/node/util/index.d.ts.map +1 -1
- package/package.json +24 -20
- package/src/config/getBridgeEscrowAddress.ts +2 -2
- package/src/config/getBridgeFeesAddress.ts +2 -2
- package/src/config/getBridgeWalletAccount.ts +1 -1
- package/src/config/getFeeStructure.ts +1 -1
- package/src/config/getGateway.ts +7 -12
- package/src/config/getMaxBridgeAmount.ts +1 -1
- package/src/config/getMinBridgeAmount.ts +1 -1
- package/src/config/getRemoteChainId.ts +1 -1
- package/src/config/getRemoteTokenAddress.ts +1 -1
- package/src/config/getXl1ChainId.ts +1 -1
- package/src/config/getXl1TokenAddress.ts +1 -1
- package/src/manifest/getIterableMap.ts +34 -0
- package/src/manifest/getModuleLocator.ts +4 -6
- package/src/manifest/getNode.ts +8 -6
- package/src/manifest/getServices.ts +11 -47
- package/src/queue/connection.ts +1 -1
- package/src/queue/flows/createXl1ToEthBridgeJob.ts +34 -19
- package/src/queue/workers/{ethTransactionMonitor.ts → EthTransactionMonitor.ts} +16 -7
- package/src/queue/workers/{ethTransactionPreparation.ts → EthTransactionPreparation.ts} +21 -9
- package/src/queue/workers/{ethTransactionSubmission.ts → EthTransactionSubmission.ts} +24 -9
- package/src/queue/workers/WorkerDescription.ts +3 -1
- package/src/queue/workers/{xl1ToEthBridgeParent.ts → Xl1ToEthBridgeParent.ts} +10 -2
- package/src/queue/workers/{xl1TransactionMonitor.ts → Xl1TransactionMonitor.ts} +20 -10
- package/src/queue/workers/{xl1TransactionPreparation.ts → Xl1TransactionPreparation.ts} +16 -5
- package/src/queue/workers/{xl1TransactionSubmission.ts → Xl1TransactionSubmission.ts} +21 -10
- package/src/queue/workers/createWorkers.ts +16 -9
- package/src/queue/workers/index.ts +7 -7
- package/src/queue/workers/util/index.ts +2 -0
- package/src/queue/workers/util/submitEthTransaction.ts +25 -0
- package/src/queue/workers/util/submitXl1Transaction.ts +9 -0
- package/src/server/addWorkers.ts +9 -0
- package/src/server/app.ts +1 -1
- package/src/server/index.ts +2 -2
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeConfig.ts +4 -2
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.ts +13 -10
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.ts +21 -15
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.ts +17 -15
- package/src/server/server.ts +5 -3
- package/src/services/IBridgeServiceCollection.ts +2 -1
- package/src/util/calculateBridgeFees.ts +1 -1
- package/src/util/getConfigFromEnv.ts +15 -0
- package/src/util/index.ts +1 -0
- package/dist/node/queue/workers/ethTransactionMonitor.d.ts +0 -3
- package/dist/node/queue/workers/ethTransactionMonitor.d.ts.map +0 -1
- package/dist/node/queue/workers/ethTransactionPreparation.d.ts +0 -5
- package/dist/node/queue/workers/ethTransactionPreparation.d.ts.map +0 -1
- package/dist/node/queue/workers/ethTransactionSubmission.d.ts +0 -3
- package/dist/node/queue/workers/ethTransactionSubmission.d.ts.map +0 -1
- package/dist/node/queue/workers/xl1ToEthBridgeParent.d.ts +0 -3
- package/dist/node/queue/workers/xl1ToEthBridgeParent.d.ts.map +0 -1
- package/dist/node/queue/workers/xl1TransactionMonitor.d.ts +0 -3
- package/dist/node/queue/workers/xl1TransactionMonitor.d.ts.map +0 -1
- package/dist/node/queue/workers/xl1TransactionPreparation.d.ts +0 -3
- package/dist/node/queue/workers/xl1TransactionPreparation.d.ts.map +0 -1
- package/dist/node/queue/workers/xl1TransactionSubmission.d.ts +0 -3
- package/dist/node/queue/workers/xl1TransactionSubmission.d.ts.map +0 -1
- package/dist/node/server/flowProducer.d.ts.map +0 -1
- /package/src/server/{flowProducer.ts → addFlowProducer.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js';
|
|
2
2
|
import type { AccountInstance } from '@xyo-network/account-model';
|
|
3
|
-
import type { LiquidityPoolBridge } from '@xyo-network/typechain';
|
|
3
|
+
import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain';
|
|
4
4
|
import type { IterableMap, XyoGatewayRunner } from '@xyo-network/xl1-sdk';
|
|
5
5
|
import type { Provider, Wallet } from 'ethers';
|
|
6
6
|
import type { EthTxState } from './EthTxState.ts';
|
|
@@ -8,6 +8,7 @@ import type { Xl1TxState } from './Xl1TxState.ts';
|
|
|
8
8
|
export interface IBridgeServiceCollection {
|
|
9
9
|
account: AccountInstance;
|
|
10
10
|
bridge: LiquidityPoolBridge;
|
|
11
|
+
bridgeableToken: BridgeableToken;
|
|
11
12
|
ethTxStateMap: IterableMap<Hash, EthTxState>;
|
|
12
13
|
gateway: XyoGatewayRunner;
|
|
13
14
|
provider: Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IBridgeServiceCollection.d.ts","sourceRoot":"","sources":["../../../src/services/IBridgeServiceCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"IBridgeServiceCollection.d.ts","sourceRoot":"","sources":["../../../src/services/IBridgeServiceCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,eAAe,EAAE,eAAe,CAAA;IAChC,aAAa,EAAE,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC5C,OAAO,EAAE,gBAAgB,CAAA;IACzB,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;CAC7C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hex } from '@xylabs/sdk-js';
|
|
2
2
|
import type { Config } from '@xyo-network/xl1-sdk';
|
|
3
|
-
export type FeeStructure = Pick<Config['bridge'], 'feeFixed' | 'feeRateBasisPoints'>;
|
|
3
|
+
export type FeeStructure = Pick<Config['actors']['bridge'], 'feeFixed' | 'feeRateBasisPoints'>;
|
|
4
4
|
export interface FeeCalculationResult {
|
|
5
5
|
destAmount: Hex;
|
|
6
6
|
feeFixed: Hex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateBridgeFees.d.ts","sourceRoot":"","sources":["../../../src/util/calculateBridgeFees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,oBAAoB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"calculateBridgeFees.d.ts","sourceRoot":"","sources":["../../../src/util/calculateBridgeFees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,oBAAoB,CAAC,CAAA;AAE9F,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,GAAG,CAAA;IACf,QAAQ,EAAE,GAAG,CAAA;IACb,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,GAAG,EAAE,cAAc,YAAY,KAAG,oBA0BhF,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Config } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import type { Configuration } from 'yargs-parser';
|
|
3
|
+
export declare const ConfigParserEnvPrefix = "XL1_";
|
|
4
|
+
export declare const ConfigParserConfiguration: Partial<Configuration>;
|
|
5
|
+
export declare const getConfigFromEnv: () => Config;
|
|
6
|
+
//# sourceMappingURL=getConfigFromEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigFromEnv.d.ts","sourceRoot":"","sources":["../../../src/util/getConfigFromEnv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,eAAO,MAAM,qBAAqB,SAAS,CAAA;AAC3C,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAAC,aAAa,CAI5D,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,MAGnC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './calculateBridgeFees.ts';
|
|
2
2
|
export * from './generateBridgeEstimate.ts';
|
|
3
|
+
export * from './getConfigFromEnv.ts';
|
|
3
4
|
export * from './validateBridgeEstimate.ts';
|
|
4
5
|
export * from './validateBridgeEstimateExact.ts';
|
|
5
6
|
export * from './validateBridgeTransaction.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/chain-bridge",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.8",
|
|
4
4
|
"description": "XYO Layer One Bridge",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -52,17 +52,18 @@
|
|
|
52
52
|
"@opentelemetry/instrumentation": "~0.211.0",
|
|
53
53
|
"@opentelemetry/instrumentation-express": "~0.59.0",
|
|
54
54
|
"@opentelemetry/instrumentation-http": "~0.211.0",
|
|
55
|
-
"@xylabs/express": "~5.0.
|
|
56
|
-
"@xylabs/mongo": "~5.0.
|
|
57
|
-
"@xylabs/sdk-js": "~5.0.
|
|
55
|
+
"@xylabs/express": "~5.0.78",
|
|
56
|
+
"@xylabs/mongo": "~5.0.78",
|
|
57
|
+
"@xylabs/sdk-js": "~5.0.78",
|
|
58
58
|
"@xyo-network/archivist-memory": "~5.3.2",
|
|
59
59
|
"@xyo-network/archivist-mongodb": "~5.3.2",
|
|
60
60
|
"@xyo-network/archivist-view": "~5.3.2",
|
|
61
61
|
"@xyo-network/bios": "~7.2.1",
|
|
62
62
|
"@xyo-network/boundwitness-validator": "~5.3.2",
|
|
63
|
-
"@xyo-network/chain-
|
|
64
|
-
"@xyo-network/chain-
|
|
65
|
-
"@xyo-network/chain-
|
|
63
|
+
"@xyo-network/chain-orchestration": "~1.19.8",
|
|
64
|
+
"@xyo-network/chain-protocol": "~1.19.8",
|
|
65
|
+
"@xyo-network/chain-services": "~1.19.8",
|
|
66
|
+
"@xyo-network/chain-telemetry": "~1.19.8",
|
|
66
67
|
"@xyo-network/manifest-model": "~5.3.2",
|
|
67
68
|
"@xyo-network/manifest-wrapper": "~5.3.2",
|
|
68
69
|
"@xyo-network/module-abstract": "~5.3.2",
|
|
@@ -77,15 +78,16 @@
|
|
|
77
78
|
"@xyo-network/typechain": "~4.1.1",
|
|
78
79
|
"@xyo-network/wallet": "~5.3.2",
|
|
79
80
|
"@xyo-network/wallet-model": "~5.3.2",
|
|
80
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
81
|
+
"@xyo-network/xl1-sdk": "~1.23.6",
|
|
81
82
|
"async-mutex": "~0.5.0",
|
|
82
|
-
"bullmq": "~5.67.
|
|
83
|
+
"bullmq": "~5.67.3",
|
|
83
84
|
"compression": "~1.8.1",
|
|
84
85
|
"cors": "~2.8.6",
|
|
85
86
|
"ethers": "^6.16.0",
|
|
86
87
|
"express": "~5.2.1",
|
|
87
88
|
"ioredis": "~5.9.2",
|
|
88
|
-
"uuid": "~13.0.0"
|
|
89
|
+
"uuid": "~13.0.0",
|
|
90
|
+
"yargs-parser": "~22.0.0"
|
|
89
91
|
},
|
|
90
92
|
"devDependencies": {
|
|
91
93
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -93,12 +95,13 @@
|
|
|
93
95
|
"@types/cors": "~2.8.19",
|
|
94
96
|
"@types/express": "5.0.6",
|
|
95
97
|
"@types/express-serve-static-core": "~5.1.1",
|
|
96
|
-
"@types/node": "~25.
|
|
97
|
-
"@xylabs/
|
|
98
|
-
"@xylabs/
|
|
98
|
+
"@types/node": "~25.2.3",
|
|
99
|
+
"@xylabs/axios": "~5.0.78",
|
|
100
|
+
"@xylabs/mongo": "~5.0.78",
|
|
101
|
+
"@xylabs/sdk-js": "~5.0.78",
|
|
99
102
|
"@xylabs/ts-scripts-yarn3": "~7.3.2",
|
|
100
103
|
"@xylabs/tsconfig": "~7.3.2",
|
|
101
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
104
|
+
"@xylabs/vitest-extended": "~5.0.78",
|
|
102
105
|
"@xyo-network/account": "~5.3.2",
|
|
103
106
|
"@xyo-network/account-model": "~5.3.2",
|
|
104
107
|
"@xyo-network/archivist-abstract": "~5.3.2",
|
|
@@ -109,9 +112,9 @@
|
|
|
109
112
|
"@xyo-network/bios": "~7.2.1",
|
|
110
113
|
"@xyo-network/bios-model": "~7.2.1",
|
|
111
114
|
"@xyo-network/boundwitness-builder": "~5.3.2",
|
|
112
|
-
"@xyo-network/chain-protocol": "~1.19.
|
|
113
|
-
"@xyo-network/chain-services": "~1.19.
|
|
114
|
-
"@xyo-network/chain-telemetry": "~1.19.
|
|
115
|
+
"@xyo-network/chain-protocol": "~1.19.8",
|
|
116
|
+
"@xyo-network/chain-services": "~1.19.8",
|
|
117
|
+
"@xyo-network/chain-telemetry": "~1.19.8",
|
|
115
118
|
"@xyo-network/manifest-wrapper": "~5.3.2",
|
|
116
119
|
"@xyo-network/module-abstract": "~5.3.2",
|
|
117
120
|
"@xyo-network/module-abstract-mongodb": "~5.3.2",
|
|
@@ -120,13 +123,14 @@
|
|
|
120
123
|
"@xyo-network/payload-builder": "~5.3.2",
|
|
121
124
|
"@xyo-network/sentinel-memory": "~5.3.2",
|
|
122
125
|
"@xyo-network/wallet": "~5.3.2",
|
|
123
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
126
|
+
"@xyo-network/xl1-sdk": "~1.23.6",
|
|
124
127
|
"async-mutex": "~0.5.0",
|
|
125
|
-
"
|
|
128
|
+
"axios": "~1.13.5",
|
|
129
|
+
"dotenv": "~17.2.4",
|
|
126
130
|
"eslint": "^9.39.2",
|
|
127
131
|
"ethers": "^6.16.0",
|
|
128
132
|
"http-status-codes": "~2.3.0",
|
|
129
|
-
"mongodb": "~7.
|
|
133
|
+
"mongodb": "~7.1.0",
|
|
130
134
|
"nodemon": "~3.1.11",
|
|
131
135
|
"tslib": "~2.8.1",
|
|
132
136
|
"typescript": "~5.9.3",
|
|
@@ -3,11 +3,11 @@ import { asAddress, assertEx } from '@xylabs/sdk-js'
|
|
|
3
3
|
import type { Config } from '@xyo-network/xl1-sdk'
|
|
4
4
|
|
|
5
5
|
export const tryGetBridgeEscrowAddress = (config: Config): Address | undefined => {
|
|
6
|
-
const address = asAddress(config.bridge.escrowAddress)
|
|
6
|
+
const address = asAddress(config.actors.bridge.escrowAddress)
|
|
7
7
|
return address
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const getBridgeEscrowAddress = (config: Config): Address => {
|
|
11
|
-
const address = assertEx(tryGetBridgeEscrowAddress(config), () => `Invalid bridge escrow address: ${config.bridge.escrowAddress}`)
|
|
11
|
+
const address = assertEx(tryGetBridgeEscrowAddress(config), () => `Invalid bridge escrow address: ${config.actors.bridge.escrowAddress}`)
|
|
12
12
|
return address
|
|
13
13
|
}
|
|
@@ -3,11 +3,11 @@ import { asAddress, assertEx } from '@xylabs/sdk-js'
|
|
|
3
3
|
import type { Config } from '@xyo-network/xl1-sdk'
|
|
4
4
|
|
|
5
5
|
export const tryGetBridgeFeesAddress = (config: Config): Address | undefined => {
|
|
6
|
-
const address = asAddress(config.bridge.feesAddress)
|
|
6
|
+
const address = asAddress(config.actors.bridge.feesAddress)
|
|
7
7
|
return address
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const getBridgeFeesAddress = (config: Config): Address => {
|
|
11
|
-
const address = assertEx(tryGetBridgeFeesAddress(config), () => `Invalid bridge fees address: ${config.bridge.feesAddress}`)
|
|
11
|
+
const address = assertEx(tryGetBridgeFeesAddress(config), () => `Invalid bridge fees address: ${config.actors.bridge.feesAddress}`)
|
|
12
12
|
return address
|
|
13
13
|
}
|
|
@@ -9,7 +9,7 @@ let accountServiceSingleton: Promisable<WalletInstance> | undefined
|
|
|
9
9
|
|
|
10
10
|
export const getBridgeWalletAccount = async (config: Config): Promise<WalletInstance> => {
|
|
11
11
|
if (accountServiceSingleton) return accountServiceSingleton
|
|
12
|
-
let walletPhrase = config.bridge.mnemonic
|
|
12
|
+
let walletPhrase = config.actors.bridge.mnemonic
|
|
13
13
|
if (isUndefined(walletPhrase)) {
|
|
14
14
|
console.log('[Bridge] No wallet mnemonic specified!')
|
|
15
15
|
const randomMnemonic = HDWallet.generateMnemonic()
|
|
@@ -3,6 +3,6 @@ import type { Config } from '@xyo-network/xl1-sdk'
|
|
|
3
3
|
import type { FeeStructure } from '../util/index.ts'
|
|
4
4
|
|
|
5
5
|
export const getFeeStructure = (config: Config): FeeStructure => {
|
|
6
|
-
const { feeFixed, feeRateBasisPoints } = config.bridge
|
|
6
|
+
const { feeFixed, feeRateBasisPoints } = config.actors.bridge
|
|
7
7
|
return { feeFixed, feeRateBasisPoints }
|
|
8
8
|
}
|
package/src/config/getGateway.ts
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import { isDefined } from '@xylabs/sdk-js'
|
|
2
2
|
import { HDWallet } from '@xyo-network/wallet'
|
|
3
3
|
import type {
|
|
4
|
-
Config, RpcSchemaMap, TransportFactory,
|
|
5
|
-
XyoGatewayRunner,
|
|
4
|
+
Config, RpcSchemaMap, TransportFactory, XyoGatewayRunner,
|
|
6
5
|
} from '@xyo-network/xl1-sdk'
|
|
7
6
|
import {
|
|
8
|
-
buildJsonRpcProviderLocator,
|
|
9
|
-
HttpRpcTransport,
|
|
10
|
-
SimpleXyoGatewayRunner, SimpleXyoSigner,
|
|
11
|
-
XyoGatewayRunnerMoniker,
|
|
7
|
+
ADDRESS_INDEX, buildJsonRpcProviderLocator, generateXyoBaseWalletFromPhrase, HttpRpcTransport, XyoGatewayRunnerMoniker,
|
|
12
8
|
} from '@xyo-network/xl1-sdk'
|
|
13
9
|
|
|
14
10
|
let gatewayInstance: XyoGatewayRunner | undefined
|
|
15
11
|
|
|
16
12
|
export const getGateway = async (config: Config): Promise<XyoGatewayRunner> => {
|
|
17
13
|
if (isDefined(gatewayInstance)) return gatewayInstance
|
|
18
|
-
const { mnemonic, chainRpcApiUrl: endpoint } = config.bridge
|
|
19
|
-
const
|
|
20
|
-
const
|
|
14
|
+
const { mnemonic, chainRpcApiUrl: endpoint } = config.actors.bridge
|
|
15
|
+
const walletPhrase = isDefined(mnemonic) ? mnemonic : HDWallet.generateMnemonic()
|
|
16
|
+
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
|
|
17
|
+
const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO)
|
|
21
18
|
const transportFactory: TransportFactory = (schemas: RpcSchemaMap) => new HttpRpcTransport(endpoint, schemas)
|
|
22
|
-
const locator = await buildJsonRpcProviderLocator({ transportFactory })
|
|
23
|
-
locator.register(SimpleXyoSigner.factory<SimpleXyoSigner>(SimpleXyoSigner.dependencies, { account }))
|
|
24
|
-
locator.register(SimpleXyoGatewayRunner.factory<SimpleXyoGatewayRunner>(SimpleXyoGatewayRunner.dependencies))
|
|
19
|
+
const locator = await buildJsonRpcProviderLocator({ transportFactory, signerAccount })
|
|
25
20
|
return await locator.getInstance<XyoGatewayRunner>(XyoGatewayRunnerMoniker)
|
|
26
21
|
}
|
|
@@ -2,6 +2,6 @@ import type { Hex } from '@xylabs/sdk-js'
|
|
|
2
2
|
import type { Config } from '@xyo-network/xl1-sdk'
|
|
3
3
|
|
|
4
4
|
export const getMaxBridgeAmount = (config: Config): Hex => {
|
|
5
|
-
const { maxBridgeAmount } = config.bridge
|
|
5
|
+
const { maxBridgeAmount } = config.actors.bridge
|
|
6
6
|
return maxBridgeAmount
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@ import type { Hex } from '@xylabs/sdk-js'
|
|
|
2
2
|
import type { Config } from '@xyo-network/xl1-sdk'
|
|
3
3
|
|
|
4
4
|
export const getMinBridgeAmount = (config: Config): Hex => {
|
|
5
|
-
const { minBridgeAmount } = config.bridge
|
|
5
|
+
const { minBridgeAmount } = config.actors.bridge
|
|
6
6
|
return minBridgeAmount
|
|
7
7
|
}
|
|
@@ -4,6 +4,6 @@ import type { ChainId, Config } from '@xyo-network/xl1-sdk'
|
|
|
4
4
|
import { asChainId } from './asChainId.ts'
|
|
5
5
|
|
|
6
6
|
export const getRemoteChainId = (config: Config): ChainId => {
|
|
7
|
-
const remoteChainId = assertEx(asChainId(config.bridge.remoteChainId), () => 'Invalid remote chain ID in config')
|
|
7
|
+
const remoteChainId = assertEx(asChainId(config.actors.bridge.remoteChainId), () => 'Invalid remote chain ID in config')
|
|
8
8
|
return remoteChainId
|
|
9
9
|
}
|
|
@@ -5,6 +5,6 @@ import type { Config } from '@xyo-network/xl1-sdk'
|
|
|
5
5
|
import { asToken } from './asToken.ts'
|
|
6
6
|
|
|
7
7
|
export const getRemoteTokenAddress = (config: Config): Address => {
|
|
8
|
-
const token = asToken(config.bridge.remoteTokenAddress)
|
|
8
|
+
const token = asToken(config.actors.bridge.remoteTokenAddress)
|
|
9
9
|
return assertEx(token, () => 'Remote token address is not defined in bridge configuration')
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import type { ChainId, Config } from '@xyo-network/xl1-sdk'
|
|
|
4
4
|
import { asChainId } from './asChainId.ts'
|
|
5
5
|
|
|
6
6
|
export const getXl1ChainId = (config: Config): ChainId => {
|
|
7
|
-
const xl1ChainId = config.bridge.xl1ChainId
|
|
7
|
+
const xl1ChainId = config.actors.bridge.xl1ChainId
|
|
8
8
|
if (isDefined(xl1ChainId)) {
|
|
9
9
|
return assertEx(asChainId(xl1ChainId), () => 'Invalid xl1ChainId in bridge config')
|
|
10
10
|
}
|
|
@@ -6,7 +6,7 @@ import { asToken } from './asToken.ts'
|
|
|
6
6
|
import { getXl1ChainId } from './getXl1ChainId.ts'
|
|
7
7
|
|
|
8
8
|
export const getXl1TokenAddress = (config: Config): Hex => {
|
|
9
|
-
const token = asToken(config.bridge.xl1TokenAddress)
|
|
9
|
+
const token = asToken(config.actors.bridge.xl1TokenAddress)
|
|
10
10
|
if (isDefined(token)) return token
|
|
11
11
|
return getXl1ChainId(config)
|
|
12
12
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseMongoSdk, type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'
|
|
2
|
+
import { MongoMap } from '@xyo-network/chain-protocol'
|
|
3
|
+
import type { Config, IterableMap } from '@xyo-network/xl1-sdk'
|
|
4
|
+
import { hasMongoConfig, mapToMapType } from '@xyo-network/xl1-sdk'
|
|
5
|
+
import type { Document } from 'mongodb'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets an iterable map based on the storage instructions in the config
|
|
9
|
+
* @param config The config containing storage instructions
|
|
10
|
+
* @param collection The collection to use if using MongoDB for persistence
|
|
11
|
+
* @returns The iterable map
|
|
12
|
+
*/
|
|
13
|
+
export const getIterableMap = async <K extends {} = string, V extends Document = Document>(
|
|
14
|
+
config: Config,
|
|
15
|
+
collection: string,
|
|
16
|
+
): Promise<IterableMap<K, V>> => {
|
|
17
|
+
const mongoConfig = config.storage?.mongo
|
|
18
|
+
if (hasMongoConfig(mongoConfig)) {
|
|
19
|
+
const {
|
|
20
|
+
connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,
|
|
21
|
+
} = mongoConfig
|
|
22
|
+
const payloadSdkConfig: BaseMongoSdkPrivateConfig = {
|
|
23
|
+
dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,
|
|
24
|
+
}
|
|
25
|
+
const sdkBalanceSummaryMap = new BaseMongoSdk<V>({ ...payloadSdkConfig, collection })
|
|
26
|
+
const result = await MongoMap.create<MongoMap<K, V>>({
|
|
27
|
+
sdk: sdkBalanceSummaryMap,
|
|
28
|
+
getCache: { enabled: true, maxEntries: 5000 },
|
|
29
|
+
})
|
|
30
|
+
return result
|
|
31
|
+
} else {
|
|
32
|
+
return mapToMapType(new Map<K, V>())
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -4,20 +4,18 @@ import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
|
4
4
|
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
5
5
|
import { MongoDBArchivistV2 } from '@xyo-network/archivist-mongodb'
|
|
6
6
|
import { ViewArchivist } from '@xyo-network/archivist-view'
|
|
7
|
+
import { initEvmProvider } from '@xyo-network/chain-orchestration'
|
|
7
8
|
import { MongoMap } from '@xyo-network/chain-protocol'
|
|
8
|
-
import { initEvmProvider } from '@xyo-network/chain-services'
|
|
9
9
|
import { initTelemetry } from '@xyo-network/chain-telemetry'
|
|
10
10
|
import { AbstractModule, LoggerModuleStatusReporter } from '@xyo-network/module-abstract'
|
|
11
11
|
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
12
12
|
import type { MongoDBModuleParamsV2 } from '@xyo-network/module-model-mongodb'
|
|
13
13
|
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
14
14
|
import type {
|
|
15
|
-
BridgeDestinationObservation, Config, IterableMap, ProviderFactoryLocator, SignedHydratedTransaction,
|
|
16
|
-
XyoGatewayRunner,
|
|
15
|
+
BridgeDestinationObservation, Config, IterableMap, ProviderFactoryLocator, SignedHydratedTransaction, XyoGatewayRunner,
|
|
17
16
|
} from '@xyo-network/xl1-sdk'
|
|
18
17
|
import {
|
|
19
|
-
hasMongoConfig, mapToMapType,
|
|
20
|
-
XyoGatewayRunnerMoniker,
|
|
18
|
+
hasMongoConfig, mapToMapType, XyoGatewayRunnerMoniker,
|
|
21
19
|
} from '@xyo-network/xl1-sdk'
|
|
22
20
|
import type { Document } from 'mongodb'
|
|
23
21
|
|
|
@@ -111,7 +109,7 @@ export const getModuleLocator = async (context: GetLocatorContext) => {
|
|
|
111
109
|
'liquidity_bridge_eth_xl1_bridge_completed',
|
|
112
110
|
)
|
|
113
111
|
const provider = await initEvmProvider({ config })
|
|
114
|
-
const bridgeAddress = config.bridge.remoteBridgeContractAddress
|
|
112
|
+
const bridgeAddress = config.actors.bridge.remoteBridgeContractAddress
|
|
115
113
|
const evmLiquidityBridgeTransactionCompletionMonitorSentinelParams: EVMLiquidityBridgeTransactionCompletionMonitorSentinelParams = {
|
|
116
114
|
bridgeAddress,
|
|
117
115
|
completedTransactions: completedEthXl1BridgeTransactions,
|
package/src/manifest/getNode.ts
CHANGED
|
@@ -6,10 +6,9 @@ import type {
|
|
|
6
6
|
} from '@xyo-network/xl1-sdk'
|
|
7
7
|
import { buildJsonRpcProviderLocator, HttpRpcTransport } from '@xyo-network/xl1-sdk'
|
|
8
8
|
|
|
9
|
+
import { getBridgeWalletAccount } from '../config/index.ts'
|
|
9
10
|
import { getModuleLocator } from './getModuleLocator.ts'
|
|
10
11
|
import { NodeManifest } from './nodeManifest.ts'
|
|
11
|
-
import { PrivateChildManifests } from './private/index.ts'
|
|
12
|
-
import { PublicChildManifests } from './public/index.ts'
|
|
13
12
|
|
|
14
13
|
export interface GetNodeContext {
|
|
15
14
|
config: Config
|
|
@@ -23,12 +22,15 @@ export interface GetNodeContext {
|
|
|
23
22
|
* @returns A node with the xyo-chain modules registered
|
|
24
23
|
*/
|
|
25
24
|
export const getNode = async (context: GetNodeContext) => {
|
|
26
|
-
const { wallet } = context
|
|
27
|
-
const { chainRpcApiUrl: endpoint } =
|
|
25
|
+
const { config, wallet } = context
|
|
26
|
+
const { chainRpcApiUrl: endpoint } = config.actors.bridge
|
|
28
27
|
const transportFactory: TransportFactory = (schemas: RpcSchemaMap) => new HttpRpcTransport(endpoint, schemas)
|
|
29
|
-
const
|
|
28
|
+
const signerAccount = await getBridgeWalletAccount(config)
|
|
29
|
+
const locator = await buildJsonRpcProviderLocator({ signerAccount, transportFactory })
|
|
30
|
+
|
|
30
31
|
const moduleLocator = await getModuleLocator({ ...context, locator })
|
|
31
|
-
const wrapper = new ManifestWrapper(NodeManifest, wallet, moduleLocator, PublicChildManifests, PrivateChildManifests)
|
|
32
|
+
// const wrapper = new ManifestWrapper(NodeManifest, wallet, moduleLocator, PublicChildManifests, PrivateChildManifests)
|
|
33
|
+
const wrapper = new ManifestWrapper(NodeManifest, wallet, moduleLocator, [], [])
|
|
32
34
|
const [node, ...childNodes] = await wrapper.loadNodes()
|
|
33
35
|
if (childNodes?.length > 0) {
|
|
34
36
|
await Promise.all(childNodes.map(childNode => node.register(childNode)))
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { BaseMongoSdk, type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'
|
|
2
1
|
import type { Hash, Logger } from '@xylabs/sdk-js'
|
|
3
2
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { LiquidityPoolBridge__factory } from '@xyo-network/typechain'
|
|
3
|
+
import { initEvmProvider } from '@xyo-network/chain-orchestration'
|
|
4
|
+
import { BridgeableToken__factory, LiquidityPoolBridge__factory } from '@xyo-network/typechain'
|
|
7
5
|
import { HDWallet } from '@xyo-network/wallet'
|
|
8
|
-
import type { Config
|
|
9
|
-
import {
|
|
10
|
-
hasMongoConfig,
|
|
11
|
-
mapToMapType,
|
|
12
|
-
} from '@xyo-network/xl1-sdk'
|
|
6
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
13
7
|
import { getAddress, Wallet } from 'ethers'
|
|
14
|
-
import type { Document } from 'mongodb'
|
|
15
8
|
|
|
16
9
|
import { getGateway } from '../config/index.ts'
|
|
17
10
|
import type {
|
|
18
11
|
EthTxState, IBridgeServiceCollection, Xl1TxState,
|
|
19
12
|
} from '../services/index.ts'
|
|
13
|
+
import { getIterableMap } from './getIterableMap.ts'
|
|
20
14
|
|
|
21
15
|
export interface GetServicesContext {
|
|
22
16
|
config: Config
|
|
@@ -34,50 +28,20 @@ export const getServices = async (context: GetServicesContext): Promise<IBridgeS
|
|
|
34
28
|
const ethTxStateMap = await getIterableMap<Hash, EthTxState>(config, 'liquidity_bridge_xl1_to_eth_eth_tx_state')
|
|
35
29
|
const xl1TxStateMap = await getIterableMap<Hash, Xl1TxState>(config, 'liquidity_bridge_xl1_to_eth_xl1_tx_state')
|
|
36
30
|
const provider = await initEvmProvider({ config })
|
|
37
|
-
// TODO: Get from config
|
|
38
31
|
const {
|
|
39
|
-
remoteBridgeContractAddress, remoteChainWalletPrivateKey, mnemonic,
|
|
40
|
-
} = config.bridge
|
|
32
|
+
remoteBridgeContractAddress, remoteChainWalletPrivateKey, remoteTokenAddress, mnemonic,
|
|
33
|
+
} = config.actors.bridge
|
|
41
34
|
const account = isDefined(mnemonic) ? await HDWallet.fromPhrase(mnemonic) : await HDWallet.random()
|
|
42
35
|
const wallet = new Wallet(remoteChainWalletPrivateKey, provider)
|
|
36
|
+
const bridgeableToken = BridgeableToken__factory.connect(getAddress(remoteTokenAddress), wallet)
|
|
43
37
|
const bridge = LiquidityPoolBridge__factory.connect(getAddress(remoteBridgeContractAddress), wallet)
|
|
38
|
+
// const approvalAmount = 18n * 10n ** 9n * 10n ** 18n // 18 billion tokens with 18 decimals
|
|
39
|
+
// const contractApprovalTx = await bridgeableToken.connect(wallet).approve(bridge.getAddress(), approvalAmount)
|
|
40
|
+
// await contractApprovalTx.wait(1)
|
|
44
41
|
// Assert we are contract owner so we can call ownable methods
|
|
45
42
|
const bridgeOwner = await bridge.owner()
|
|
46
43
|
assertEx(bridgeOwner.toLowerCase() === wallet.address.toLowerCase(), () => 'Wallet is not the owner of the bridge contract')
|
|
47
44
|
return {
|
|
48
|
-
account,
|
|
49
|
-
bridge,
|
|
50
|
-
ethTxStateMap,
|
|
51
|
-
gateway,
|
|
52
|
-
provider,
|
|
53
|
-
wallet,
|
|
54
|
-
xl1TxStateMap,
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Gets an iterable map based on the storage instructions in the config
|
|
60
|
-
* @param config The config containing storage instructions
|
|
61
|
-
* @param collection The collection to use if using MongoDB for persistence
|
|
62
|
-
* @returns The iterable map
|
|
63
|
-
*/
|
|
64
|
-
const getIterableMap = async <K extends {} = string, V extends Document = Document>
|
|
65
|
-
(config: Config, collection: string): Promise<IterableMap<K, V>> => {
|
|
66
|
-
const mongoConfig = config.storage?.mongo
|
|
67
|
-
if (hasMongoConfig(mongoConfig)) {
|
|
68
|
-
const {
|
|
69
|
-
connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,
|
|
70
|
-
} = mongoConfig
|
|
71
|
-
const payloadSdkConfig: BaseMongoSdkPrivateConfig = {
|
|
72
|
-
dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,
|
|
73
|
-
}
|
|
74
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk<V>({ ...payloadSdkConfig, collection })
|
|
75
|
-
const result = await MongoMap.create<MongoMap<K, V>>({
|
|
76
|
-
sdk: sdkBalanceSummaryMap,
|
|
77
|
-
getCache: { enabled: true, maxEntries: 5000 },
|
|
78
|
-
})
|
|
79
|
-
return result
|
|
80
|
-
} else {
|
|
81
|
-
return mapToMapType(new Map<K, V>())
|
|
45
|
+
account, bridge, bridgeableToken, ethTxStateMap, gateway, provider, wallet, xl1TxStateMap,
|
|
82
46
|
}
|
|
83
47
|
}
|
package/src/queue/connection.ts
CHANGED
|
@@ -8,7 +8,7 @@ const maxRetriesPerRequest = null
|
|
|
8
8
|
|
|
9
9
|
export const getConnection = (config: Config) => {
|
|
10
10
|
if (isDefined(connection)) return connection
|
|
11
|
-
const { redisHost: host, redisPort: port } = config.bridge
|
|
11
|
+
const { redisHost: host, redisPort: port } = config.actors.bridge
|
|
12
12
|
connection = new Redis({
|
|
13
13
|
host, port, maxRetriesPerRequest,
|
|
14
14
|
})
|
|
@@ -2,47 +2,62 @@ import type { SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
|
|
|
2
2
|
import type { FlowProducer } from 'bullmq'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
EthTransactionMonitor, EthTransactionPreparation, EthTransactionSubmission, Xl1ToEthBridgeParent, Xl1TransactionMonitor, Xl1TransactionPreparation,
|
|
6
|
+
Xl1TransactionSubmission,
|
|
7
7
|
} from '../workers/index.ts'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a job flow for bridging a transaction from XL1 to Ethereum.
|
|
11
|
+
* @param flowProducer The flow producer to run the job
|
|
12
|
+
* @param tx The bridge transaction
|
|
13
|
+
* @returns The JobNode representing the XL1 to ETH bridge job
|
|
14
|
+
*/
|
|
15
|
+
export const createXl1ToEthBridgeJob = async (
|
|
16
|
+
flowProducer: FlowProducer,
|
|
17
|
+
tx: SignedHydratedTransaction,
|
|
18
|
+
) => {
|
|
10
19
|
const flow = await flowProducer.add({
|
|
11
|
-
name:
|
|
12
|
-
queueName:
|
|
20
|
+
name: Xl1ToEthBridgeParent.name,
|
|
21
|
+
queueName: Xl1ToEthBridgeParent.queueName,
|
|
13
22
|
data: { tx },
|
|
14
23
|
children: [
|
|
15
24
|
{
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
// Step 6 (runs after child completes)
|
|
26
|
+
name: EthTransactionMonitor.name,
|
|
27
|
+
queueName: EthTransactionMonitor.queueName,
|
|
18
28
|
data: { tx },
|
|
29
|
+
opts: { attempts: 60, backoff: { type: 'fixed', delay: 5000 } },
|
|
19
30
|
children: [
|
|
20
31
|
{
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
// Step 5
|
|
33
|
+
name: EthTransactionSubmission.name,
|
|
34
|
+
queueName: EthTransactionSubmission.queueName,
|
|
23
35
|
data: { tx },
|
|
24
36
|
children: [
|
|
25
37
|
{
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
// Step 4
|
|
39
|
+
name: EthTransactionPreparation.name,
|
|
40
|
+
queueName: EthTransactionPreparation.queueName,
|
|
28
41
|
data: { tx },
|
|
29
|
-
opts: { attempts: 60, backoff: { type: 'fixed', delay: 5000 } },
|
|
30
42
|
children: [
|
|
31
43
|
{
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
// Step 3
|
|
45
|
+
name: Xl1TransactionMonitor.name,
|
|
46
|
+
queueName: Xl1TransactionMonitor.queueName,
|
|
34
47
|
data: { tx },
|
|
48
|
+
opts: { attempts: 60, backoff: { type: 'fixed', delay: 5000 } },
|
|
35
49
|
children: [
|
|
36
50
|
{
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
// Step 2
|
|
52
|
+
name: Xl1TransactionSubmission.name,
|
|
53
|
+
queueName: Xl1TransactionSubmission.queueName,
|
|
39
54
|
data: { tx },
|
|
40
55
|
children: [
|
|
41
56
|
{
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
// Step 1 (runs first as deepest child)
|
|
58
|
+
name: Xl1TransactionPreparation.name,
|
|
59
|
+
queueName: Xl1TransactionPreparation.queueName,
|
|
44
60
|
data: { tx },
|
|
45
|
-
opts: { attempts: 60, backoff: { type: 'fixed', delay: 5000 } },
|
|
46
61
|
},
|
|
47
62
|
],
|
|
48
63
|
},
|
|
@@ -8,7 +8,7 @@ import type { Redis } from 'ioredis'
|
|
|
8
8
|
import type { IBridgeServiceCollection } from '../../services/index.ts'
|
|
9
9
|
import type { WorkerDescription } from './WorkerDescription.ts'
|
|
10
10
|
|
|
11
|
-
type JobData =
|
|
11
|
+
type JobData = { tx: SignedHydratedTransaction }
|
|
12
12
|
interface ReturnType {
|
|
13
13
|
blockHash: string
|
|
14
14
|
blockNumber: number
|
|
@@ -16,13 +16,14 @@ interface ReturnType {
|
|
|
16
16
|
|
|
17
17
|
const name = 'Monitor Submitted ETH Transaction'
|
|
18
18
|
const queueName = 'eth-tx-monitor'
|
|
19
|
-
const createWorker = (connection: Redis) => {
|
|
20
|
-
|
|
19
|
+
const createWorker = (connection: Redis, services?: IBridgeServiceCollection) => {
|
|
20
|
+
const provider = assertEx(services?.provider, () => 'provider service not provided')
|
|
21
|
+
const stateMap = assertEx(services?.ethTxStateMap, () => 'ethTxStateMap service not provided')
|
|
22
|
+
|
|
23
|
+
const worker = new Worker(
|
|
21
24
|
queueName,
|
|
22
25
|
async (job: Job<JobData, ReturnType>) => {
|
|
23
|
-
const {
|
|
24
|
-
provider, ethTxStateMap: stateMap, tx,
|
|
25
|
-
} = job.data
|
|
26
|
+
const { tx } = job.data
|
|
26
27
|
const hash = await PayloadBuilder.hash(tx[0])
|
|
27
28
|
const state = assertEx(await stateMap.get(hash), () => 'State not found')
|
|
28
29
|
const submissionHash = assertEx(state?.submissionHash, () => 'submissionHash not found')
|
|
@@ -35,8 +36,16 @@ const createWorker = (connection: Redis) => {
|
|
|
35
36
|
},
|
|
36
37
|
{ connection },
|
|
37
38
|
)
|
|
39
|
+
|
|
40
|
+
worker.on('failed', (job, err) => {
|
|
41
|
+
console.error(`[${name}] Job ${job?.id} failed:`, err.message)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
worker.on('error', (err) => {
|
|
45
|
+
console.error(`[${name}] Worker error:`, err)
|
|
46
|
+
})
|
|
38
47
|
}
|
|
39
48
|
|
|
40
|
-
export const
|
|
49
|
+
export const EthTransactionMonitor: WorkerDescription = {
|
|
41
50
|
createWorker, name, queueName,
|
|
42
51
|
}
|