@xyo-network/chain-bridge 1.19.6 → 1.19.7
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 +339 -337
- 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/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 +17 -13
- package/src/config/getGateway.ts +6 -11
- package/src/manifest/getIterableMap.ts +34 -0
- package/src/manifest/getModuleLocator.ts +3 -5
- package/src/manifest/getNode.ts +8 -6
- package/src/manifest/getServices.ts +10 -46
- 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 +3 -1
- package/src/services/IBridgeServiceCollection.ts +2 -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"}
|
|
@@ -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.7",
|
|
4
4
|
"description": "XYO Layer One Bridge",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -60,9 +60,10 @@
|
|
|
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.7",
|
|
64
|
+
"@xyo-network/chain-protocol": "~1.19.7",
|
|
65
|
+
"@xyo-network/chain-services": "~1.19.7",
|
|
66
|
+
"@xyo-network/chain-telemetry": "~1.19.7",
|
|
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.22.30",
|
|
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,7 +95,8 @@
|
|
|
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.1
|
|
98
|
+
"@types/node": "~25.2.1",
|
|
99
|
+
"@xylabs/axios": "~5.0.65",
|
|
97
100
|
"@xylabs/mongo": "~5.0.65",
|
|
98
101
|
"@xylabs/sdk-js": "~5.0.65",
|
|
99
102
|
"@xylabs/ts-scripts-yarn3": "~7.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.7",
|
|
116
|
+
"@xyo-network/chain-services": "~1.19.7",
|
|
117
|
+
"@xyo-network/chain-telemetry": "~1.19.7",
|
|
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,9 +123,10 @@
|
|
|
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.22.30",
|
|
124
127
|
"async-mutex": "~0.5.0",
|
|
125
|
-
"
|
|
128
|
+
"axios": "~1.13.4",
|
|
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",
|
package/src/config/getGateway.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
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
|
|
@@ -16,11 +12,10 @@ let gatewayInstance: XyoGatewayRunner | undefined
|
|
|
16
12
|
export const getGateway = async (config: Config): Promise<XyoGatewayRunner> => {
|
|
17
13
|
if (isDefined(gatewayInstance)) return gatewayInstance
|
|
18
14
|
const { mnemonic, chainRpcApiUrl: endpoint } = config.bridge
|
|
19
|
-
const
|
|
20
|
-
const
|
|
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
|
}
|
|
@@ -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
|
|
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.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,
|
|
32
|
+
remoteBridgeContractAddress, remoteChainWalletPrivateKey, remoteTokenAddress, mnemonic,
|
|
40
33
|
} = config.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
|
}
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { assertEx, hexToBigInt } from '@xylabs/sdk-js'
|
|
2
2
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
isBridgeIntent, isSignedTransactionBoundWitness, type SignedHydratedTransaction,
|
|
5
|
+
} from '@xyo-network/xl1-sdk'
|
|
4
6
|
import type { Job } from 'bullmq'
|
|
5
7
|
import { Worker } from 'bullmq'
|
|
6
8
|
import { getAddress } from 'ethers'
|
|
@@ -9,20 +11,21 @@ import type { Redis } from 'ioredis'
|
|
|
9
11
|
import type { IBridgeServiceCollection } from '../../services/index.ts'
|
|
10
12
|
import type { WorkerDescription } from './WorkerDescription.ts'
|
|
11
13
|
|
|
12
|
-
type JobData =
|
|
14
|
+
type JobData = { tx: SignedHydratedTransaction }
|
|
13
15
|
|
|
14
16
|
interface ReturnType {}
|
|
15
17
|
|
|
16
18
|
const name = 'Prepare ETH Transaction'
|
|
17
19
|
const queueName = 'eth-tx-prepare'
|
|
18
20
|
|
|
19
|
-
export const createWorker = (connection: Redis) => {
|
|
20
|
-
|
|
21
|
+
export const createWorker = (connection: Redis, services?: IBridgeServiceCollection) => {
|
|
22
|
+
const bridge = assertEx(services?.bridge, () => 'bridge service not provided')
|
|
23
|
+
const stateMap = assertEx(services?.ethTxStateMap, () => 'ethTxStateMap service not provided')
|
|
24
|
+
|
|
25
|
+
const worker = new Worker(
|
|
21
26
|
queueName,
|
|
22
27
|
async (job: Job<JobData, ReturnType>) => {
|
|
23
|
-
const {
|
|
24
|
-
bridge, ethTxStateMap: stateMap, tx,
|
|
25
|
-
} = job.data
|
|
28
|
+
const { tx } = job.data
|
|
26
29
|
const hash = await PayloadBuilder.hash(tx[0])
|
|
27
30
|
await job.log(`[${hash}] preparing ETH transaction`)
|
|
28
31
|
await job.log(`[${hash}] building ETH transaction`)
|
|
@@ -30,7 +33,8 @@ export const createWorker = (connection: Redis) => {
|
|
|
30
33
|
const amount = hexToBigInt(bridgeIntent.destAmount)
|
|
31
34
|
const srcAddress = getAddress(bridgeIntent.srcAddress)
|
|
32
35
|
const destAddress = getAddress(bridgeIntent.destAddress)
|
|
33
|
-
const
|
|
36
|
+
const nonce = hexToBigInt(await PayloadBuilder.hash(tx[0]))
|
|
37
|
+
const preparedTx = await bridge.getFunction('bridgeFromRemote').populateTransaction(srcAddress, destAddress, amount, nonce)
|
|
34
38
|
await job.log(`[${hash}] built ETH transaction`)
|
|
35
39
|
await job.log(`[${hash}] storing ETH preparedTx`)
|
|
36
40
|
await stateMap.set(hash, { preparedTx })
|
|
@@ -40,8 +44,16 @@ export const createWorker = (connection: Redis) => {
|
|
|
40
44
|
},
|
|
41
45
|
{ connection },
|
|
42
46
|
)
|
|
47
|
+
|
|
48
|
+
worker.on('failed', (job, err) => {
|
|
49
|
+
console.error(`[${name}] Job ${job?.id} failed:`, err.message)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
worker.on('error', (err) => {
|
|
53
|
+
console.error(`[${name}] Worker error:`, err)
|
|
54
|
+
})
|
|
43
55
|
}
|
|
44
56
|
|
|
45
|
-
export const
|
|
57
|
+
export const EthTransactionPreparation: WorkerDescription = {
|
|
46
58
|
createWorker, name, queueName,
|
|
47
59
|
}
|
|
@@ -6,9 +6,10 @@ import { Worker } from 'bullmq'
|
|
|
6
6
|
import type { Redis } from 'ioredis'
|
|
7
7
|
|
|
8
8
|
import type { EthTxState, IBridgeServiceCollection } from '../../services/index.ts'
|
|
9
|
+
import { submitEthTransaction } from './util/index.ts'
|
|
9
10
|
import type { WorkerDescription } from './WorkerDescription.ts'
|
|
10
11
|
|
|
11
|
-
type JobData =
|
|
12
|
+
type JobData = { tx: SignedHydratedTransaction }
|
|
12
13
|
|
|
13
14
|
interface ReturnType {
|
|
14
15
|
submissionHash: Required<EthTxState>['submissionHash']
|
|
@@ -16,13 +17,16 @@ interface ReturnType {
|
|
|
16
17
|
|
|
17
18
|
const name = 'Submit ETH Transaction'
|
|
18
19
|
const queueName = 'eth-tx-submit'
|
|
19
|
-
const createWorker = (connection: Redis) => {
|
|
20
|
-
|
|
20
|
+
const createWorker = (connection: Redis, services?: IBridgeServiceCollection) => {
|
|
21
|
+
const bridge = assertEx(services?.bridge, () => 'bridge service not provided')
|
|
22
|
+
const bridgeableToken = assertEx(services?.bridgeableToken, () => 'bridgeableToken service not provided')
|
|
23
|
+
const wallet = assertEx(services?.wallet, () => 'wallet service not provided')
|
|
24
|
+
const stateMap = assertEx(services?.ethTxStateMap, () => 'ethTxStateMap service not provided')
|
|
25
|
+
|
|
26
|
+
const worker = new Worker(
|
|
21
27
|
queueName,
|
|
22
28
|
async (job: Job<JobData, ReturnType>) => {
|
|
23
|
-
const {
|
|
24
|
-
ethTxStateMap: stateMap, tx, wallet,
|
|
25
|
-
} = job.data
|
|
29
|
+
const { tx } = job.data
|
|
26
30
|
const hash = await PayloadBuilder.hash(tx[0])
|
|
27
31
|
const state = assertEx(await stateMap.get(hash), () => `[${hash}] state not found`)
|
|
28
32
|
const preparedTx = assertEx(state?.preparedTx, () => `[${hash}] preparedTx not found`)
|
|
@@ -36,8 +40,11 @@ const createWorker = (connection: Redis) => {
|
|
|
36
40
|
|
|
37
41
|
// Submit the transaction to the Ethereum network
|
|
38
42
|
await job.log(`[${hash}] Submitting ETH tx`)
|
|
39
|
-
const submissionResponse = await wallet.sendTransaction(preparedTx)
|
|
40
|
-
const submissionHash = submissionResponse.hash
|
|
43
|
+
// const submissionResponse = await wallet.sendTransaction(preparedTx)
|
|
44
|
+
// const submissionHash = submissionResponse.hash
|
|
45
|
+
|
|
46
|
+
const submissionHash = assertEx(await submitEthTransaction(tx, bridgeableToken, bridge, wallet), () => `[${hash}] submissionHash not found in receipt`)
|
|
47
|
+
|
|
41
48
|
await job.log(`[${hash}] Submitted ETH tx and received submission response hash ${submissionHash}`)
|
|
42
49
|
|
|
43
50
|
// Store the submission hash in the state
|
|
@@ -70,8 +77,16 @@ const createWorker = (connection: Redis) => {
|
|
|
70
77
|
},
|
|
71
78
|
{ connection, concurrency: 1 },
|
|
72
79
|
)
|
|
80
|
+
|
|
81
|
+
worker.on('failed', (job, err) => {
|
|
82
|
+
console.error(`[${name}] Job ${job?.id} failed:`, err.message)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
worker.on('error', (err) => {
|
|
86
|
+
console.error(`[${name}] Worker error:`, err)
|
|
87
|
+
})
|
|
73
88
|
}
|
|
74
89
|
|
|
75
|
-
export const
|
|
90
|
+
export const EthTransactionSubmission: WorkerDescription = {
|
|
76
91
|
createWorker, name, queueName,
|
|
77
92
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Redis } from 'ioredis'
|
|
2
2
|
|
|
3
|
+
import type { IBridgeServiceCollection } from '../../services/index.ts'
|
|
4
|
+
|
|
3
5
|
export interface WorkerDescription {
|
|
4
|
-
createWorker: (connection: Redis) => void
|
|
6
|
+
createWorker: (connection: Redis, services?: IBridgeServiceCollection) => void
|
|
5
7
|
name: string
|
|
6
8
|
queueName: string
|
|
7
9
|
}
|
|
@@ -7,7 +7,7 @@ import type { WorkerDescription } from './WorkerDescription.ts'
|
|
|
7
7
|
const name = 'Bridge XL1 to Ethereum'
|
|
8
8
|
const queueName = 'xl1-to-eth-bridge'
|
|
9
9
|
const createWorker = (connection: Redis) => {
|
|
10
|
-
new Worker(
|
|
10
|
+
const worker = new Worker(
|
|
11
11
|
queueName,
|
|
12
12
|
async (job: Job) => {
|
|
13
13
|
await job.log(`[${job.name}] start`)
|
|
@@ -18,8 +18,16 @@ const createWorker = (connection: Redis) => {
|
|
|
18
18
|
},
|
|
19
19
|
{ connection },
|
|
20
20
|
)
|
|
21
|
+
|
|
22
|
+
worker.on('failed', (job, err) => {
|
|
23
|
+
console.error(`[${name}] Job ${job?.id} failed:`, err.message)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
worker.on('error', (err) => {
|
|
27
|
+
console.error(`[${name}] Worker error:`, err)
|
|
28
|
+
})
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
export const
|
|
31
|
+
export const Xl1ToEthBridgeParent: WorkerDescription = {
|
|
24
32
|
createWorker, name, queueName,
|
|
25
33
|
}
|