@xyo-network/chain-bridge 1.19.17 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/config/getTestGateway.d.ts +4 -0
- package/dist/node/config/getTestGateway.d.ts.map +1 -0
- package/dist/node/config/index.d.ts +1 -1
- package/dist/node/config/index.d.ts.map +1 -1
- package/dist/node/index.mjs +767 -520
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/modules/index.d.ts +0 -1
- package/dist/node/modules/index.d.ts.map +1 -1
- package/dist/node/queue/flowProducer.d.ts +2 -1
- package/dist/node/queue/flowProducer.d.ts.map +1 -1
- package/dist/node/queue/flows/createEthToXl1BridgeJob.d.ts +10 -0
- package/dist/node/queue/flows/createEthToXl1BridgeJob.d.ts.map +1 -0
- package/dist/node/queue/flows/createXl1ToEthBridgeJob.d.ts.map +1 -1
- package/dist/node/queue/flows/index.d.ts +1 -0
- package/dist/node/queue/flows/index.d.ts.map +1 -1
- package/dist/node/queue/getXl1ToEthQueueJobs.d.ts +20 -0
- package/dist/node/queue/getXl1ToEthQueueJobs.d.ts.map +1 -0
- package/dist/node/queue/getXl1ToEthQueues.d.ts +14 -0
- package/dist/node/queue/getXl1ToEthQueues.d.ts.map +1 -0
- package/dist/node/queue/index.d.ts +4 -0
- package/dist/node/queue/index.d.ts.map +1 -1
- package/dist/node/queue/prefix.d.ts +2 -0
- package/dist/node/queue/prefix.d.ts.map +1 -0
- package/dist/node/queue/telemetry.d.ts +3 -0
- package/dist/node/queue/telemetry.d.ts.map +1 -0
- package/dist/node/queue/workers/EthToXl1BridgeParent.d.ts +8 -0
- package/dist/node/queue/workers/EthToXl1BridgeParent.d.ts.map +1 -0
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts +11 -0
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts +9 -1
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts +10 -0
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionSubmissionStorage.d.ts +13 -0
- package/dist/node/queue/workers/EthTransactionSubmissionStorage.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 +8 -0
- package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts +10 -0
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts +9 -0
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts +10 -0
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts +13 -0
- package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.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 +3 -0
- package/dist/node/queue/workers/index.d.ts.map +1 -1
- package/dist/node/queue/workers/util/index.d.ts +0 -2
- package/dist/node/queue/workers/util/index.d.ts.map +1 -1
- package/dist/node/server/addFlowProducer.d.ts.map +1 -1
- package/dist/node/server/addWorkers.d.ts.map +1 -1
- package/dist/node/server/index.d.ts +2 -0
- package/dist/node/server/index.d.ts.map +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/node/services/IBridgeServiceCollection.d.ts.map +1 -1
- package/dist/node/services/TxState.d.ts +0 -7
- package/dist/node/services/TxState.d.ts.map +1 -1
- package/dist/node/util/index.d.ts +0 -3
- package/dist/node/util/index.d.ts.map +1 -1
- package/dist/node/validation/AsyncLogger.d.ts +5 -0
- package/dist/node/validation/AsyncLogger.d.ts.map +1 -0
- package/dist/node/validation/index.d.ts +7 -0
- package/dist/node/validation/index.d.ts.map +1 -0
- package/dist/node/validation/validateBridgeEstimate.d.ts.map +1 -0
- package/dist/node/validation/validateBridgeEstimateExact.d.ts.map +1 -0
- package/dist/node/validation/validateBridgeTransaction.d.ts.map +1 -0
- package/dist/node/{queue/workers/util/validateSufficientAllowance.d.ts → validation/validateSufficientLiquiditySourceAllowance.d.ts} +3 -7
- package/dist/node/validation/validateSufficientLiquiditySourceAllowance.d.ts.map +1 -0
- package/dist/node/{queue/workers/util/validateSufficientBalance.d.ts → validation/validateSufficientLiquiditySourceBalance.d.ts} +3 -7
- package/dist/node/validation/validateSufficientLiquiditySourceBalance.d.ts.map +1 -0
- package/dist/node/validation/validateSufficientRunnerEthBalanceForGas.d.ts +14 -0
- package/dist/node/validation/validateSufficientRunnerEthBalanceForGas.d.ts.map +1 -0
- package/dist/node/validation/validateSufficientXL1SourceAddressBalance.d.ts +15 -0
- package/dist/node/validation/validateSufficientXL1SourceAddressBalance.d.ts.map +1 -0
- package/package.json +31 -35
- package/src/config/getBridgeWalletAccount.ts +1 -1
- package/src/config/getTestGateway.ts +24 -0
- package/src/config/index.ts +1 -1
- package/src/modules/index.ts +0 -1
- package/src/queue/flowProducer.ts +7 -2
- package/src/queue/flows/createEthToXl1BridgeJob.ts +71 -0
- package/src/queue/flows/createXl1ToEthBridgeJob.ts +48 -20
- package/src/queue/flows/index.ts +1 -0
- package/src/queue/getXl1ToEthQueueJobs.ts +57 -0
- package/src/queue/getXl1ToEthQueues.ts +39 -0
- package/src/queue/index.ts +4 -0
- package/src/queue/prefix.ts +1 -0
- package/src/queue/telemetry.ts +12 -0
- package/src/queue/workers/EthToXl1BridgeParent.ts +40 -0
- package/src/queue/workers/EthTransactionMonitor.ts +14 -6
- package/src/queue/workers/EthTransactionPreparation.ts +21 -9
- package/src/queue/workers/EthTransactionSubmission.ts +10 -38
- package/src/queue/workers/EthTransactionSubmissionStorage.ts +76 -0
- package/src/queue/workers/WorkerDescription.ts +2 -1
- package/src/queue/workers/Xl1ToEthBridgeParent.ts +13 -5
- package/src/queue/workers/Xl1TransactionMonitor.ts +18 -12
- package/src/queue/workers/Xl1TransactionPreparation.ts +11 -7
- package/src/queue/workers/Xl1TransactionSubmission.ts +12 -12
- package/src/queue/workers/Xl1TransactionSubmissionStorage.ts +77 -0
- package/src/queue/workers/createWorkers.ts +15 -8
- package/src/queue/workers/index.ts +3 -0
- package/src/queue/workers/util/index.ts +0 -2
- package/src/server/addFlowProducer.ts +5 -2
- package/src/server/addWorkers.ts +6 -2
- package/src/server/index.ts +3 -2
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.ts +11 -1
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.ts +27 -101
- package/src/server/server.ts +1 -0
- package/src/services/IBridgeServiceCollection.ts +1 -1
- package/src/services/TxState.ts +0 -18
- package/src/services/getServices.ts +1 -1
- package/src/util/index.ts +0 -3
- package/src/validation/AsyncLogger.ts +5 -0
- package/src/validation/index.ts +6 -0
- package/src/{util → validation}/validateBridgeEstimate.ts +1 -1
- package/src/{util → validation}/validateBridgeEstimateExact.ts +1 -1
- package/src/{util → validation}/validateBridgeTransaction.ts +1 -2
- package/src/{queue/workers/util/validateSufficientAllowance.ts → validation/validateSufficientLiquiditySourceAllowance.ts} +3 -6
- package/src/{queue/workers/util/validateSufficientBalance.ts → validation/validateSufficientLiquiditySourceBalance.ts} +3 -6
- package/src/validation/validateSufficientRunnerEthBalanceForGas.ts +57 -0
- package/src/validation/validateSufficientXL1SourceAddressBalance.ts +39 -0
- package/dist/node/config/getGateway.d.ts +0 -4
- package/dist/node/config/getGateway.d.ts.map +0 -1
- package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.d.ts +0 -60
- package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.d.ts.map +0 -1
- package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/index.d.ts +0 -2
- package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/index.d.ts.map +0 -1
- package/dist/node/queue/workers/util/validateSufficientAllowance.d.ts.map +0 -1
- package/dist/node/queue/workers/util/validateSufficientBalance.d.ts.map +0 -1
- package/dist/node/util/validateBridgeEstimate.d.ts.map +0 -1
- package/dist/node/util/validateBridgeEstimateExact.d.ts.map +0 -1
- package/dist/node/util/validateBridgeTransaction.d.ts.map +0 -1
- package/src/config/getGateway.ts +0 -23
- package/src/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.ts +0 -165
- package/src/modules/XL1TransactionCompletionMonitorSentinel/index.ts +0 -1
- /package/dist/node/{util → validation}/validateBridgeEstimate.d.ts +0 -0
- /package/dist/node/{util → validation}/validateBridgeEstimateExact.d.ts +0 -0
- /package/dist/node/{util → validation}/validateBridgeTransaction.d.ts +0 -0
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
import { z } from 'zod'
|
|
14
14
|
|
|
15
15
|
import { createXl1ToEthBridgeJob } from '../../../../../queue/index.ts'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
validateBridgeEstimateExact, validateBridgeTransaction, validateSufficientXL1SourceAddressBalance,
|
|
18
|
+
} from '../../../../../validation/index.ts'
|
|
17
19
|
import { getRemoteChainIdZod } from '../pathParams/index.ts'
|
|
18
20
|
|
|
19
21
|
export const BridgeToRemoteBodyZod = z.tuple([
|
|
@@ -38,6 +40,7 @@ export const makeBridgeToRemoteRoute = (config: BridgeConfig): RouteDefinition =
|
|
|
38
40
|
handlers: validateRequest(async (req, res) => {
|
|
39
41
|
const [signedTxBw, bridgeIntent, transfer] = req.body
|
|
40
42
|
const { flowProducer } = req.app
|
|
43
|
+
const { gateway } = req.app.services
|
|
41
44
|
|
|
42
45
|
// Validate request
|
|
43
46
|
const transactionValid = await validateBridgeTransaction(signedTxBw, bridgeIntent, transfer, config)
|
|
@@ -53,6 +56,13 @@ export const makeBridgeToRemoteRoute = (config: BridgeConfig): RouteDefinition =
|
|
|
53
56
|
return
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
// Validate sufficient balance
|
|
60
|
+
const sufficientBalance = await validateSufficientXL1SourceAddressBalance(bridgeIntent, gateway, config)
|
|
61
|
+
if (!sufficientBalance) {
|
|
62
|
+
res.status(400).send()
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
// Submit to job queue
|
|
57
67
|
const singedHydratedTransaction: SignedHydratedTransaction = [signedTxBw, [transfer, bridgeIntent]]
|
|
58
68
|
await createXl1ToEthBridgeJob(flowProducer, singedHydratedTransaction)
|
|
@@ -3,21 +3,14 @@ import { requestHandlerValidator } from '@xylabs/express'
|
|
|
3
3
|
import { asHex, isDefined } from '@xylabs/sdk-js'
|
|
4
4
|
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
5
5
|
import { PayloadBuilder, PayloadZodStrictOfSchema } from '@xyo-network/sdk-js'
|
|
6
|
-
import type {
|
|
7
|
-
BridgeDestinationObservation, BridgeSourceObservation, SignedHydratedTransaction,
|
|
8
|
-
} from '@xyo-network/xl1-sdk'
|
|
6
|
+
import type { BridgeDestinationObservation, BridgeSourceObservation } from '@xyo-network/xl1-sdk'
|
|
9
7
|
import {
|
|
10
8
|
asBridgeIntent, BridgeDestinationObservationFieldsZod, BridgeDestinationObservationSchema, BridgeIntentFieldsZod, BridgeIntentSchema,
|
|
11
9
|
BridgeSourceObservationFieldsZod, BridgeSourceObservationSchema, isBridgeIntent,
|
|
12
10
|
} from '@xyo-network/xl1-sdk'
|
|
13
|
-
import type { Job } from 'bullmq'
|
|
14
|
-
import { Queue } from 'bullmq'
|
|
15
11
|
import { z } from 'zod'
|
|
16
12
|
|
|
17
|
-
import {
|
|
18
|
-
EthTransactionMonitor, EthTransactionPreparation, EthTransactionSubmission, getConnection, Xl1ToEthBridgeParent, Xl1TransactionMonitor,
|
|
19
|
-
Xl1TransactionPreparation, Xl1TransactionSubmission,
|
|
20
|
-
} from '../../../../../queue/index.ts'
|
|
13
|
+
import { getStatusQueueJobs, getXl1ToEthQueues } from '../../../../../queue/index.ts'
|
|
21
14
|
import { getRemoteChainIdZod } from '../pathParams/index.ts'
|
|
22
15
|
|
|
23
16
|
const BridgeIntentResponseZod = PayloadZodStrictOfSchema(BridgeIntentSchema)
|
|
@@ -37,78 +30,6 @@ export const BridgeToRemoteStatusResponseZod = z.union([
|
|
|
37
30
|
])
|
|
38
31
|
export type BridgeToRemoteStatusResponse = z.infer<typeof BridgeToRemoteStatusResponseZod>
|
|
39
32
|
|
|
40
|
-
interface StatusQueues {
|
|
41
|
-
ethTransactionMonitor: Queue
|
|
42
|
-
ethTransactionPreparation: Queue
|
|
43
|
-
ethTransactionSubmission: Queue
|
|
44
|
-
xl1ToEthBridgeParent: Queue
|
|
45
|
-
xl1TransactionMonitor: Queue
|
|
46
|
-
xl1TransactionPreparation: Queue
|
|
47
|
-
xl1TransactionSubmission: Queue
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let statusQueues: StatusQueues | undefined
|
|
51
|
-
|
|
52
|
-
const getStatusQueues = (config: BridgeConfig): StatusQueues => {
|
|
53
|
-
if (statusQueues) return statusQueues
|
|
54
|
-
const connection = getConnection(config)
|
|
55
|
-
statusQueues = {
|
|
56
|
-
ethTransactionMonitor: new Queue(EthTransactionMonitor.queueName, { connection }),
|
|
57
|
-
ethTransactionPreparation: new Queue(EthTransactionPreparation.queueName, { connection }),
|
|
58
|
-
ethTransactionSubmission: new Queue(EthTransactionSubmission.queueName, { connection }),
|
|
59
|
-
xl1ToEthBridgeParent: new Queue(Xl1ToEthBridgeParent.queueName, { connection }),
|
|
60
|
-
xl1TransactionMonitor: new Queue(Xl1TransactionMonitor.queueName, { connection }),
|
|
61
|
-
xl1TransactionPreparation: new Queue(Xl1TransactionPreparation.queueName, { connection }),
|
|
62
|
-
xl1TransactionSubmission: new Queue(Xl1TransactionSubmission.queueName, { connection }),
|
|
63
|
-
}
|
|
64
|
-
return statusQueues
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface StatusQueueJobs {
|
|
68
|
-
ethTransactionMonitorJob?: Job
|
|
69
|
-
ethTransactionPreparationJob?: Job
|
|
70
|
-
ethTransactionSubmissionJob?: Job
|
|
71
|
-
xl1ToEthBridgeParentJob?: Job
|
|
72
|
-
xl1TransactionMonitorJob?: Job
|
|
73
|
-
xl1TransactionPreparationJob?: Job
|
|
74
|
-
xl1TransactionSubmissionJob?: Job
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Checks all the relevant status queues for a job with the given id and returns the jobs found in an object
|
|
79
|
-
* @param queues The status queues to check for jobs
|
|
80
|
-
* @param jobId The job id to look for in the queues, which is the same as the tx hash of the bridge transaction
|
|
81
|
-
* @returns An object containing the jobs found in the status queues corresponding to the given job id
|
|
82
|
-
*/
|
|
83
|
-
const getStatusQueueJobs = async (queues: StatusQueues, jobId: string): Promise<StatusQueueJobs> => {
|
|
84
|
-
const [
|
|
85
|
-
ethTransactionMonitorJob,
|
|
86
|
-
ethTransactionPreparationJob,
|
|
87
|
-
ethTransactionSubmissionJob,
|
|
88
|
-
xl1ToEthBridgeParentJob,
|
|
89
|
-
xl1TransactionMonitorJob,
|
|
90
|
-
xl1TransactionPreparationJob,
|
|
91
|
-
xl1TransactionSubmissionJob,
|
|
92
|
-
] = await Promise.all([
|
|
93
|
-
queues.ethTransactionMonitor.getJob(jobId),
|
|
94
|
-
queues.ethTransactionPreparation.getJob(jobId),
|
|
95
|
-
queues.ethTransactionSubmission.getJob(jobId),
|
|
96
|
-
queues.xl1ToEthBridgeParent.getJob(jobId),
|
|
97
|
-
queues.xl1TransactionMonitor.getJob(jobId),
|
|
98
|
-
queues.xl1TransactionPreparation.getJob(jobId),
|
|
99
|
-
queues.xl1TransactionSubmission.getJob(jobId),
|
|
100
|
-
])
|
|
101
|
-
return {
|
|
102
|
-
ethTransactionMonitorJob,
|
|
103
|
-
ethTransactionPreparationJob,
|
|
104
|
-
ethTransactionSubmissionJob,
|
|
105
|
-
xl1ToEthBridgeParentJob,
|
|
106
|
-
xl1TransactionMonitorJob,
|
|
107
|
-
xl1TransactionPreparationJob,
|
|
108
|
-
xl1TransactionSubmissionJob,
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
33
|
export const makeBridgeToRemoteStatusRoute = (config: BridgeConfig): RouteDefinition => {
|
|
113
34
|
const params = z.object({
|
|
114
35
|
chainId: getRemoteChainIdZod(config),
|
|
@@ -122,18 +43,18 @@ export const makeBridgeToRemoteStatusRoute = (config: BridgeConfig): RouteDefini
|
|
|
122
43
|
path: '/bridge/chains/:chainId/bridgeToRemote/status/:nonce',
|
|
123
44
|
handlers: validateRequest(async (req, res) => {
|
|
124
45
|
const jobId = req.params.nonce
|
|
125
|
-
const result: z.infer<typeof BridgeToRemoteStatusResponseZod> = [] as
|
|
126
|
-
const queues =
|
|
46
|
+
const result: z.infer<typeof BridgeToRemoteStatusResponseZod> = [] as z.infer<typeof BridgeToRemoteStatusResponseZod>
|
|
47
|
+
const queues = getXl1ToEthQueues(config)
|
|
127
48
|
|
|
128
49
|
const statusQueueJobs = await getStatusQueueJobs(queues, jobId)
|
|
129
50
|
|
|
130
|
-
// Check for the transaction hash in
|
|
131
|
-
const tx =
|
|
51
|
+
// Check for the transaction hash in the parent job
|
|
52
|
+
const tx = statusQueueJobs.xl1ToEthBridgeParentJob?.data?.tx
|
|
132
53
|
|
|
133
|
-
// If the
|
|
54
|
+
// If the job does not exist return Not Found
|
|
134
55
|
if (!tx) return res.sendStatus(404)
|
|
135
56
|
|
|
136
|
-
// If the
|
|
57
|
+
// If the tx is not the right shape for bridging return Not Found
|
|
137
58
|
const bridgeIntent = tx[1].find(isBridgeIntent)
|
|
138
59
|
if (!bridgeIntent) return res.sendStatus(404)
|
|
139
60
|
|
|
@@ -143,26 +64,31 @@ export const makeBridgeToRemoteStatusRoute = (config: BridgeConfig): RouteDefini
|
|
|
143
64
|
// Check the state of the XL1 monitor job to determine if we can include the source observation
|
|
144
65
|
const { xl1TransactionMonitorJob } = statusQueueJobs
|
|
145
66
|
const xl1MonitorState = xl1TransactionMonitorJob ? await xl1TransactionMonitorJob.getState() : undefined
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
67
|
+
if (xl1MonitorState === 'completed') {
|
|
68
|
+
const srcConfirmation = xl1TransactionMonitorJob?.returnvalue?.submissionHash
|
|
69
|
+
if (isDefined(srcConfirmation)) {
|
|
70
|
+
const schema = BridgeSourceObservationSchema
|
|
71
|
+
const bridgeSourceObservationFields = BridgeSourceObservationFieldsZod.parse(bridgeIntent)
|
|
72
|
+
const observation: BridgeSourceObservation = {
|
|
73
|
+
schema, ...bridgeSourceObservationFields, srcConfirmation,
|
|
74
|
+
}
|
|
75
|
+
result[1] = observation
|
|
152
76
|
}
|
|
153
|
-
result[1] = observation
|
|
154
77
|
}
|
|
155
78
|
|
|
156
79
|
// Check the state of the ETH monitor job to determine if we can include the destination observation
|
|
157
80
|
const { ethTransactionMonitorJob } = statusQueueJobs
|
|
158
81
|
const ethMonitorState = ethTransactionMonitorJob ? await ethTransactionMonitorJob.getState() : undefined
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
82
|
+
if (ethMonitorState === 'completed') {
|
|
83
|
+
const destConfirmation = asHex(ethTransactionMonitorJob?.returnvalue?.submissionHash)
|
|
84
|
+
if (isDefined(destConfirmation)) {
|
|
85
|
+
const schema = BridgeDestinationObservationSchema
|
|
86
|
+
const bridgeDestinationObservationFields = BridgeDestinationObservationFieldsZod.parse(bridgeIntent)
|
|
87
|
+
const observation: BridgeDestinationObservation = {
|
|
88
|
+
schema, ...bridgeDestinationObservationFields, destConfirmation,
|
|
89
|
+
}
|
|
90
|
+
result[2] = observation
|
|
91
|
+
}
|
|
166
92
|
}
|
|
167
93
|
|
|
168
94
|
res.json(result)
|
package/src/server/server.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const getServer = async (context: BridgeConfigContext, gateway: XyoGatewa
|
|
|
13
13
|
const { port } = config
|
|
14
14
|
const app = getApp(config, gateway)
|
|
15
15
|
const services = await getServices(context, gateway)
|
|
16
|
+
app.services = services
|
|
16
17
|
addWorkers(config, services)
|
|
17
18
|
const server = app.listen(port, hostname, () => logger?.log(`[Bridge] Server listening at http://${hostname}:${port}`))
|
|
18
19
|
server.setTimeout(20_000)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { AccountInstance } from '@xyo-network/
|
|
2
|
+
import type { AccountInstance } from '@xyo-network/sdk-js'
|
|
3
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'
|
package/src/services/TxState.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
1
|
export interface TxState<TTx, TTxHash extends string = string, TConfHash extends string = string> {
|
|
4
2
|
/**
|
|
5
3
|
* The confirmation hash of the transaction
|
|
@@ -14,19 +12,3 @@ export interface TxState<TTx, TTxHash extends string = string, TConfHash extends
|
|
|
14
12
|
*/
|
|
15
13
|
submissionHash?: TTxHash
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
export type TxCompletionStates = 'pendingSubmission' | 'submitted' | 'confirmed' | 'failed'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Determines the transaction state based on the TxState object
|
|
22
|
-
* @param state The transaction state
|
|
23
|
-
* @returns The state of the transaction
|
|
24
|
-
*/
|
|
25
|
-
export const getTransactionCompletionState = <T>(state: TxState<T>): TxCompletionStates => {
|
|
26
|
-
// Prepared, submitted, and confirmed
|
|
27
|
-
if (isDefined(state.preparedTx) && isDefined(state.submissionHash) && isDefined(state.confirmationHash)) return 'confirmed'
|
|
28
|
-
// Prepared and submitted
|
|
29
|
-
if (isDefined(state.preparedTx) && isDefined(state.submissionHash)) return 'submitted'
|
|
30
|
-
// Prepared
|
|
31
|
-
return 'pendingSubmission'
|
|
32
|
-
}
|
|
@@ -2,8 +2,8 @@ import type { Hash } from '@xylabs/sdk-js'
|
|
|
2
2
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
3
3
|
import type { BridgeConfig, BridgeConfigContext } from '@xyo-network/chain-orchestration'
|
|
4
4
|
import { initEvmProvider } from '@xyo-network/chain-orchestration'
|
|
5
|
+
import { HDWallet } from '@xyo-network/sdk-js'
|
|
5
6
|
import { BridgeableToken__factory, LiquidityPoolBridge__factory } from '@xyo-network/typechain'
|
|
6
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
7
7
|
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
8
8
|
import { getAddress, Wallet } from 'ethers'
|
|
9
9
|
|
package/src/util/index.ts
CHANGED
|
@@ -4,6 +4,3 @@ export * from './calculateBridgeFees.ts'
|
|
|
4
4
|
export * from './createBridgeTransfer.ts'
|
|
5
5
|
export * from './generateBridgeEstimate.ts'
|
|
6
6
|
export * from './getConfigFromEnv.ts'
|
|
7
|
-
export * from './validateBridgeEstimate.ts'
|
|
8
|
-
export * from './validateBridgeEstimateExact.ts'
|
|
9
|
-
export * from './validateBridgeTransaction.ts'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './validateBridgeEstimateExact.ts'
|
|
2
|
+
export * from './validateBridgeTransaction.ts'
|
|
3
|
+
export * from './validateSufficientLiquiditySourceAllowance.ts'
|
|
4
|
+
export * from './validateSufficientLiquiditySourceBalance.ts'
|
|
5
|
+
export * from './validateSufficientRunnerEthBalanceForGas.ts'
|
|
6
|
+
export * from './validateSufficientXL1SourceAddressBalance.ts'
|
|
@@ -3,7 +3,7 @@ import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
|
3
3
|
import type { BridgeIntent, Transfer } from '@xyo-network/xl1-sdk'
|
|
4
4
|
|
|
5
5
|
import { getBridgeSettings } from '../config/index.ts'
|
|
6
|
-
import { calculateBridgeFees } from '
|
|
6
|
+
import { calculateBridgeFees } from '../util/index.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Validates a bridge estimate by checking the intent and transfer against the provided configuration. This method
|
|
@@ -3,7 +3,7 @@ import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
|
3
3
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
4
4
|
import type { BridgeIntent, Transfer } from '@xyo-network/xl1-sdk'
|
|
5
5
|
|
|
6
|
-
import { generateBridgeEstimate } from '
|
|
6
|
+
import { generateBridgeEstimate } from '../util/index.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Validates a bridge estimate by checking the intent and transfer against the provided configuration. This method
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
6
6
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
7
7
|
import type {
|
|
8
|
-
BridgeIntent,
|
|
9
|
-
TransactionBoundWitness, Transfer,
|
|
8
|
+
BridgeIntent, TransactionBoundWitness, Transfer,
|
|
10
9
|
} from '@xyo-network/xl1-sdk'
|
|
11
10
|
|
|
12
11
|
import { getXl1ChainId } from '../config/index.ts'
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
1
|
import { assertEx, hexToBigInt } from '@xylabs/sdk-js'
|
|
3
2
|
import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain'
|
|
4
3
|
import { isBridgeIntent, type SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
log: (message: string) => Promisable<unknown>
|
|
8
|
-
}
|
|
5
|
+
import type { AsyncLogger } from './AsyncLogger.ts'
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Checks if the liquidity source has sufficient allowance for the bridge to execute the transaction. This doesn't
|
|
@@ -17,11 +14,11 @@ interface IAsyncLogger {
|
|
|
17
14
|
* @param logger Optional logger for asynchronous logging
|
|
18
15
|
* @returns True if the liquidity source allowance is sufficient to execute the bridge
|
|
19
16
|
*/
|
|
20
|
-
export const
|
|
17
|
+
export const validateSufficientLiquiditySourceAllowance = async (
|
|
21
18
|
tx: SignedHydratedTransaction,
|
|
22
19
|
bridgeableToken: BridgeableToken,
|
|
23
20
|
bridge: LiquidityPoolBridge,
|
|
24
|
-
logger?:
|
|
21
|
+
logger?: AsyncLogger,
|
|
25
22
|
) => {
|
|
26
23
|
// Get the amount being bridged from the bridge intent
|
|
27
24
|
const bridgeIntent = assertEx(tx[1].find(isBridgeIntent), () => 'No bridge intent found')
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
1
|
import { assertEx, hexToBigInt } from '@xylabs/sdk-js'
|
|
3
2
|
import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain'
|
|
4
3
|
import { isBridgeIntent, type SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
log: (message: string) => Promisable<unknown>
|
|
8
|
-
}
|
|
5
|
+
import type { AsyncLogger } from './AsyncLogger.ts'
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Checks if the liquidity source has sufficient balance for the bridge to execute the transaction. This doesn't
|
|
@@ -17,11 +14,11 @@ interface IAsyncLogger {
|
|
|
17
14
|
* @param logger Optional logger for asynchronous logging
|
|
18
15
|
* @returns True if the liquidity source balance is sufficient to execute the bridge
|
|
19
16
|
*/
|
|
20
|
-
export const
|
|
17
|
+
export const validateSufficientLiquiditySourceBalance = async (
|
|
21
18
|
tx: SignedHydratedTransaction,
|
|
22
19
|
bridgeableToken: BridgeableToken,
|
|
23
20
|
bridge: LiquidityPoolBridge,
|
|
24
|
-
logger?:
|
|
21
|
+
logger?: AsyncLogger,
|
|
25
22
|
) => {
|
|
26
23
|
// Get the amount being bridged from the bridge intent
|
|
27
24
|
const bridgeIntent = assertEx(tx[1].find(isBridgeIntent), () => 'No bridge intent found')
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
+
import type { ContractTransaction, Wallet } from 'ethers'
|
|
3
|
+
|
|
4
|
+
import type { AsyncLogger } from './AsyncLogger.ts'
|
|
5
|
+
|
|
6
|
+
const DEFAULT_GAS_BUFFER_BPS = 2000n // 20%
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates that the wallet (the account that will submit the tx) has enough ETH
|
|
10
|
+
* to cover the estimated gas cost (plus a buffer) for the transaction.
|
|
11
|
+
* @param preparedTx The transaction that is being prepared for submission.
|
|
12
|
+
* This should be a fully populated transaction (to/from/data/value) except for gas fields.
|
|
13
|
+
* @param wallet The wallet that will be used to submit the transaction.
|
|
14
|
+
* @param logger Optional logger for asynchronous logging.
|
|
15
|
+
* @param bufferBps The buffer to apply to the estimated gas cost, in basis points (1/100th of a percent).
|
|
16
|
+
* @returns A boolean indicating whether the wallet has sufficient ETH to cover the estimated gas cost with the buffer applied.
|
|
17
|
+
*/
|
|
18
|
+
export const validateSufficientRunnerEthBalanceForGas = async (
|
|
19
|
+
preparedTx: ContractTransaction,
|
|
20
|
+
wallet: Wallet,
|
|
21
|
+
logger?: AsyncLogger,
|
|
22
|
+
bufferBps: bigint = DEFAULT_GAS_BUFFER_BPS,
|
|
23
|
+
) => {
|
|
24
|
+
const provider = assertEx(wallet.provider, () => 'Wallet provider is not defined')
|
|
25
|
+
|
|
26
|
+
// Fee data (EIP-1559 preferred, gasPrice fallback)
|
|
27
|
+
const feeData = await provider.getFeeData()
|
|
28
|
+
const perGas = feeData.maxFeePerGas ?? feeData.gasPrice
|
|
29
|
+
if (perGas == null) {
|
|
30
|
+
await logger?.log('[gas] unable to resolve gas price / maxFeePerGas from provider')
|
|
31
|
+
return true // don’t hard-fail; provider may not support fee data
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Estimate gas
|
|
35
|
+
const transactionRequest = {
|
|
36
|
+
...preparedTx,
|
|
37
|
+
from: await wallet.getAddress(),
|
|
38
|
+
}
|
|
39
|
+
const estGas = await provider.estimateGas(transactionRequest)
|
|
40
|
+
|
|
41
|
+
// Include any value sent with the tx
|
|
42
|
+
const txValue = preparedTx?.value ?? 0n
|
|
43
|
+
|
|
44
|
+
// Required = (gas * perGas + value) * (1 + buffer)
|
|
45
|
+
const baseRequired = estGas * perGas + txValue
|
|
46
|
+
const required = (baseRequired * (10_000n + bufferBps)) / 10_000n
|
|
47
|
+
|
|
48
|
+
const balance = await provider.getBalance(await wallet.getAddress())
|
|
49
|
+
|
|
50
|
+
await logger?.log(
|
|
51
|
+
`[gas] runner=${await wallet.getAddress()} balance=${balance.toString()} `
|
|
52
|
+
+ `estGas=${estGas.toString()} perGas=${perGas.toString()} value=${txValue.toString()} `
|
|
53
|
+
+ `requiredWithBuffer=${required.toString()} bufferBps=${bufferBps.toString()}`,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
return balance >= required
|
|
57
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asAddress, assertEx, hexToBigInt,
|
|
3
|
+
} from '@xylabs/sdk-js'
|
|
4
|
+
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
5
|
+
import type { BridgeIntent, XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
6
|
+
|
|
7
|
+
import { generateBridgeEstimate } from '../util/index.ts'
|
|
8
|
+
import type { AsyncLogger } from './AsyncLogger.ts'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the liquidity source has sufficient balance for the bridge to execute the transaction. This doesn't
|
|
12
|
+
* ensure that (due to race conditions) the transaction will succeed, but is a quick check to avoid
|
|
13
|
+
* submitting transactions that are likely to fail.
|
|
14
|
+
* @param bridgeIntent The bridge intent containing the details of the bridge transaction, including the source address and amount being bridged
|
|
15
|
+
* @param gateway The XyoGatewayRunner to check the balance of the source address on XL1
|
|
16
|
+
* @param config The bridge configuration, used to generate a bridge estimate for the transaction
|
|
17
|
+
* @param logger Optional logger for asynchronous logging
|
|
18
|
+
* @returns True if the liquidity source balance is sufficient to execute the bridge
|
|
19
|
+
*/
|
|
20
|
+
export const validateSufficientXL1SourceAddressBalance = async (
|
|
21
|
+
bridgeIntent: BridgeIntent,
|
|
22
|
+
gateway: XyoGatewayRunner,
|
|
23
|
+
config: BridgeConfig,
|
|
24
|
+
logger?: AsyncLogger,
|
|
25
|
+
) => {
|
|
26
|
+
// Get the amount being bridged from the bridge intent
|
|
27
|
+
const viewer = assertEx(gateway.connection.viewer, () => 'Gateway connection does not have a viewer')
|
|
28
|
+
const {
|
|
29
|
+
srcAddress, srcAmount, destAddress,
|
|
30
|
+
} = bridgeIntent
|
|
31
|
+
const srcAddressBranded = asAddress(srcAddress, () => `Invalid source address in bridge intent: ${srcAddress}`)
|
|
32
|
+
const [_, calculatedTransfer] = await generateBridgeEstimate(srcAddress, srcAmount, destAddress, config)
|
|
33
|
+
const totalAmount = Object.values(calculatedTransfer.transfers).reduce((acc, transfer) => acc + hexToBigInt(transfer), 0n)
|
|
34
|
+
|
|
35
|
+
// Check the srcAddress balance on XL1 for the bridge
|
|
36
|
+
const accountBalance = await viewer.account.balance.accountBalance(srcAddressBranded)
|
|
37
|
+
await logger?.log(`Account balance for ${srcAddressBranded}: ${accountBalance.toString()}`)
|
|
38
|
+
return accountBalance >= totalAmount
|
|
39
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGateway.d.ts","sourceRoot":"","sources":["../../../src/config/getGateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EACsB,gBAAgB,EACjD,MAAM,sBAAsB,CAAA;AAO7B,eAAO,MAAM,UAAU,GAAU,QAAQ,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAU/E,CAAA"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js';
|
|
2
|
-
import type { AnyConfigSchema, Payload } from '@xyo-network/sdk-js';
|
|
3
|
-
import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
|
|
4
|
-
import type { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelParams } from '@xyo-network/sentinel-model';
|
|
5
|
-
import type { IterableMap, MapType, SignedHydratedTransaction, XyoViewer } from '@xyo-network/xl1-sdk';
|
|
6
|
-
export declare const XL1TransactionCompletionMonitorSentinelConfigSchema: "network.xyo.sentinel.chain.transaction.completion.monitor.config" & {
|
|
7
|
-
readonly __schema: true;
|
|
8
|
-
};
|
|
9
|
-
export type XL1TransactionCompletionMonitorSentinelConfigSchema = typeof XL1TransactionCompletionMonitorSentinelConfigSchema;
|
|
10
|
-
/**
|
|
11
|
-
* The configuration for the sentinel
|
|
12
|
-
*/
|
|
13
|
-
export type XL1TransactionCompletionMonitorSentinelConfig = SentinelConfig<{
|
|
14
|
-
/**
|
|
15
|
-
* The interval in milliseconds between checking for jobs to fulfill
|
|
16
|
-
*/
|
|
17
|
-
jobCheckInterval: number;
|
|
18
|
-
/**
|
|
19
|
-
* The schema for the sentinel config
|
|
20
|
-
*/
|
|
21
|
-
schema: XL1TransactionCompletionMonitorSentinelConfigSchema;
|
|
22
|
-
}>;
|
|
23
|
-
interface XL1TransactionCompletionMonitorSentinelParamFields {
|
|
24
|
-
/**
|
|
25
|
-
* The map of completed transactions to monitor for completion
|
|
26
|
-
*/
|
|
27
|
-
completedTransactions: MapType<Hash, SignedHydratedTransaction>;
|
|
28
|
-
/**
|
|
29
|
-
* The map of pending transactions to monitor for completion
|
|
30
|
-
*/
|
|
31
|
-
pendingTransactions: IterableMap<Hash, SignedHydratedTransaction>;
|
|
32
|
-
/**
|
|
33
|
-
* The viewer instance to use for viewing transactions
|
|
34
|
-
*/
|
|
35
|
-
viewer: XyoViewer;
|
|
36
|
-
}
|
|
37
|
-
export type XL1TransactionCompletionMonitorSentinelParams<TConfig extends AnyConfigSchema<XL1TransactionCompletionMonitorSentinelConfig> = AnyConfigSchema<XL1TransactionCompletionMonitorSentinelConfig>> = SentinelParams<TConfig> & XL1TransactionCompletionMonitorSentinelParamFields;
|
|
38
|
-
export declare class XL1TransactionCompletionMonitorSentinel<TParams extends XL1TransactionCompletionMonitorSentinelParams = XL1TransactionCompletionMonitorSentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
39
|
-
static readonly configSchemas: ("network.xyo.sentinel.chain.transaction.completion.monitor.config" & {
|
|
40
|
-
readonly __schema: true;
|
|
41
|
-
})[];
|
|
42
|
-
static readonly defaultConfigSchema: "network.xyo.sentinel.chain.transaction.completion.monitor.config" & {
|
|
43
|
-
readonly __schema: true;
|
|
44
|
-
};
|
|
45
|
-
private _attemptsCounter;
|
|
46
|
-
private _checkCounter;
|
|
47
|
-
private _errorCounter;
|
|
48
|
-
private _reportMutex;
|
|
49
|
-
private _successCounter;
|
|
50
|
-
protected get completedTransactions(): MapType<Hash, SignedHydratedTransaction>;
|
|
51
|
-
protected get jobCheckInterval(): number;
|
|
52
|
-
protected get pendingTransactions(): IterableMap<Hash, SignedHydratedTransaction>;
|
|
53
|
-
protected get viewer(): XyoViewer;
|
|
54
|
-
createHandler(): Promise<void>;
|
|
55
|
-
reportHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
56
|
-
private processAllTransactions;
|
|
57
|
-
private processTransaction;
|
|
58
|
-
}
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=XL1TransactionCompletionMonitorSentinel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XL1TransactionCompletionMonitorSentinel.d.ts","sourceRoot":"","sources":["../../../../src/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,KAAK,EACV,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,cAAc,EAC1E,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EACV,WAAW,EAAE,OAAO,EAAE,yBAAyB,EAC/C,SAAS,EACV,MAAM,sBAAsB,CAAA;AAM7B,eAAO,MAAM,mDAAmD;;CAAqF,CAAA;AACrJ,MAAM,MAAM,mDAAmD,GAAG,OAAO,mDAAmD,CAAA;AAE5H;;GAEG;AACH,MAAM,MAAM,6CAA6C,GAAG,cAAc,CAAC;IACzE;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,MAAM,EAAE,mDAAmD,CAAA;CAC5D,CAAC,CAAA;AAEF,UAAU,kDAAkD;IAC1D;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAA;IAE/D;;OAEG;IACH,mBAAmB,EAAE,WAAW,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAA;IAEjE;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;CAClB;AAED,MAAM,MAAM,6CAA6C,CACvD,OAAO,SAAS,eAAe,CAAC,6CAA6C,CAAC,GAAG,eAAe,CAAC,6CAA6C,CAAC,IAC7I,cAAc,CAAC,OAAO,CAAC,GAAG,kDAAkD,CAAA;AAIhF,qBAAa,uCAAuC,CAClD,OAAO,SAAS,6CAA6C,GAAG,6CAA6C,EAC7G,UAAU,SAAS,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC1H,SAAQ,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7C,gBAAyB,aAAa;;SAAwD;IAC9F,gBAAyB,mBAAmB;;MAAsD;IAClG,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,eAAe,CAAiC;IAExD,SAAS,KAAK,qBAAqB,IAAI,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAE9E;IAED,SAAS,KAAK,gBAAgB,IAAI,MAAM,CAEvC;IAED,SAAS,KAAK,mBAAmB,IAAI,WAAW,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAEhF;IAED,SAAS,KAAK,MAAM,IAAI,SAAS,CAEhC;IAEc,aAAa;IASb,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YA0BxD,sBAAsB;YAUtB,kBAAkB;CA8BjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/XL1TransactionCompletionMonitorSentinel/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateSufficientAllowance.d.ts","sourceRoot":"","sources":["../../../../../src/queue/workers/util/validateSufficientAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAkB,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAErF,UAAU,YAAY;IACpB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,CAAC,CAAA;CAC9C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,IAAI,yBAAyB,EAC7B,iBAAiB,eAAe,EAChC,QAAQ,mBAAmB,EAC3B,SAAS,YAAY,qBActB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateSufficientBalance.d.ts","sourceRoot":"","sources":["../../../../../src/queue/workers/util/validateSufficientBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAkB,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAErF,UAAU,YAAY;IACpB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,CAAC,CAAA;CAC9C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,IAAI,yBAAyB,EAC7B,iBAAiB,eAAe,EAChC,QAAQ,mBAAmB,EAC3B,SAAS,YAAY,qBAatB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../src/util/validateBridgeEstimate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKlE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAuCjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateBridgeEstimateExact.d.ts","sourceRoot":"","sources":["../../../src/util/validateBridgeEstimateExact.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIlE;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAcjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateBridgeTransaction.d.ts","sourceRoot":"","sources":["../../../src/util/validateBridgeTransaction.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EAAE,QAAQ,EAClC,MAAM,sBAAsB,CAAA;AAI7B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GACpC,YAAY,uBAAuB,EACnC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAgBjB,CAAA"}
|
package/src/config/getGateway.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
3
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
4
|
-
import type {
|
|
5
|
-
RpcSchemaMap, TransportFactory, XyoGatewayRunner,
|
|
6
|
-
} from '@xyo-network/xl1-sdk'
|
|
7
|
-
import {
|
|
8
|
-
ADDRESS_INDEX, buildJsonRpcProviderLocator, generateXyoBaseWalletFromPhrase, HttpRpcTransport, XyoGatewayRunnerMoniker,
|
|
9
|
-
} from '@xyo-network/xl1-sdk'
|
|
10
|
-
|
|
11
|
-
let gatewayInstance: XyoGatewayRunner | undefined
|
|
12
|
-
|
|
13
|
-
export const getGateway = async (config: BridgeConfig): Promise<XyoGatewayRunner> => {
|
|
14
|
-
if (isDefined(gatewayInstance)) return gatewayInstance
|
|
15
|
-
const { mnemonic } = config
|
|
16
|
-
const endpoint = assertEx(config.remote?.rpc?.url ?? config.remote?.rpc?.url, () => 'RPC URL is required for gateway')
|
|
17
|
-
const walletPhrase = isDefined(mnemonic) ? mnemonic : HDWallet.generateMnemonic()
|
|
18
|
-
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
|
|
19
|
-
const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO)
|
|
20
|
-
const transportFactory: TransportFactory = (schemas: RpcSchemaMap) => new HttpRpcTransport(endpoint, schemas)
|
|
21
|
-
const locator = await buildJsonRpcProviderLocator({ transportFactory, signerAccount })
|
|
22
|
-
return await locator.getInstance<XyoGatewayRunner>(XyoGatewayRunnerMoniker)
|
|
23
|
-
}
|