From 2329fab3ed60836d1d1acb74086316dc673878cb Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Wed, 17 Jul 2024 22:16:57 +0200 Subject: [PATCH] API release v0.1.17 (#1259) * fix bridge latency gap * upped version number * add account type * rename --- web/packages/api/package.json | 2 +- web/packages/api/src/environment.ts | 15 ++++++++------- web/packages/api/src/status.ts | 7 ++++--- web/packages/api/src/utils.ts | 2 +- web/packages/contract-types/package.json | 4 ++-- web/packages/contracts/package.json | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/web/packages/api/package.json b/web/packages/api/package.json index 696dbfac38..760eff2c78 100644 --- a/web/packages/api/package.json +++ b/web/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/api", - "version": "0.1.16", + "version": "0.1.17", "description": "Snowbridge API client", "license": "Apache-2.0", "repository": { diff --git a/web/packages/api/src/environment.ts b/web/packages/api/src/environment.ts index f0d3f11315..1cf847e6f7 100644 --- a/web/packages/api/src/environment.ts +++ b/web/packages/api/src/environment.ts @@ -19,13 +19,14 @@ export type Config = { } } +export type AddressType = "20byte" | "32byte" | "both" export type SourceType = "substrate" | "ethereum" export type Relayer = { name: string; account: string; type: SourceType; balance?: bigint } export type ParachainInfo = { paraId: number destinationFeeDOT: bigint skipExistentialDepositCheck: boolean - has20ByteAccounts: boolean + addressType: AddressType decimals: number maxConsumers: number } @@ -77,7 +78,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 1000, destinationFeeDOT: 0n, skipExistentialDepositCheck: false, - has20ByteAccounts: false, + addressType: "32byte", decimals: 12, maxConsumers: 16, }, @@ -98,7 +99,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 2000, destinationFeeDOT: 4_000_000_000n, skipExistentialDepositCheck: false, - has20ByteAccounts: false, + addressType: "32byte", decimals: 12, maxConsumers: 16, }, @@ -206,7 +207,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 1000, destinationFeeDOT: 0n, skipExistentialDepositCheck: false, - has20ByteAccounts: false, + addressType: "32byte", decimals: 12, maxConsumers: 16, }, @@ -237,7 +238,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 3369, destinationFeeDOT: 200_000_000_000n, skipExistentialDepositCheck: true, - has20ByteAccounts: true, + addressType: "20byte", decimals: 18, maxConsumers: 16, }, @@ -360,7 +361,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 1000, destinationFeeDOT: 0n, skipExistentialDepositCheck: false, - has20ByteAccounts: false, + addressType: "32byte", decimals: 10, maxConsumers: 64, }, @@ -411,7 +412,7 @@ export const SNOWBRIDGE_ENV: { [id: string]: SnowbridgeEnvironment } = { paraId: 3369, destinationFeeDOT: 500_000_000n, skipExistentialDepositCheck: true, - has20ByteAccounts: true, + addressType: "20byte", decimals: 18, maxConsumers: 16, }, diff --git a/web/packages/api/src/status.ts b/web/packages/api/src/status.ts index eeb0f1c508..1843764f54 100644 --- a/web/packages/api/src/status.ts +++ b/web/packages/api/src/status.ts @@ -23,6 +23,7 @@ export type BridgeStatusInfo = { latestBeaconSlotOnPolkadot: number latestBeaconSlotAttested: number latestBeaconSlotFinalized: number + latestBeaconSlotHead: number blockLatency: number latencySeconds: number previousEthereumBlockOnPolkadot: number @@ -118,7 +119,7 @@ export const bridgeStatusInfo = async ( ) // Beacon status - const latestFinalizedBeaconBlock = await fetchFinalityUpdate(context.config.ethereum.beacon_url) + const [latestFinalizedBeaconBlock, latestBeaconBlock] = await Promise.all([fetchFinalityUpdate(context.config.ethereum.beacon_url), fetchBeaconSlot(context.config.ethereum.beacon_url, "head")]) const latestBeaconBlockRoot = ( await context.polkadot.api.bridgeHub.query.ethereumBeaconClient.latestFinalizedBlockRoot() ).toHex() @@ -126,8 +127,7 @@ export const bridgeStatusInfo = async ( (await fetchBeaconSlot(context.config.ethereum.beacon_url, latestBeaconBlockRoot)).data .message.slot ) - const beaconBlockLatency = - latestFinalizedBeaconBlock.attested_slot - latestBeaconBlockOnPolkadot + const beaconBlockLatency = latestBeaconBlock.data.message.slot - latestBeaconBlockOnPolkadot const beaconLatencySeconds = beaconBlockLatency * options.ethereumBlockTimeInSeconds const latestBridgeHubBlock = ( await context.polkadot.api.bridgeHub.query.system.number() @@ -177,6 +177,7 @@ export const bridgeStatusInfo = async ( latestBeaconSlotOnPolkadot: latestBeaconBlockOnPolkadot, latestBeaconSlotAttested: latestFinalizedBeaconBlock.attested_slot, latestBeaconSlotFinalized: latestFinalizedBeaconBlock.finalized_slot, + latestBeaconSlotHead: latestBeaconBlock.data.message.slot, blockLatency: beaconBlockLatency, latencySeconds: beaconLatencySeconds, previousEthereumBlockOnPolkadot: previousBeaconBlock, diff --git a/web/packages/api/src/utils.ts b/web/packages/api/src/utils.ts index b77c30af4f..758f97a856 100644 --- a/web/packages/api/src/utils.ts +++ b/web/packages/api/src/utils.ts @@ -73,7 +73,7 @@ export const beneficiaryMultiAddress = (beneficiary: string) => { export const fetchBeaconSlot = async ( beaconUrl: string, - blockId: `0x${string}` | number + blockId: `0x${string}` | number | "head" | "finalized" ): Promise<{ data: { message: { diff --git a/web/packages/contract-types/package.json b/web/packages/contract-types/package.json index 93c7f9972b..543df949bd 100644 --- a/web/packages/contract-types/package.json +++ b/web/packages/contract-types/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/contract-types", - "version": "0.1.16", + "version": "0.1.17", "description": "Snowbridge contract type bindings", "license": "Apache-2.0", "repository": { @@ -11,7 +11,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "pnpm typechain && tsc", + "build": "typechain && tsc", "typechain": "typechain --target ethers-v6 '../../../contracts/out/?(IERC20.sol|IERC20Metadata.sol|IGateway.sol|BeefyClient.sol|WETH9.sol)/!(*.abi).json' --out-dir src" }, "devDependencies": { diff --git a/web/packages/contracts/package.json b/web/packages/contracts/package.json index 077edf742c..241ea860e4 100644 --- a/web/packages/contracts/package.json +++ b/web/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/contracts", - "version": "0.1.16", + "version": "0.1.17", "description": "Snowbridge contract source and abi.", "license": "Apache-2.0", "repository": {