Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@avalabs/avalanche-module": "1.11.0",
"@avalabs/avalanchejs": "5.1.0-alpha.2",
"@avalabs/bitcoin-module": "1.11.0",
"@avalabs/bridge-unified": "4.0.3",
"@avalabs/bridge-unified": "0.0.0-feat-lombard-sdk-integration-20251105203545",
"@avalabs/core-bridge-sdk": "3.1.0-alpha.63",
"@avalabs/core-chains-sdk": "3.1.0-alpha.63",
"@avalabs/core-coingecko-sdk": "3.1.0-alpha.63",
Expand Down Expand Up @@ -57,6 +57,7 @@
"@keystonehq/hw-app-eth": "0.4.4",
"@keystonehq/hw-transport-webusb": "0.5.1",
"@keystonehq/ur-decoder": "0.9.2",
"@layerzerolabs/lz-v2-utilities": "3.0.17",
"@metamask/eth-sig-util": "4.0.1",
"@metamask/rpc-errors": "6.3.0",
"@noble/curves": "1.6.0",
Expand Down
10 changes: 10 additions & 0 deletions apps/legacy/src/pages/Bridge/BridgeTransactionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const BridgeTransactionStatus = () => {
} = useAccountsContext();
const { getErrorMessage } = useUnifiedBridgeContext();
const bridgeTransactions = usePendingBridgeTransactions();
console.log({ bridgeTransactions });
const { removeBridgeTransaction } = useBridgeContext();
const [fromCardOpen, setFromCardOpen] = useState<boolean>(false);
const [toCardOpen, setToCardOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -148,6 +149,15 @@ const BridgeTransactionStatus = () => {
targetRequiredConfirmations,
} = useBridgeTransferStatus(bridgeTransaction);

console.log({
bridgeTransaction,
isComplete,
sourceCurrentConfirmations,
sourceRequiredConfirmations,
targetCurrentConfirmations,
targetRequiredConfirmations,
});

const errorCode = isUnifiedBridgeTransfer(bridgeTransaction)
? bridgeTransaction.errorCode
: undefined;
Expand Down
9 changes: 6 additions & 3 deletions packages/common/src/utils/getEnabledBridgeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { BridgeType } from '@avalabs/bridge-unified';
import { FeatureFlags, FeatureGates } from '@core/types';

export const getEnabledBridgeTypes = (featureFlags: Partial<FeatureFlags>) => {
const enabled: BridgeType[] = [];
const enabled: BridgeType[] = [
BridgeType.LOMBARD_BTC_TO_BTCB,
BridgeType.LOMBARD_BTCB_TO_BTC,
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those will need to be toggled on/off based on new feature flags:

  • unified-bridge-lombard-btc-to-ava
  • unified-bridge-lombard-ava-to-btc

Feature flags can be added to the FeatureGates enum here:

export enum FeatureGates {

UNIFIED_BRIDGE_LOMBARD_BTC_TO_AVA = 'unified-bridge-lombard-btc-to-ava',
UNIFIED_BRIDGE_LOMBARD_AVA_TO_BTC = 'unified-bridge-lombard-ava-to-btc',
if (featureFlags[FeatureGates.UNIFIED_BRIDGE_LOMBARD_BTC_TO_AVA]) {
  enabled.push(BridgeType.LOMBARD_BTC_TO_BTCB);
} else if (featureFlags[FeatureGates.UNIFIED_BRIDGE_AB_BTC_TO_AVA]) {
  // Make sure to not enable both at the same time
  enabled.push(BridgeType.AVALANCHE_BTC_AVA);
}

if (featureFlags[FeatureGates.UNIFIED_BRIDGE_LOMBARD_AVA_TO_BTC]) {
  enabled.push(BridgeType.LOMBARD_BTCB_TO_BTC);
} else if (featureFlags[FeatureGates.UNIFIED_BRIDGE_AB_AVA_TO_BTC]) {
  // Make sure to not enable both at the same time
  enabled.push(BridgeType.AVALANCHE_AVA_BTC);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New feature flags are already created. They're enabled for dev environments and disabled for prod.


if (featureFlags[FeatureGates.UNIFIED_BRIDGE_CCTP]) {
enabled.push(BridgeType.CCTP);
Expand All @@ -14,10 +17,10 @@ export const getEnabledBridgeTypes = (featureFlags: Partial<FeatureFlags>) => {
enabled.push(BridgeType.AVALANCHE_EVM);
}
if (featureFlags[FeatureGates.UNIFIED_BRIDGE_AB_BTC_TO_AVA]) {
enabled.push(BridgeType.AVALANCHE_BTC_AVA);
// enabled.push(BridgeType.AVALANCHE_BTC_AVA);
}
if (featureFlags[FeatureGates.UNIFIED_BRIDGE_AB_AVA_TO_BTC]) {
enabled.push(BridgeType.AVALANCHE_AVA_BTC);
// enabled.push(BridgeType.AVALANCHE_AVA_BTC);
}

return enabled;
Expand Down
4 changes: 2 additions & 2 deletions packages/service-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@avalabs/avalanche-module": "1.11.0",
"@avalabs/avalanchejs": "5.1.0-alpha.2",
"@avalabs/bitcoin-module": "1.11.0",
"@avalabs/bridge-unified": "4.0.3",
"@avalabs/bridge-unified": "0.0.0-feat-lombard-sdk-integration-20251105203545",
"@avalabs/core-bridge-sdk": "3.1.0-alpha.63",
"@avalabs/core-chains-sdk": "3.1.0-alpha.63",
"@avalabs/core-coingecko-sdk": "3.1.0-alpha.63",
Expand Down Expand Up @@ -67,7 +67,7 @@
"argon2-browser": "1.18.0",
"bip32": "2.0.6",
"bip39": "3.0.4",
"bitcoinjs-lib": "5.2.0",
"bitcoinjs-lib": "6.1.5",
"bn.js": "5.2.1",
"buffer": "6.0.3",
"date-fns": "2.28.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/service-worker/rsbuild.worker.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default defineConfig(() => {
// Joi by default goes to browser-specific version which does not include the list of TLDS (which we need for email validation)
joi: require.resolve('joi/lib/index.js'),
},
dedupe: ['bn.js', 'bitcoinjs-lib', 'ledger-bitcoin'],
dedupe: ['bn.js', 'ledger-bitcoin'],
fallback: {
path: false,
fs: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export class UnifiedBridgeService implements OnStorageReady {
async sign() {
return '0x' as const;
},
async signMessage() {
return '0x' as const;
},
};

switch (type) {
Expand All @@ -153,6 +156,15 @@ export class UnifiedBridgeService implements OnStorageReady {
signer: dummySigner,
bitcoinFunctions: bitcoinProvider,
};

case BridgeType.LOMBARD_BTC_TO_BTCB:
case BridgeType.LOMBARD_BTCB_TO_BTC:
return {
type,
evmSigner: dummySigner,
btcSigner: dummySigner,
bitcoinFunctions: bitcoinProvider,
};
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/service-worker/src/services/wallet/WalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ export class WalletService implements OnUnlock {
return { signedTx: signingResult.toHex() };
}

if ('toHex' in signingResult && typeof signingResult.toHex === 'function') {
return { signedTx: signingResult.toHex() as string };
}

return signingResult;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"main": "src/index.ts",
"dependencies": {
"@avalabs/avalanchejs": "5.1.0-alpha.2",
"@avalabs/bridge-unified": "4.0.3",
"@avalabs/bridge-unified": "0.0.0-feat-lombard-sdk-integration-20251105203545",
"@avalabs/core-bridge-sdk": "3.1.0-alpha.63",
"@avalabs/core-chains-sdk": "3.1.0-alpha.63",
"@avalabs/core-coingecko-sdk": "3.1.0-alpha.63",
Expand Down
69 changes: 67 additions & 2 deletions packages/ui/src/contexts/UnifiedBridgeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
BtcSigner,
Chain,
Environment,
EvmSigner,
EvmSignerWithMessage,
GasSettings,
TokenType,
ErrorCode as UnifiedBridgeErrorCode,
Expand Down Expand Up @@ -57,6 +57,7 @@ import { useAccountsContext } from './AccountsProvider';
import { useConnectionContext } from './ConnectionProvider';
import { useFeatureFlagContext } from './FeatureFlagsProvider';
import { useNetworkContext } from './NetworkProvider';
import { hex, utf8 } from '@scure/base';

export interface UnifiedBridgeContext {
estimateTransferGas(
Expand Down Expand Up @@ -166,8 +167,56 @@ export function UnifiedBridgeProvider({
const [activeBridgeTypes, setActiveBridgeTypes] =
useState<BridgeServicesMap>();

const evmSigner: EvmSigner = useMemo(
const evmSigner: EvmSignerWithMessage = useMemo(
() => ({
signMessage: async (
data: { message: string; address: `0x${string}`; chainId: number },
_,
{ currentSignature, requiredSignatures },
) => {
const { message, address, chainId } = data;

assert(message, UnifiedBridgeError.InvalidTxPayload);
assert(address, UnifiedBridgeError.InvalidTxPayload);

try {
const result = await request(
{
method: RpcMethod.PERSONAL_SIGN,
params: [`0x${hex.encode(utf8.decode(message))}`, address],
},
{
scope: `eip155:${chainId}`,
context: {
customApprovalScreenTitle: t('Confirm Bridge'),
alert:
requiredSignatures > currentSignature
? {
type: 'info',
title: t(
'This operation requires {{total}} approvals.',
{
total: requiredSignatures,
},
),
notice: t(
'You will be prompted {{remaining}} more time(s).',
{
remaining: requiredSignatures - currentSignature,
},
),
}
: undefined,
},
},
);

return result as `0x${string}`;
} catch (err) {
console.error(err);
throw err;
}
},
sign: async (
{ from, data, to, value },
_,
Expand Down Expand Up @@ -334,6 +383,22 @@ export function UnifiedBridgeProvider({
signer: btcSigner,
bitcoinFunctions,
};

case BridgeType.LOMBARD_BTC_TO_BTCB:
return {
type,
evmSigner,
btcSigner,
bitcoinFunctions,
};

case BridgeType.LOMBARD_BTCB_TO_BTC:
return {
type,
evmSigner,
btcSigner,
bitcoinFunctions,
};
}
},
[evmSigner, btcSigner],
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/hooks/usePendingBridgeTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const usePendingBridgeTransactions = () => {
const {
state: { pendingTransfers: unifiedBridgeTransfers },
} = useUnifiedBridgeContext();

const bridgeTransactions = useMemo(() => {
return [
...Object.values(legacyBridgeTransfers),
Expand Down
Loading