Skip to content

Commit

Permalink
API release v0.1.17 (#1259)
Browse files Browse the repository at this point in the history
* fix bridge latency gap

* upped version number

* add account type

* rename
  • Loading branch information
alistair-singh authored Jul 17, 2024
1 parent a6d24b8 commit 2329fab
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web/packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snowbridge/api",
"version": "0.1.16",
"version": "0.1.17",
"description": "Snowbridge API client",
"license": "Apache-2.0",
"repository": {
Expand Down
15 changes: 8 additions & 7 deletions web/packages/api/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
7 changes: 4 additions & 3 deletions web/packages/api/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type BridgeStatusInfo = {
latestBeaconSlotOnPolkadot: number
latestBeaconSlotAttested: number
latestBeaconSlotFinalized: number
latestBeaconSlotHead: number
blockLatency: number
latencySeconds: number
previousEthereumBlockOnPolkadot: number
Expand Down Expand Up @@ -118,16 +119,15 @@ 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()
const latestBeaconBlockOnPolkadot = Number(
(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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion web/packages/api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions web/packages/contract-types/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion web/packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 2329fab

Please sign in to comment.