@xyo-network/chain-bridge 1.19.7 → 1.19.9
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/BridgeActor.d.ts +15 -0
- package/dist/node/BridgeActor.d.ts.map +1 -0
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +155 -130
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/manifest/getServices.d.ts +2 -2
- package/dist/node/manifest/getServices.d.ts.map +1 -1
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts +3 -42
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts.map +1 -1
- package/dist/node/server/app.d.ts +2 -2
- package/dist/node/server/app.d.ts.map +1 -1
- package/dist/node/server/routes/addRoutes.d.ts +2 -2
- package/dist/node/server/routes/addRoutes.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/addBridgeRoutes.d.ts +2 -2
- package/dist/node/server/routes/bridge/addBridgeRoutes.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/getRouteDefinitions.d.ts +2 -2
- package/dist/node/server/routes/bridge/routeDefinitions/getRouteDefinitions.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts +2 -2
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map +1 -1
- package/dist/node/server/server.d.ts +2 -2
- package/dist/node/server/server.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/package.json +20 -20
- package/src/BridgeActor.ts +51 -0
- 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 +1 -1
- 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/index.ts +1 -1
- package/src/manifest/getModuleLocator.ts +1 -1
- package/src/manifest/getNode.ts +1 -1
- package/src/manifest/getServices.ts +3 -5
- package/src/queue/connection.ts +1 -1
- package/src/queue/workers/util/submitXl1Transaction.ts +23 -7
- package/src/server/app.ts +3 -3
- package/src/server/routes/addRoutes.ts +3 -3
- package/src/server/routes/bridge/addBridgeRoutes.ts +3 -3
- package/src/server/routes/bridge/routeDefinitions/getRouteDefinitions.ts +3 -3
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.ts +4 -7
- package/src/server/server.ts +6 -6
- package/src/util/calculateBridgeFees.ts +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { RouteDefinition } from '@xylabs/express'
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-sdk'
|
|
2
|
+
import type { Config, XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
makeBridgeConfigRoute, makeBridgeFromRemoteStatusRoute, makeBridgeToRemoteEstimateRoute, makeBridgeToRemoteRoute, makeBridgeToRemoteStatusRoute,
|
|
6
6
|
} from './routes/index.ts'
|
|
7
7
|
|
|
8
|
-
export const getRouteDefinitions = (config: Config): RouteDefinition[] => {
|
|
8
|
+
export const getRouteDefinitions = (config: Config, gateway: XyoGatewayRunner): RouteDefinition[] => {
|
|
9
9
|
return [
|
|
10
10
|
makeBridgeConfigRoute(config),
|
|
11
|
-
makeBridgeToRemoteEstimateRoute(config),
|
|
11
|
+
makeBridgeToRemoteEstimateRoute(config, gateway),
|
|
12
12
|
makeBridgeToRemoteRoute(config),
|
|
13
13
|
makeBridgeToRemoteStatusRoute(config),
|
|
14
14
|
makeBridgeFromRemoteStatusRoute(config),
|
|
@@ -2,15 +2,13 @@ import type { RouteDefinition } from '@xylabs/express'
|
|
|
2
2
|
import { requestHandlerValidator } from '@xylabs/express'
|
|
3
3
|
import { assertEx, toAddress } from '@xylabs/sdk-js'
|
|
4
4
|
import { PayloadZodStrictOfSchema } from '@xyo-network/payload-model'
|
|
5
|
+
import type { Config, XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
5
6
|
import {
|
|
6
|
-
buildUnsignedTransaction,
|
|
7
|
-
} from '@xyo-network/xl1-sdk'
|
|
8
|
-
import {
|
|
9
|
-
BridgeIntentFieldsZod, BridgeIntentSchema, toXL1BlockNumber, TransactionBoundWitnessZod,
|
|
7
|
+
BridgeIntentFieldsZod, BridgeIntentSchema, buildUnsignedTransaction, toXL1BlockNumber, TransactionBoundWitnessZod, TransferZod,
|
|
10
8
|
} from '@xyo-network/xl1-sdk'
|
|
11
9
|
import { z } from 'zod'
|
|
12
10
|
|
|
13
|
-
import {
|
|
11
|
+
import { getXl1ChainId } from '../../../../../config/index.ts'
|
|
14
12
|
import { generateBridgeEstimate } from '../../../../../util/index.ts'
|
|
15
13
|
import { getRemoteChainIdZod } from '../pathParams/index.ts'
|
|
16
14
|
|
|
@@ -29,7 +27,7 @@ export const BridgeToRemoteEstimateResponseZod = z.tuple([
|
|
|
29
27
|
|
|
30
28
|
export type BridgeToRemoteEstimateResponse = z.infer<typeof BridgeToRemoteEstimateResponseZod>
|
|
31
29
|
|
|
32
|
-
export const makeBridgeToRemoteEstimateRoute = (config: Config): RouteDefinition => {
|
|
30
|
+
export const makeBridgeToRemoteEstimateRoute = (config: Config, gateway: XyoGatewayRunner): RouteDefinition => {
|
|
33
31
|
const params = z.object({ chainId: getRemoteChainIdZod(config) })
|
|
34
32
|
const validateRequest = requestHandlerValidator({
|
|
35
33
|
params, body: BridgeToRemoteEstimateBodyZod, response: BridgeToRemoteEstimateResponseZod,
|
|
@@ -46,7 +44,6 @@ export const makeBridgeToRemoteEstimateRoute = (config: Config): RouteDefinition
|
|
|
46
44
|
const sender = toAddress(srcAddress)
|
|
47
45
|
|
|
48
46
|
// Use viewer to get current block
|
|
49
|
-
const gateway = await getGateway(config)
|
|
50
47
|
const viewer = assertEx(gateway.connection.viewer, () => new Error('Viewer not available on gateway connection'))
|
|
51
48
|
const currentBlockNumber = await viewer.currentBlockNumber()
|
|
52
49
|
// Calculate nbf/exp
|
package/src/server/server.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { boot } from '@xyo-network/bios'
|
|
|
5
5
|
import type { BiosExternalInterface } from '@xyo-network/bios-model'
|
|
6
6
|
import type { NodeInstance } from '@xyo-network/node-model'
|
|
7
7
|
import { HDWallet } from '@xyo-network/wallet'
|
|
8
|
-
import {
|
|
8
|
+
import type { Config, XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
9
9
|
|
|
10
10
|
import { getNode, getServices } from '../manifest/index.ts'
|
|
11
11
|
import { addWorkers } from './addWorkers.ts'
|
|
@@ -18,7 +18,7 @@ const hostname = '::'
|
|
|
18
18
|
const getSeedPhrase = async (bios: BiosExternalInterface, config: Config, logger?: Logger): Promise<string> => {
|
|
19
19
|
const storedSeedPhrase = await bios.seedPhraseStore.get('os')
|
|
20
20
|
logger?.debug(`[Bridge] Stored mnemonic: ${storedSeedPhrase}`)
|
|
21
|
-
const { mnemonic } = config.api
|
|
21
|
+
const { mnemonic } = config.actors.api
|
|
22
22
|
if (isString(storedSeedPhrase) && isString(mnemonic)) {
|
|
23
23
|
logger?.warn('[Bridge] Stored mnemonic does not match supplied. Updating stored mnemonic to supplied.')
|
|
24
24
|
await bios.seedPhraseStore.set('os', mnemonic)
|
|
@@ -42,9 +42,9 @@ interface GetServerContext {
|
|
|
42
42
|
node?: NodeInstance
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const getServer = async (context: GetServerContext) => {
|
|
45
|
+
export const getServer = async (context: GetServerContext, gateway: XyoGatewayRunner) => {
|
|
46
46
|
const { logger, config } = context
|
|
47
|
-
const { port, mnemonic } = config.bridge
|
|
47
|
+
const { port, mnemonic } = config.actors.bridge
|
|
48
48
|
const bios = await boot()
|
|
49
49
|
const seedPhrase = isDefined(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger)
|
|
50
50
|
const wallet = await HDWallet.fromPhrase(seedPhrase)
|
|
@@ -52,8 +52,8 @@ export const getServer = async (context: GetServerContext) => {
|
|
|
52
52
|
wallet, logger, config,
|
|
53
53
|
}
|
|
54
54
|
const node = context.node ?? await getNode(nodeContext)
|
|
55
|
-
const app = getApp(node, config)
|
|
56
|
-
const services = await getServices({ config, logger })
|
|
55
|
+
const app = getApp(node, config, gateway)
|
|
56
|
+
const services = await getServices({ config, logger }, gateway)
|
|
57
57
|
addWorkers(config, services)
|
|
58
58
|
const server = app.listen(port, hostname, () => logger?.log(`[Bridge] Server listening at http://${hostname}:${port}`))
|
|
59
59
|
server.setTimeout(20_000)
|
|
@@ -2,7 +2,7 @@ import type { Hex } from '@xylabs/sdk-js'
|
|
|
2
2
|
import { hexToBigInt, toHex } from '@xylabs/sdk-js'
|
|
3
3
|
import type { Config } from '@xyo-network/xl1-sdk'
|
|
4
4
|
|
|
5
|
-
export type FeeStructure = Pick<Config['bridge'], 'feeFixed' | 'feeRateBasisPoints'>
|
|
5
|
+
export type FeeStructure = Pick<Config['actors']['bridge'], 'feeFixed' | 'feeRateBasisPoints'>
|
|
6
6
|
|
|
7
7
|
export interface FeeCalculationResult {
|
|
8
8
|
destAmount: Hex
|