mirror of
https://github.com/Brotocol-xyz/bro-sdk.git
synced 2026-01-12 06:44:18 +08:00
refactor: rebrand to Brotocol
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# XLink-SDK Development Guide
|
# SDK Development Guide
|
||||||
|
|
||||||
## Build/Test Commands
|
## Build/Test Commands
|
||||||
- Install dependencies: `pnpm install`
|
- Install dependencies: `pnpm install`
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -1,10 +1,10 @@
|
|||||||
# XLinkSDK
|
# BroSDK
|
||||||
|
|
||||||
🐙 **XLINK isn't just a bridge—it's the liquidity layer for Bitcoin and the essential connector for Bitcoin DeFi** 🐙
|
🐙 **Brotocol isn't just a bridge—it's the liquidity layer for Bitcoin and the essential connector for Bitcoin DeFi** 🐙
|
||||||
|
|
||||||
XLinkSDK enables seamless asset transfers between Bitcoin, Stacks, and EVM-compatible blockchains. It supports cross-chain swaps, Runes & BRC20 metaprotocols, and DEX aggregator integrations.
|
BroSDK enables seamless asset transfers between Bitcoin, Stacks, and EVM-compatible blockchains. It supports cross-chain swaps, Runes & BRC20 metaprotocols, and DEX aggregator integrations.
|
||||||
|
|
||||||
The SDK allows users to interact with XLINK smart contracts from backend environments, browsers, and mobile apps. It securely handles cross-chain transfers, fee estimation, route planning, and transaction size calculations by using XLINK's on-chain and off-chain infrastructure.
|
The SDK allows users to interact with Brotocol smart contracts from backend environments, browsers, and mobile apps. It securely handles cross-chain transfers, fee estimation, route planning, and transaction size calculations by using Brotocol's on-chain and off-chain infrastructure.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -16,16 +16,16 @@ The SDK allows users to interact with XLINK smart contracts from backend environ
|
|||||||
### Install
|
### Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm install @xlink-network/xlink-sdk
|
pnpm install @brotocol-xyz/bro-sdk
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The [`XLinkSDK`](./src/XLinkSDK.ts) class provides the core functions of the library. To create an instance:
|
The [`BroSDK`](./src/BroSDK.ts) class provides the core functions of the library. To create an instance:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { XLinkSDK } from "@xlink-network/xlink-sdk"
|
import { BroSDK } from "@brotocol-xyz/bro-sdk"
|
||||||
const sdk = new XLinkSDK()
|
const sdk = new BroSDK()
|
||||||
```
|
```
|
||||||
|
|
||||||
For the full API reference, including a full list of available methods and their usage, visit the [SDK Documentation](https://releases-latest.xlink-sdk.pages.dev).
|
For the full API reference, including a full list of available methods and their usage, visit the [SDK Documentation](https://releases-latest.xlink-sdk.pages.dev).
|
||||||
@@ -61,13 +61,13 @@ Defines types, utility functions, and supported tokens within the SDK.
|
|||||||
Create an instance of the SDK with default options:
|
Create an instance of the SDK with default options:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { XLinkSDK } from "@xlink-network/xlink-sdk"
|
import { BroSDK } from "@brotocol-xyz/bro-sdk"
|
||||||
const xlinkSdk = new XLinkSDK()
|
const broSdk = new BroSDK()
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Bridge from Stacks
|
#### Bridge from Stacks
|
||||||
|
|
||||||
Use case showcasing a transfer of 100 `sUSDT` from Stacks to `USDT` on Ethereum using XLinkSDK.
|
Use case showcasing a transfer of 100 `sUSDT` from Stacks to `USDT` on Ethereum using BroSDK.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import {
|
import {
|
||||||
@@ -75,11 +75,11 @@ import {
|
|||||||
KnownChainId,
|
KnownChainId,
|
||||||
KnownTokenId,
|
KnownTokenId,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
} from '@xlink-network/xlink-sdk';
|
} from '@brotocol-xyz/bro-sdk';
|
||||||
import { serializeCVBytes, makeContractCall, broadcastTransaction } from '@stacks/transactions';
|
import { serializeCVBytes, makeContractCall, broadcastTransaction } from '@stacks/transactions';
|
||||||
|
|
||||||
// Retrieve bridge information
|
// Retrieve bridge information
|
||||||
const bridgeInfo = await xlinkSdk.bridgeInfoFromStacks({
|
const bridgeInfo = await broSdk.bridgeInfoFromStacks({
|
||||||
fromChain: KnownChainId.Stacks.Mainnet,
|
fromChain: KnownChainId.Stacks.Mainnet,
|
||||||
toChain: KnownChainId.EVM.Ethereum,
|
toChain: KnownChainId.EVM.Ethereum,
|
||||||
fromToken: KnownTokenId.Stacks.sUSDT,
|
fromToken: KnownTokenId.Stacks.sUSDT,
|
||||||
@@ -128,13 +128,13 @@ const contractCallOptionsExample: ContractCallOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Perform the bridge operation
|
// Perform the bridge operation
|
||||||
const result = await xlinkSdk.bridgeFromStacks(bridgeFromStacksInput);
|
const result = await broSdk.bridgeFromStacks(bridgeFromStacksInput);
|
||||||
console.log("Transaction ID:", result.txid);
|
console.log("Transaction ID:", result.txid);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Bridge from EVM
|
#### Bridge from EVM
|
||||||
|
|
||||||
Use case showcasing a transfer of 100 `USDT` from Ethereum to `UsSDT` on Stacks using XLinkSDK.
|
Use case showcasing a transfer of 100 `USDT` from Ethereum to `UsSDT` on Stacks using BroSDK.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import {
|
import {
|
||||||
@@ -142,11 +142,11 @@ import {
|
|||||||
KnownChainId,
|
KnownChainId,
|
||||||
KnownTokenId,
|
KnownTokenId,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
} from "@xlink-network/xlink-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
|
||||||
// Retrieve bridge information
|
// Retrieve bridge information
|
||||||
const bridgeInfo = await xlinkSdk.bridgeInfoFromEVM({
|
const bridgeInfo = await broSdk.bridgeInfoFromEVM({
|
||||||
fromChain: KnownChainId.EVM.Ethereum,
|
fromChain: KnownChainId.EVM.Ethereum,
|
||||||
toChain: KnownChainId.Stacks.Mainnet,
|
toChain: KnownChainId.Stacks.Mainnet,
|
||||||
fromToken: KnownTokenId.EVM.USDT,
|
fromToken: KnownTokenId.EVM.USDT,
|
||||||
@@ -195,13 +195,13 @@ const bridgeFromEVMInput: BridgeFromEVMInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Perform the bridge operation
|
// Perform the bridge operation
|
||||||
const result = await xlinkSdk.bridgeFromEVM(bridgeFromEVMInput);
|
const result = await broSdk.bridgeFromEVM(bridgeFromEVMInput);
|
||||||
console.log("Transaction ID:", result.txHash);
|
console.log("Transaction ID:", result.txHash);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Bridge from Bitcoin
|
#### Bridge from Bitcoin
|
||||||
|
|
||||||
Use case showcasing a transfer of 1 `BTC` from Bitcoin to `WBTC` on Ethereum using XLinkSDK.
|
Use case showcasing a transfer of 1 `BTC` from Bitcoin to `WBTC` on Ethereum using BroSDK.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import {
|
import {
|
||||||
@@ -209,7 +209,7 @@ import {
|
|||||||
KnownChainId,
|
KnownChainId,
|
||||||
KnownTokenId,
|
KnownTokenId,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
} from "@xlink-network/xlink-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
/* Use your preferred Bitcoin libs here */
|
/* Use your preferred Bitcoin libs here */
|
||||||
import { Psbt, networks, Transaction, script } from "bitcoinjs-lib";
|
import { Psbt, networks, Transaction, script } from "bitcoinjs-lib";
|
||||||
import { ECPairFactory } from "ecpair";
|
import { ECPairFactory } from "ecpair";
|
||||||
@@ -217,7 +217,7 @@ import * as tinysecp from "tiny-secp256k1";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
// Retrieve bridge information
|
// Retrieve bridge information
|
||||||
const bridgeInfo = await xlinkSdk.bridgeInfoFromBitcoin({
|
const bridgeInfo = await broSdk.bridgeInfoFromBitcoin({
|
||||||
fromChain: KnownChainId.Bitcoin.Mainnet,
|
fromChain: KnownChainId.Bitcoin.Mainnet,
|
||||||
toChain: KnownChainId.EVM.Ethereum,
|
toChain: KnownChainId.EVM.Ethereum,
|
||||||
fromToken: KnownTokenId.Bitcoin.BTC,
|
fromToken: KnownTokenId.Bitcoin.BTC,
|
||||||
@@ -272,6 +272,6 @@ const bridgeFromBitcoinInput: BridgeFromBitcoinInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Perform the bridge operation
|
// Perform the bridge operation
|
||||||
const result = await xlinkSdk.bridgeFromBitcoin(bridgeFromBitcoinInput);
|
const result = await broSdk.bridgeFromBitcoin(bridgeFromBitcoinInput);
|
||||||
console.log("Transaction ID:", result.txid);
|
console.log("Transaction ID:", result.txid);
|
||||||
```
|
```
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# How to Add Support for a new EVM Token
|
# How to Add Support for a new EVM Token
|
||||||
|
|
||||||
This document explains the process for adding support for a new EVM token in the XLink SDK.
|
This document explains the process for adding support for a new EVM token in the SDK.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
BridgeFromBitcoinInput,
|
BridgeFromBitcoinInput,
|
||||||
BridgeFromBitcoinOutput,
|
BridgeFromBitcoinOutput,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "../../src/XLinkSDK"
|
} from "../../src/BroSDK"
|
||||||
|
|
||||||
export type SignInfo = Parameters<BridgeFromBitcoinInput["signPsbt"]>[0]
|
export type SignInfo = Parameters<BridgeFromBitcoinInput["signPsbt"]>[0]
|
||||||
|
|
||||||
export class TransactionBuilder {
|
export class TransactionBuilder {
|
||||||
constructor(private readonly sdk: XLinkSDK) {}
|
constructor(private readonly sdk: BroSDK) {}
|
||||||
|
|
||||||
private inProgressRequests = new Map<
|
private inProgressRequests = new Map<
|
||||||
/* requestId */ string,
|
/* requestId */ string,
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import { UTXOSpendable } from "../../src/bitcoinHelpers"
|
|||||||
import {
|
import {
|
||||||
BridgeFromBitcoinInput,
|
BridgeFromBitcoinInput,
|
||||||
BridgeFromBitcoinOutput,
|
BridgeFromBitcoinOutput,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "../../src/XLinkSDK"
|
} from "../../src/BroSDK"
|
||||||
|
|
||||||
export type SignInfo = Parameters<BridgeFromBitcoinInput["signPsbt"]>[0]
|
export type SignInfo = Parameters<BridgeFromBitcoinInput["signPsbt"]>[0]
|
||||||
|
|
||||||
export class TransactionBuilder {
|
export class TransactionBuilder {
|
||||||
constructor(private readonly sdk: XLinkSDK) {}
|
constructor(private readonly sdk: BroSDK) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a cache of the request parameters for the transaction builder.
|
* This is a cache of the request parameters for the transaction builder.
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
# XLink SDK Cross-Chain Swap Demo
|
# Brotocol SDK Cross-Chain Swap Demo
|
||||||
|
|
||||||
This demo project showcases how to implement cross-chain asset exchange functionality using XLink SDK and ALEX SDK.
|
This demo project showcases how to implement cross-chain asset exchange functionality using Brotocol SDK and ALEX SDK.
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
This demo application demonstrates how to integrate XLink SDK and ALEX SDK to create a complete cross-chain swap experience. Users can seamlessly transfer and exchange digital assets between different blockchains.
|
This demo application demonstrates how to integrate Brotocol SDK and ALEX SDK to create a complete cross-chain swap experience. Users can seamlessly transfer and exchange digital assets between different blockchains.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
Ensure you have the following tools installed:
|
Ensure you have the following tools installed:
|
||||||
|
|
||||||
- Node.js
|
- Node.js
|
||||||
- pnpm (recommended) or npm
|
- pnpm (recommended) or npm
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { XLinkSDK } from "@brotocol-xyz/bro-sdk"
|
import { BroSDK } from "@brotocol-xyz/bro-sdk"
|
||||||
import { AlexSDK } from "alex-sdk"
|
import { AlexSDK } from "alex-sdk"
|
||||||
import { FC } from "react"
|
import { FC } from "react"
|
||||||
import "./App.css"
|
import "./App.css"
|
||||||
@@ -6,7 +6,7 @@ import { SwapRouteSelector } from "./components/SwapRouteSelector"
|
|||||||
import { QueryClient, QueryClientProvider } from "react-query"
|
import { QueryClient, QueryClientProvider } from "react-query"
|
||||||
|
|
||||||
const alex = new AlexSDK()
|
const alex = new AlexSDK()
|
||||||
const sdk = new XLinkSDK()
|
const sdk = new BroSDK()
|
||||||
const queryClient = new QueryClient()
|
const queryClient = new QueryClient()
|
||||||
|
|
||||||
const App: FC = () => {
|
const App: FC = () => {
|
||||||
@@ -14,7 +14,7 @@ const App: FC = () => {
|
|||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<div className="app-container">
|
<div className="app-container">
|
||||||
<header className="app-header">
|
<header className="app-header">
|
||||||
<h1>XLink Cross-Chain Swap Demo</h1>
|
<h1>Brotocol Cross-Chain Swap Demo</h1>
|
||||||
</header>
|
</header>
|
||||||
<main className="app-main">
|
<main className="app-main">
|
||||||
<div className="content-wrapper">
|
<div className="content-wrapper">
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import {
|
|||||||
StacksContractAddress,
|
StacksContractAddress,
|
||||||
SwapRoute_WithExchangeRate,
|
SwapRoute_WithExchangeRate,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "@brotocol-xyz/bro-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
import { AlexSDK } from "alex-sdk"
|
import { AlexSDK } from "alex-sdk"
|
||||||
import { FC, Fragment, useState } from "react"
|
import { FC, Fragment, useState } from "react"
|
||||||
import { useQuery } from "react-query"
|
import { useQuery } from "react-query"
|
||||||
import { useDebouncedValue } from "../hooks/useDebouncedValue"
|
import { useDebouncedValue } from "../hooks/useDebouncedValue"
|
||||||
import { formatXLinkSDKChainName } from "../utils/formatXLinkSDKChainName"
|
import { formatSDKChainName } from "../utils/formatSDKChainName"
|
||||||
import { getAvailableRoutes } from "../utils/getAvailableRoutes"
|
import { getAvailableRoutes } from "../utils/getAvailableRoutes"
|
||||||
import { getSwapRoutesViaALEX } from "../utils/getSwapRoutesViaALEX"
|
import { getSwapRoutesViaALEX } from "../utils/getSwapRoutesViaALEX"
|
||||||
import { getSwapRoutesViaEVMDEX } from "../utils/getSwapRoutesViaEVMDEX"
|
import { getSwapRoutesViaEVMDEX } from "../utils/getSwapRoutesViaEVMDEX"
|
||||||
|
|
||||||
export const SwapRouteSelector: FC<{
|
export const SwapRouteSelector: FC<{
|
||||||
alexSDK: AlexSDK
|
alexSDK: AlexSDK
|
||||||
sdk: XLinkSDK
|
sdk: BroSDK
|
||||||
}> = ({ alexSDK, sdk }) => {
|
}> = ({ alexSDK, sdk }) => {
|
||||||
const [swapAmount, setSwapAmount] = useState("")
|
const [swapAmount, setSwapAmount] = useState("")
|
||||||
const [selectedRoute, setSelectedRoute] = useState<null | KnownRoute>(null)
|
const [selectedRoute, setSelectedRoute] = useState<null | KnownRoute>(null)
|
||||||
@@ -169,8 +169,8 @@ export const SwapRouteSelector: FC<{
|
|||||||
{availableRoutes.data?.map((route, index) => (
|
{availableRoutes.data?.map((route, index) => (
|
||||||
<option key={index} value={JSON.stringify(route)}>
|
<option key={index} value={JSON.stringify(route)}>
|
||||||
{route.fromTokenName} (
|
{route.fromTokenName} (
|
||||||
{formatXLinkSDKChainName(route.fromChain)}) →{" "}
|
{formatSDKChainName(route.fromChain)}) →{" "}
|
||||||
{route.toTokenName} ({formatXLinkSDKChainName(route.toChain)})
|
{route.toTokenName} ({formatSDKChainName(route.toChain)})
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { KnownChainId } from "@brotocol-xyz/bro-sdk"
|
import { KnownChainId } from "@brotocol-xyz/bro-sdk"
|
||||||
|
|
||||||
export const formatXLinkSDKChainName = (
|
export const formatSDKChainName = (chain: KnownChainId.KnownChain): string => {
|
||||||
chain: KnownChainId.KnownChain,
|
|
||||||
): string => {
|
|
||||||
if (KnownChainId.isBitcoinChain(chain)) {
|
if (KnownChainId.isBitcoinChain(chain)) {
|
||||||
return "Bitcoin"
|
return "Bitcoin"
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,11 @@ import {
|
|||||||
KnownChainId,
|
KnownChainId,
|
||||||
KnownRoute,
|
KnownRoute,
|
||||||
KnownTokenId,
|
KnownTokenId,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "@brotocol-xyz/bro-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
|
|
||||||
export const getAvailableRoutes = async (
|
export const getAvailableRoutes = async (
|
||||||
sdk: XLinkSDK,
|
sdk: BroSDK,
|
||||||
): Promise<(KnownRoute & { fromTokenName: string; toTokenName: string })[]> => {
|
): Promise<(KnownRoute & { fromTokenName: string; toTokenName: string })[]> => {
|
||||||
const routes = await _getAvailableRoutes(sdk)
|
const routes = await _getAvailableRoutes(sdk)
|
||||||
return routes.map(
|
return routes.map(
|
||||||
@@ -31,7 +31,7 @@ type ChainTokenPair = readonly [
|
|||||||
type AvailableRoute = readonly [from: ChainTokenPair, to: ChainTokenPair]
|
type AvailableRoute = readonly [from: ChainTokenPair, to: ChainTokenPair]
|
||||||
|
|
||||||
const _getAvailableRoutes = async (
|
const _getAvailableRoutes = async (
|
||||||
sdk: XLinkSDK,
|
sdk: BroSDK,
|
||||||
): Promise<AvailableRoute[]> => {
|
): Promise<AvailableRoute[]> => {
|
||||||
const alexBrc20 = await sdk.brc20TickToBRC20Token(
|
const alexBrc20 = await sdk.brc20TickToBRC20Token(
|
||||||
KnownChainId.BRC20.Mainnet,
|
KnownChainId.BRC20.Mainnet,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
SwapRouteViaALEX_WithExchangeRate,
|
SwapRouteViaALEX_WithExchangeRate,
|
||||||
SwapRouteViaALEX_WithMinimumAmountsOut,
|
SwapRouteViaALEX_WithMinimumAmountsOut,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "@brotocol-xyz/bro-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
import { getALEXSwapParameters } from "@brotocol-xyz/bro-sdk/swapHelpers"
|
import { getALEXSwapParameters } from "@brotocol-xyz/bro-sdk/swapHelpers"
|
||||||
import { AlexSDK } from "alex-sdk"
|
import { AlexSDK } from "alex-sdk"
|
||||||
@@ -14,7 +14,7 @@ import { sortBy, uniqBy } from "lodash-es"
|
|||||||
export async function getSwapRoutesViaALEX(
|
export async function getSwapRoutesViaALEX(
|
||||||
context: {
|
context: {
|
||||||
alexSDK: AlexSDK
|
alexSDK: AlexSDK
|
||||||
sdk: XLinkSDK
|
sdk: BroSDK
|
||||||
},
|
},
|
||||||
swapRequest: KnownRoute & {
|
swapRequest: KnownRoute & {
|
||||||
amount: SDKNumber
|
amount: SDKNumber
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
SwapRouteViaEVMDexAggregator_WithExchangeRate,
|
SwapRouteViaEVMDexAggregator_WithExchangeRate,
|
||||||
SwapRouteViaEVMDexAggregator_WithMinimumAmountsOut,
|
SwapRouteViaEVMDexAggregator_WithMinimumAmountsOut,
|
||||||
toSDKNumberOrUndefined,
|
toSDKNumberOrUndefined,
|
||||||
XLinkSDK,
|
BroSDK,
|
||||||
} from "@brotocol-xyz/bro-sdk"
|
} from "@brotocol-xyz/bro-sdk"
|
||||||
import {
|
import {
|
||||||
fetchKyberSwapPossibleRoutesFactory,
|
fetchKyberSwapPossibleRoutesFactory,
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
|
|
||||||
export async function getSwapRoutesViaEVMDEX(
|
export async function getSwapRoutesViaEVMDEX(
|
||||||
context: {
|
context: {
|
||||||
sdk: XLinkSDK
|
sdk: BroSDK
|
||||||
},
|
},
|
||||||
swapRequest: KnownRoute & {
|
swapRequest: KnownRoute & {
|
||||||
amount: SDKNumber
|
amount: SDKNumber
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { XLinkSDK } from "../src"
|
import { BroSDK } from "../src"
|
||||||
import { KnownRoute } from "../src/utils/buildSupportedRoutes"
|
import { KnownRoute } from "../src/utils/buildSupportedRoutes"
|
||||||
|
|
||||||
async function print(matchers: {
|
async function print(matchers: {
|
||||||
@@ -7,7 +7,7 @@ async function print(matchers: {
|
|||||||
chain: string[]
|
chain: string[]
|
||||||
token: string[]
|
token: string[]
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const sdk = new XLinkSDK({
|
const sdk = new BroSDK({
|
||||||
debugLog: matchers.debug,
|
debugLog: matchers.debug,
|
||||||
})
|
})
|
||||||
const supportedRoutes = await sdk
|
const supportedRoutes = await sdk
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { XLinkSDK } from "../src"
|
import { BroSDK } from "../src"
|
||||||
import { getAllAddresses } from "../src/evmUtils/contractHelpers"
|
import { getAllAddresses } from "../src/evmUtils/contractHelpers"
|
||||||
import { getXLinkSDKContext } from "../src/lowlevelUnstableInfos"
|
import { getSDKContext } from "../src/lowlevelUnstableInfos"
|
||||||
import { _allKnownEVMChains } from "../src/utils/types/knownIds"
|
import { _allKnownEVMChains } from "../src/utils/types/knownIds"
|
||||||
|
|
||||||
async function print(matchers: { chain: string[] }): Promise<void> {
|
async function print(matchers: { chain: string[] }): Promise<void> {
|
||||||
@@ -8,8 +8,8 @@ async function print(matchers: { chain: string[] }): Promise<void> {
|
|||||||
matchers.chain.some(m => c.includes(m)),
|
matchers.chain.some(m => c.includes(m)),
|
||||||
)
|
)
|
||||||
|
|
||||||
const sdk = new XLinkSDK()
|
const sdk = new BroSDK()
|
||||||
const ctx = getXLinkSDKContext(sdk)
|
const ctx = getSDKContext(sdk)
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
chainIds.map(chainId =>
|
chainIds.map(chainId =>
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export {
|
|||||||
} from "./sdkUtils/timelockFromEVM"
|
} from "./sdkUtils/timelockFromEVM"
|
||||||
export type { DumpableCache } from "./utils/DumpableCache"
|
export type { DumpableCache } from "./utils/DumpableCache"
|
||||||
|
|
||||||
export interface XLinkSDKOptions {
|
export interface BroSDKOptions {
|
||||||
debugLog?: boolean
|
debugLog?: boolean
|
||||||
__experimental?: {
|
__experimental?: {
|
||||||
backendAPI?: {
|
backendAPI?: {
|
||||||
@@ -225,20 +225,20 @@ export interface XLinkSDKOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let defaultConfig: XLinkSDKOptions = {
|
let defaultConfig: BroSDKOptions = {
|
||||||
evm: {
|
evm: {
|
||||||
cacheOnChainConfig: true,
|
cacheOnChainConfig: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export class XLinkSDK {
|
export class BroSDK {
|
||||||
static defaultConfig(options: XLinkSDKOptions): void {
|
static defaultConfig(options: BroSDKOptions): void {
|
||||||
defaultConfig = options
|
defaultConfig = options
|
||||||
}
|
}
|
||||||
|
|
||||||
private sdkContext: SDKGlobalContext
|
private sdkContext: SDKGlobalContext
|
||||||
|
|
||||||
constructor(options: XLinkSDKOptions = {}) {
|
constructor(options: BroSDKOptions = {}) {
|
||||||
const cacheEVMOnChainConfig =
|
const cacheEVMOnChainConfig =
|
||||||
options.evm?.cacheOnChainConfig ?? defaultConfig.evm?.cacheOnChainConfig
|
options.evm?.cacheOnChainConfig ?? defaultConfig.evm?.cacheOnChainConfig
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ export class XLinkSDK {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether a given route (from one blockchain/token to another) is supported by the XLink SDK.
|
* Determines whether a given route (from one blockchain/token to another) is supported by the SDK.
|
||||||
* This function evaluates cross-chain compatibility for all supported networks (EVM, Stacks, Bitcoin, BRC20, Runes)
|
* This function evaluates cross-chain compatibility for all supported networks (EVM, Stacks, Bitcoin, BRC20, Runes)
|
||||||
* by delegating to specialized validators per source chain type. It checks that the route is logically valid,
|
* by delegating to specialized validators per source chain type. It checks that the route is logically valid,
|
||||||
* not deprecated, and exists in the bridge configuration which is dynamically fetched.
|
* not deprecated, and exists in the bridge configuration which is dynamically fetched.
|
||||||
@@ -434,7 +434,7 @@ export class XLinkSDK {
|
|||||||
*
|
*
|
||||||
* @returns A promise that resolves with the known token ID corresponding to the provided
|
* @returns A promise that resolves with the known token ID corresponding to the provided
|
||||||
* contract address, or `undefined` if the chain is not a Stacks chain or if the token is not
|
* contract address, or `undefined` if the chain is not a Stacks chain or if the token is not
|
||||||
* supported by XLINK.
|
* supported by Brotocol.
|
||||||
*/
|
*/
|
||||||
stacksAddressToStacksToken(
|
stacksAddressToStacksToken(
|
||||||
chain: ChainId,
|
chain: ChainId,
|
||||||
@@ -525,7 +525,7 @@ export class XLinkSDK {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function retrieves the numeric EVM chain ID (`chainId`) associated with a known EVM-compatible chain in the SDK.
|
* This function retrieves the numeric EVM chain ID (`chainId`) associated with a known EVM-compatible chain in the SDK.
|
||||||
* This chain ID serves as the identifier for chains within XLINK smart contracts.
|
* This chain ID serves as the identifier for chains within smart contracts.
|
||||||
*
|
*
|
||||||
* @param chain - A known EVM-compatible chain identifier (`KnownChainId.EVMChain`).
|
* @param chain - A known EVM-compatible chain identifier (`KnownChainId.EVMChain`).
|
||||||
*
|
*
|
||||||
@@ -694,7 +694,7 @@ export class XLinkSDK {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the BTC Peg-In address and its corresponding ScriptPubKey for a given Bitcoin source
|
* Retrieves the BTC Peg-In address and its corresponding ScriptPubKey for a given Bitcoin source
|
||||||
* chain (mainnet or testnet) and a specified destination chain.
|
* chain (mainnet or testnet) and a specified destination chain.
|
||||||
* This address is used to initiate a transfer (peg-in) from the Bitcoin network into the XLink protocol.
|
* This address is used to initiate a transfer (peg-in) from the Bitcoin network into the Brotocol.
|
||||||
*
|
*
|
||||||
* @param fromChain - The source Bitcoin chain (`Mainnet` or `Testnet`).
|
* @param fromChain - The source Bitcoin chain (`Mainnet` or `Testnet`).
|
||||||
* @param toChain - The destination chain (must be a known chain, although it is not used in address generation).
|
* @param toChain - The destination chain (must be a known chain, although it is not used in address generation).
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
export const SDK_NAME = "BroSDK"
|
||||||
|
|
||||||
export const BITCOIN_OUTPUT_MINIMUM_AMOUNT = 546n
|
export const BITCOIN_OUTPUT_MINIMUM_AMOUNT = 546n
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { XLinkSDKErrorBase } from "../utils/errors"
|
import { BroSDKErrorBase } from "../utils/errors"
|
||||||
|
|
||||||
export class InsufficientBitcoinBalanceError extends XLinkSDKErrorBase {
|
export class InsufficientBitcoinBalanceError extends BroSDKErrorBase {
|
||||||
constructor(...args: ConstructorParameters<typeof Error>) {
|
constructor(...args: ConstructorParameters<typeof Error>) {
|
||||||
super(...args)
|
super(...args)
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export class InsufficientBitcoinBalanceError extends XLinkSDKErrorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UnsupportedBitcoinInput extends XLinkSDKErrorBase {
|
export class UnsupportedBitcoinInput extends BroSDKErrorBase {
|
||||||
constructor(
|
constructor(
|
||||||
public txid: string,
|
public txid: string,
|
||||||
public index: number,
|
public index: number,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { getBRC20SupportedRoutes } from "../metaUtils/apiHelpers/getBRC20Support
|
|||||||
import { getRunesSupportedRoutes } from "../metaUtils/apiHelpers/getRunesSupportedRoutes"
|
import { getRunesSupportedRoutes } from "../metaUtils/apiHelpers/getRunesSupportedRoutes"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksTokenContractInfo,
|
getStacksTokenContractInfo,
|
||||||
numberFromStacksContractNumber,
|
numberFromStacksContractNumber,
|
||||||
@@ -87,19 +87,19 @@ const _getBtc2StacksFeeInfo = async (
|
|||||||
(checkNever(options.swapRoute.via), stacksBaseContractCallInfo)
|
(checkNever(options.swapRoute.via), stacksBaseContractCallInfo)
|
||||||
|
|
||||||
const resp = await props({
|
const resp = await props({
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"is-peg-in-paused",
|
"is-peg-in-paused",
|
||||||
{},
|
{},
|
||||||
contractCallInfo.executeOptions,
|
contractCallInfo.executeOptions,
|
||||||
),
|
),
|
||||||
feeRate: executeReadonlyCallXLINK(
|
feeRate: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"get-peg-in-fee",
|
"get-peg-in-fee",
|
||||||
{},
|
{},
|
||||||
contractCallInfo.executeOptions,
|
contractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
minFeeAmount: executeReadonlyCallXLINK(
|
minFeeAmount: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"get-peg-in-min-fee",
|
"get-peg-in-min-fee",
|
||||||
{},
|
{},
|
||||||
@@ -233,13 +233,13 @@ const _getStacks2BtcFeeInfo = async (
|
|||||||
async (info): Promise<SpecialFeeDetailsForSwapRoute> =>
|
async (info): Promise<SpecialFeeDetailsForSwapRoute> =>
|
||||||
info ??
|
info ??
|
||||||
props({
|
props({
|
||||||
feeRate: executeReadonlyCallXLINK(
|
feeRate: executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-peg-out-fee",
|
"get-peg-out-fee",
|
||||||
{},
|
{},
|
||||||
stacksContractCallInfo.executeOptions,
|
stacksContractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
minFeeAmount: executeReadonlyCallXLINK(
|
minFeeAmount: executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-peg-out-min-fee",
|
"get-peg-out-min-fee",
|
||||||
{},
|
{},
|
||||||
@@ -250,7 +250,7 @@ const _getStacks2BtcFeeInfo = async (
|
|||||||
|
|
||||||
const resp = await props({
|
const resp = await props({
|
||||||
...feeDetails,
|
...feeDetails,
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"is-peg-out-paused",
|
"is-peg-out-paused",
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { getRunesSupportedRoutes } from "../metaUtils/apiHelpers/getRunesSupport
|
|||||||
import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContractDataMapping"
|
import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContractDataMapping"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksTokenContractInfo,
|
getStacksTokenContractInfo,
|
||||||
numberFromStacksContractNumber,
|
numberFromStacksContractNumber,
|
||||||
@@ -142,7 +142,7 @@ const _getEvm2StacksFeeInfo = async (
|
|||||||
functionName: "maxAmountPerToken",
|
functionName: "maxAmountPerToken",
|
||||||
args: [tokenContractAddress],
|
args: [tokenContractAddress],
|
||||||
}).then(numberFromSolidityContractNumber),
|
}).then(numberFromSolidityContractNumber),
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-paused",
|
"get-paused",
|
||||||
{},
|
{},
|
||||||
@@ -201,7 +201,7 @@ const getEvm2StacksNativeBridgeFeeInfo = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const resp = await props({
|
const resp = await props({
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-paused",
|
"get-paused",
|
||||||
{},
|
{},
|
||||||
@@ -338,7 +338,7 @@ const _getStacks2EvmFeeInfo = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tokenConf = await Promise.all([
|
const tokenConf = await Promise.all([
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-approved-pair-or-fail",
|
"get-approved-pair-or-fail",
|
||||||
{
|
{
|
||||||
@@ -349,7 +349,7 @@ const _getStacks2EvmFeeInfo = async (
|
|||||||
},
|
},
|
||||||
stacksContractCallInfo.executeOptions,
|
stacksContractCallInfo.executeOptions,
|
||||||
),
|
),
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
stacksContractCallInfo.contractName,
|
stacksContractCallInfo.contractName,
|
||||||
"get-paused",
|
"get-paused",
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export * from "./XLinkSDK"
|
export * from "./BroSDK"
|
||||||
export * from "./utils/errors"
|
export * from "./utils/errors"
|
||||||
export {
|
export {
|
||||||
ChainId,
|
ChainId,
|
||||||
|
|||||||
@@ -80,39 +80,36 @@ export { bridgeInfoFromBitcoin_toLaunchpad } from "./sdkUtils/bridgeInfoFromBitc
|
|||||||
|
|
||||||
export { getBitcoinHardLinkageAddress } from "./bitcoinUtils/btcAddresses"
|
export { getBitcoinHardLinkageAddress } from "./bitcoinUtils/btcAddresses"
|
||||||
|
|
||||||
export const getXLinkSDKContext = (
|
export const getSDKContext = (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
): SDKGlobalContext => {
|
): SDKGlobalContext => {
|
||||||
return sdk["sdkContext"]
|
return sdk["sdkContext"]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTerminatingStacksTokenContractAddress = async (
|
export const getTerminatingStacksTokenContractAddress = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
info: {
|
info: {
|
||||||
evmChain: KnownChainId.EVMChain
|
evmChain: KnownChainId.EVMChain
|
||||||
evmToken: KnownTokenId.EVMToken
|
evmToken: KnownTokenId.EVMToken
|
||||||
stacksChain: KnownChainId.StacksChain
|
stacksChain: KnownChainId.StacksChain
|
||||||
},
|
},
|
||||||
): Promise<undefined | StacksContractAddress> => {
|
): Promise<undefined | StacksContractAddress> => {
|
||||||
return _getTerminatingStacksTokenContractAddress(
|
return _getTerminatingStacksTokenContractAddress(getSDKContext(sdk), info)
|
||||||
getXLinkSDKContext(sdk),
|
|
||||||
info,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
export const getStacksTokenFromTerminatingStacksTokenContractAddress = async (
|
export const getStacksTokenFromTerminatingStacksTokenContractAddress = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
info: {
|
info: {
|
||||||
stacksChain: KnownChainId.StacksChain
|
stacksChain: KnownChainId.StacksChain
|
||||||
stacksTokenAddress: StacksContractAddress
|
stacksTokenAddress: StacksContractAddress
|
||||||
},
|
},
|
||||||
): Promise<undefined | KnownTokenId.StacksToken> => {
|
): Promise<undefined | KnownTokenId.StacksToken> => {
|
||||||
return _getStacksTokenFromTerminatingStacksTokenContractAddress(
|
return _getStacksTokenFromTerminatingStacksTokenContractAddress(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
info,
|
info,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export const getEVMTokenIdFromTerminatingStacksTokenContractAddress = async (
|
export const getEVMTokenIdFromTerminatingStacksTokenContractAddress = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
info: {
|
info: {
|
||||||
evmChain: KnownChainId.EVMChain
|
evmChain: KnownChainId.EVMChain
|
||||||
stacksChain: KnownChainId.StacksChain
|
stacksChain: KnownChainId.StacksChain
|
||||||
@@ -120,13 +117,13 @@ export const getEVMTokenIdFromTerminatingStacksTokenContractAddress = async (
|
|||||||
},
|
},
|
||||||
): Promise<undefined | KnownTokenId.EVMToken> => {
|
): Promise<undefined | KnownTokenId.EVMToken> => {
|
||||||
return _getEVMTokenFromTerminatingStacksTokenContractAddress(
|
return _getEVMTokenFromTerminatingStacksTokenContractAddress(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
info,
|
info,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const evmTokensFromStacksToken = async (
|
export const evmTokensFromStacksToken = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
options: {
|
options: {
|
||||||
fromStacksChain: KnownChainId.StacksChain
|
fromStacksChain: KnownChainId.StacksChain
|
||||||
fromStacksToken: KnownTokenId.StacksToken
|
fromStacksToken: KnownTokenId.StacksToken
|
||||||
@@ -136,14 +133,14 @@ export const evmTokensFromStacksToken = async (
|
|||||||
evmTokens: KnownTokenId.EVMToken[]
|
evmTokens: KnownTokenId.EVMToken[]
|
||||||
}> => {
|
}> => {
|
||||||
const evmTokens = await evmTokenFromCorrespondingStacksToken(
|
const evmTokens = await evmTokenFromCorrespondingStacksToken(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
options.toChain,
|
options.toChain,
|
||||||
options.fromStacksToken,
|
options.fromStacksToken,
|
||||||
)
|
)
|
||||||
return { evmTokens }
|
return { evmTokens }
|
||||||
}
|
}
|
||||||
export const evmTokenToStacksToken = async (
|
export const evmTokenToStacksToken = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
options: {
|
options: {
|
||||||
fromChain: KnownChainId.EVMChain
|
fromChain: KnownChainId.EVMChain
|
||||||
fromToken: KnownTokenId.EVMToken
|
fromToken: KnownTokenId.EVMToken
|
||||||
@@ -153,7 +150,7 @@ export const evmTokenToStacksToken = async (
|
|||||||
stacksTokens: KnownTokenId.StacksToken[]
|
stacksTokens: KnownTokenId.StacksToken[]
|
||||||
}> => {
|
}> => {
|
||||||
const stacksTokens = await evmTokenToCorrespondingStacksToken(
|
const stacksTokens = await evmTokenToCorrespondingStacksToken(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
options.fromChain,
|
options.fromChain,
|
||||||
options.fromToken,
|
options.fromToken,
|
||||||
)
|
)
|
||||||
@@ -161,7 +158,7 @@ export const evmTokenToStacksToken = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const metaTokensFromStacksToken = async (
|
export const metaTokensFromStacksToken = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
options: {
|
options: {
|
||||||
fromStacksChain: KnownChainId.StacksChain
|
fromStacksChain: KnownChainId.StacksChain
|
||||||
fromStacksToken: KnownTokenId.StacksToken
|
fromStacksToken: KnownTokenId.StacksToken
|
||||||
@@ -171,14 +168,14 @@ export const metaTokensFromStacksToken = async (
|
|||||||
tokens: (KnownTokenId.BRC20Token | KnownTokenId.RunesToken)[]
|
tokens: (KnownTokenId.BRC20Token | KnownTokenId.RunesToken)[]
|
||||||
}> => {
|
}> => {
|
||||||
const metaTokens = await metaTokenFromCorrespondingStacksToken(
|
const metaTokens = await metaTokenFromCorrespondingStacksToken(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
options.toChain,
|
options.toChain,
|
||||||
options.fromStacksToken,
|
options.fromStacksToken,
|
||||||
)
|
)
|
||||||
return { tokens: metaTokens == null ? [] : [metaTokens as any] }
|
return { tokens: metaTokens == null ? [] : [metaTokens as any] }
|
||||||
}
|
}
|
||||||
export const metaTokenToStacksToken = async (
|
export const metaTokenToStacksToken = async (
|
||||||
sdk: import("./XLinkSDK").XLinkSDK,
|
sdk: import("./BroSDK").BroSDK,
|
||||||
options: {
|
options: {
|
||||||
fromChain: KnownChainId.BRC20Chain | KnownChainId.RunesChain
|
fromChain: KnownChainId.BRC20Chain | KnownChainId.RunesChain
|
||||||
fromToken: KnownTokenId.BRC20Token | KnownTokenId.RunesToken
|
fromToken: KnownTokenId.BRC20Token | KnownTokenId.RunesToken
|
||||||
@@ -188,7 +185,7 @@ export const metaTokenToStacksToken = async (
|
|||||||
stacksTokens: KnownTokenId.StacksToken[]
|
stacksTokens: KnownTokenId.StacksToken[]
|
||||||
}> => {
|
}> => {
|
||||||
const stacksTokens = await metaTokenToCorrespondingStacksToken(
|
const stacksTokens = await metaTokenToCorrespondingStacksToken(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
{
|
{
|
||||||
chain: options.fromChain as any,
|
chain: options.fromChain as any,
|
||||||
token: options.fromToken as any,
|
token: options.fromToken as any,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getEVMSupportedRoutes } from "../evmUtils/apiHelpers/getEVMSupportedRoutes"
|
import { getEVMSupportedRoutes } from "../evmUtils/apiHelpers/getEVMSupportedRoutes"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
numberFromStacksContractNumber,
|
numberFromStacksContractNumber,
|
||||||
} from "../stacksUtils/contractHelpers"
|
} from "../stacksUtils/contractHelpers"
|
||||||
@@ -179,13 +179,13 @@ const getMeta2StacksSwapFeeInfo = async (
|
|||||||
if (contractCallInfo == null) return
|
if (contractCallInfo == null) return
|
||||||
|
|
||||||
const resp = await props({
|
const resp = await props({
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"is-paused",
|
"is-paused",
|
||||||
{},
|
{},
|
||||||
contractCallInfo.executeOptions,
|
contractCallInfo.executeOptions,
|
||||||
),
|
),
|
||||||
fixedBtcFee: executeReadonlyCallXLINK(
|
fixedBtcFee: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"get-peg-in-fee",
|
"get-peg-in-fee",
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ import {
|
|||||||
getBTCPegInAddress,
|
getBTCPegInAddress,
|
||||||
getBitcoinHardLinkageAddress,
|
getBitcoinHardLinkageAddress,
|
||||||
} from "../bitcoinUtils/btcAddresses"
|
} from "../bitcoinUtils/btcAddresses"
|
||||||
import { BITCOIN_OUTPUT_MINIMUM_AMOUNT } from "../bitcoinUtils/constants"
|
import {
|
||||||
|
BITCOIN_OUTPUT_MINIMUM_AMOUNT,
|
||||||
|
SDK_NAME,
|
||||||
|
} from "../bitcoinUtils/constants"
|
||||||
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
||||||
import {
|
import {
|
||||||
BitcoinTransactionPrepareResult,
|
BitcoinTransactionPrepareResult,
|
||||||
@@ -24,6 +27,7 @@ import {
|
|||||||
getMeta2StacksFeeInfo,
|
getMeta2StacksFeeInfo,
|
||||||
isSupportedBRC20Route,
|
isSupportedBRC20Route,
|
||||||
} from "../metaUtils/peggingHelpers"
|
} from "../metaUtils/peggingHelpers"
|
||||||
|
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||||
import { CreateBridgeOrderResult } from "../stacksUtils/createBridgeOrderFromBitcoin"
|
import { CreateBridgeOrderResult } from "../stacksUtils/createBridgeOrderFromBitcoin"
|
||||||
import {
|
import {
|
||||||
createBridgeOrder_MetaToBitcoin,
|
createBridgeOrder_MetaToBitcoin,
|
||||||
@@ -32,7 +36,6 @@ import {
|
|||||||
createBridgeOrder_MetaToStacks,
|
createBridgeOrder_MetaToStacks,
|
||||||
} from "../stacksUtils/createBridgeOrderFromMeta"
|
} from "../stacksUtils/createBridgeOrderFromMeta"
|
||||||
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
||||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
|
||||||
import { range } from "../utils/arrayHelpers"
|
import { range } from "../utils/arrayHelpers"
|
||||||
import { BigNumber } from "../utils/BigNumber"
|
import { BigNumber } from "../utils/BigNumber"
|
||||||
import {
|
import {
|
||||||
@@ -141,7 +144,7 @@ export async function bridgeFromBRC20(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromBRC20"],
|
[SDK_NAME, "bridgeFromBRC20"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "fromAddressScriptPubKey",
|
name: "fromAddressScriptPubKey",
|
||||||
@@ -165,7 +168,7 @@ export async function bridgeFromBRC20(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromBRC20"],
|
[SDK_NAME, "bridgeFromBRC20"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "toAddressScriptPubKey",
|
name: "toAddressScriptPubKey",
|
||||||
@@ -457,7 +460,7 @@ async function bridgeFromBRC20_toBitcoin(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -519,7 +522,7 @@ async function bridgeFromBRC20_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import {
|
|||||||
getBTCPegInAddress,
|
getBTCPegInAddress,
|
||||||
getBitcoinHardLinkageAddress,
|
getBitcoinHardLinkageAddress,
|
||||||
} from "../bitcoinUtils/btcAddresses"
|
} from "../bitcoinUtils/btcAddresses"
|
||||||
import { BITCOIN_OUTPUT_MINIMUM_AMOUNT } from "../bitcoinUtils/constants"
|
import {
|
||||||
|
BITCOIN_OUTPUT_MINIMUM_AMOUNT,
|
||||||
|
SDK_NAME,
|
||||||
|
} from "../bitcoinUtils/constants"
|
||||||
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
||||||
import { isSupportedBitcoinRoute } from "../bitcoinUtils/peggingHelpers"
|
import { isSupportedBitcoinRoute } from "../bitcoinUtils/peggingHelpers"
|
||||||
import {
|
import {
|
||||||
@@ -124,7 +127,7 @@ export async function bridgeFromBitcoin(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromBitcoin"],
|
[SDK_NAME, "bridgeFromBitcoin"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "fromAddressScriptPubKey",
|
name: "fromAddressScriptPubKey",
|
||||||
@@ -148,7 +151,7 @@ export async function bridgeFromBitcoin(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromBitcoin"],
|
[SDK_NAME, "bridgeFromBitcoin"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "toAddressScriptPubKey",
|
name: "toAddressScriptPubKey",
|
||||||
@@ -344,7 +347,7 @@ async function bridgeFromBitcoin_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromBitcoin (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromBitcoin (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { encodeFunctionData, Hex, toHex } from "viem"
|
import { encodeFunctionData, Hex, toHex } from "viem"
|
||||||
import { estimateGas } from "viem/actions"
|
import { estimateGas } from "viem/actions"
|
||||||
|
import { SDK_NAME } from "../bitcoinUtils/constants"
|
||||||
import { BridgeEndpointAbi } from "../evmUtils/contractAbi/bridgeEndpoint"
|
import { BridgeEndpointAbi } from "../evmUtils/contractAbi/bridgeEndpoint"
|
||||||
import { NativeBridgeEndpointAbi } from "../evmUtils/contractAbi/nativeBridgeEndpoint"
|
import { NativeBridgeEndpointAbi } from "../evmUtils/contractAbi/nativeBridgeEndpoint"
|
||||||
import { sendMessageAbi } from "../evmUtils/contractMessageHelpers"
|
|
||||||
import { isSupportedEVMRoute } from "../evmUtils/peggingHelpers"
|
|
||||||
import {
|
import {
|
||||||
getEVMContractCallInfo,
|
getEVMContractCallInfo,
|
||||||
getEVMTokenContractInfo,
|
getEVMTokenContractInfo,
|
||||||
numberToSolidityContractNumber,
|
numberToSolidityContractNumber,
|
||||||
} from "../evmUtils/contractHelpers"
|
} from "../evmUtils/contractHelpers"
|
||||||
|
import { sendMessageAbi } from "../evmUtils/contractMessageHelpers"
|
||||||
|
import { isSupportedEVMRoute } from "../evmUtils/peggingHelpers"
|
||||||
import { metaTokenToCorrespondingStacksToken } from "../metaUtils/peggingHelpers"
|
import { metaTokenToCorrespondingStacksToken } from "../metaUtils/peggingHelpers"
|
||||||
import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContractDataMapping"
|
|
||||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||||
|
import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContractDataMapping"
|
||||||
import { addressToBuffer } from "../utils/addressHelpers"
|
import { addressToBuffer } from "../utils/addressHelpers"
|
||||||
import { BigNumber } from "../utils/BigNumber"
|
import { BigNumber } from "../utils/BigNumber"
|
||||||
import {
|
import {
|
||||||
@@ -263,7 +264,7 @@ async function bridgeFromEVM_toBitcoin(
|
|||||||
|
|
||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromEVM (to Bitcoin)"],
|
[SDK_NAME, "bridgeFromEVM (to Bitcoin)"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "toAddressScriptPubKey",
|
name: "toAddressScriptPubKey",
|
||||||
@@ -491,7 +492,7 @@ async function bridgeFromEVM_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromEVM (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromEVM (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -604,7 +605,7 @@ export async function bridgeFromEVM_toLaunchpad(
|
|||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromEVM_toLaunchpad (to ${_knownChainIdToErrorMessagePart(info.receiverChain)})`,
|
`bridgeFromEVM_toLaunchpad (to ${_knownChainIdToErrorMessagePart(info.receiverChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ import {
|
|||||||
BitcoinAddress,
|
BitcoinAddress,
|
||||||
getBitcoinHardLinkageAddress,
|
getBitcoinHardLinkageAddress,
|
||||||
} from "../bitcoinUtils/btcAddresses"
|
} from "../bitcoinUtils/btcAddresses"
|
||||||
import { BITCOIN_OUTPUT_MINIMUM_AMOUNT } from "../bitcoinUtils/constants"
|
import {
|
||||||
|
BITCOIN_OUTPUT_MINIMUM_AMOUNT,
|
||||||
|
SDK_NAME,
|
||||||
|
} from "../bitcoinUtils/constants"
|
||||||
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
import { createTransaction } from "../bitcoinUtils/createTransaction"
|
||||||
import {
|
import {
|
||||||
BitcoinTransactionPrepareResult,
|
BitcoinTransactionPrepareResult,
|
||||||
@@ -22,6 +25,7 @@ import {
|
|||||||
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
||||||
import { isSupportedRunesRoute } from "../metaUtils/peggingHelpers"
|
import { isSupportedRunesRoute } from "../metaUtils/peggingHelpers"
|
||||||
import { runesTokenToId } from "../metaUtils/tokenAddresses"
|
import { runesTokenToId } from "../metaUtils/tokenAddresses"
|
||||||
|
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||||
import { CreateBridgeOrderResult } from "../stacksUtils/createBridgeOrderFromBitcoin"
|
import { CreateBridgeOrderResult } from "../stacksUtils/createBridgeOrderFromBitcoin"
|
||||||
import {
|
import {
|
||||||
createBridgeOrder_MetaToBitcoin,
|
createBridgeOrder_MetaToBitcoin,
|
||||||
@@ -30,7 +34,6 @@ import {
|
|||||||
createBridgeOrder_MetaToStacks,
|
createBridgeOrder_MetaToStacks,
|
||||||
} from "../stacksUtils/createBridgeOrderFromMeta"
|
} from "../stacksUtils/createBridgeOrderFromMeta"
|
||||||
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
||||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
|
||||||
import { range } from "../utils/arrayHelpers"
|
import { range } from "../utils/arrayHelpers"
|
||||||
import { BigNumber } from "../utils/BigNumber"
|
import { BigNumber } from "../utils/BigNumber"
|
||||||
import {
|
import {
|
||||||
@@ -152,7 +155,7 @@ export async function bridgeFromRunes(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromRunes"],
|
[SDK_NAME, "bridgeFromRunes"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "fromAddressScriptPubKey",
|
name: "fromAddressScriptPubKey",
|
||||||
@@ -176,7 +179,7 @@ export async function bridgeFromRunes(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
["XLinkSDK", "bridgeFromRunes"],
|
[SDK_NAME, "bridgeFromRunes"],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "toAddressScriptPubKey",
|
name: "toAddressScriptPubKey",
|
||||||
@@ -399,7 +402,7 @@ async function bridgeFromRunes_toBitcoin(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -461,7 +464,7 @@ async function bridgeFromRunes_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`bridgeFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`bridgeFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -785,7 +788,7 @@ export async function prepareRunesTransaction(
|
|||||||
if (runeDivisibility == null) {
|
if (runeDivisibility == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`${methodName} (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`${methodName} (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -808,7 +811,7 @@ export async function prepareRunesTransaction(
|
|||||||
if (runeRawAmountToSend < runeRawAmountToPegIn) {
|
if (runeRawAmountToSend < runeRawAmountToPegIn) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`${methodName} (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`${methodName} (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContr
|
|||||||
import { isSupportedStacksRoute } from "../stacksUtils/peggingHelpers"
|
import { isSupportedStacksRoute } from "../stacksUtils/peggingHelpers"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
composeTxXLINK,
|
composeTxBro,
|
||||||
ContractCallOptions,
|
ContractCallOptions,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksTokenContractInfo,
|
getStacksTokenContractInfo,
|
||||||
@@ -147,7 +147,7 @@ async function bridgeFromStacks_toBitcoin(
|
|||||||
? btc.NETWORK
|
? btc.NETWORK
|
||||||
: btc.TEST_NETWORK
|
: btc.TEST_NETWORK
|
||||||
|
|
||||||
const options = composeTxXLINK(
|
const options = composeTxBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"request-peg-out-0",
|
"request-peg-out-0",
|
||||||
{
|
{
|
||||||
@@ -196,7 +196,7 @@ async function bridgeFromStacks_toEVM(
|
|||||||
evmToken: info.toToken,
|
evmToken: info.toToken,
|
||||||
})) ?? fromTokenContractInfo
|
})) ?? fromTokenContractInfo
|
||||||
|
|
||||||
const options = composeTxXLINK(
|
const options = composeTxBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"transfer-to-unwrap",
|
"transfer-to-unwrap",
|
||||||
{
|
{
|
||||||
@@ -246,7 +246,7 @@ async function bridgeFromStacks_toMeta(
|
|||||||
? btc.NETWORK
|
? btc.NETWORK
|
||||||
: btc.TEST_NETWORK
|
: btc.TEST_NETWORK
|
||||||
|
|
||||||
const options = composeTxXLINK(
|
const options = composeTxBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"request-peg-out",
|
"request-peg-out",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
import { getStacks2MetaFeeInfo } from "../metaUtils/peggingHelpers"
|
import { getStacks2MetaFeeInfo } from "../metaUtils/peggingHelpers"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
numberFromStacksContractNumber,
|
numberFromStacksContractNumber,
|
||||||
} from "../stacksUtils/contractHelpers"
|
} from "../stacksUtils/contractHelpers"
|
||||||
@@ -670,19 +670,19 @@ export async function bridgeInfoFromBitcoin_toLaunchpad(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const resp = await props({
|
const resp = await props({
|
||||||
isPaused: executeReadonlyCallXLINK(
|
isPaused: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"is-peg-in-paused",
|
"is-peg-in-paused",
|
||||||
{},
|
{},
|
||||||
contractCallInfo.executeOptions,
|
contractCallInfo.executeOptions,
|
||||||
),
|
),
|
||||||
feeRate: executeReadonlyCallXLINK(
|
feeRate: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"get-peg-in-fee",
|
"get-peg-in-fee",
|
||||||
{},
|
{},
|
||||||
contractCallInfo.executeOptions,
|
contractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
minFeeAmount: executeReadonlyCallXLINK(
|
minFeeAmount: executeReadonlyCallBro(
|
||||||
contractCallInfo.contractName,
|
contractCallInfo.contractName,
|
||||||
"get-peg-in-min-fee",
|
"get-peg-in-min-fee",
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { UTXOSpendable } from "../bitcoinHelpers"
|
import { UTXOSpendable } from "../bitcoinHelpers"
|
||||||
import { getBitcoinHardLinkageAddress } from "../bitcoinUtils/btcAddresses"
|
import { getBitcoinHardLinkageAddress } from "../bitcoinUtils/btcAddresses"
|
||||||
|
import { SDK_NAME } from "../bitcoinUtils/constants"
|
||||||
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
||||||
import { isSupportedBRC20Route } from "../metaUtils/peggingHelpers"
|
import { isSupportedBRC20Route } from "../metaUtils/peggingHelpers"
|
||||||
import {
|
import {
|
||||||
@@ -259,7 +260,7 @@ async function estimateFromBRC20_toBitcoin(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`estimateBridgeTransactionFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`estimateBridgeTransactionFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -316,7 +317,7 @@ async function estimateFromBRC20_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`estimateBridgeTransactionFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`estimateBridgeTransactionFromBRC20 (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
getBitcoinHardLinkageAddress,
|
getBitcoinHardLinkageAddress,
|
||||||
getBTCPegInAddress,
|
getBTCPegInAddress,
|
||||||
} from "../bitcoinUtils/btcAddresses"
|
} from "../bitcoinUtils/btcAddresses"
|
||||||
|
import { SDK_NAME } from "../bitcoinUtils/constants"
|
||||||
import { isSupportedBitcoinRoute } from "../bitcoinUtils/peggingHelpers"
|
import { isSupportedBitcoinRoute } from "../bitcoinUtils/peggingHelpers"
|
||||||
import {
|
import {
|
||||||
createBridgeOrder_BitcoinToEVM,
|
createBridgeOrder_BitcoinToEVM,
|
||||||
@@ -240,7 +241,7 @@ async function estimateFromBitcoin_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`estimateBridgeTransactionFromBitcoin (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`estimateBridgeTransactionFromBitcoin (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { getBitcoinHardLinkageAddress } from "../bitcoinUtils/btcAddresses"
|
import { getBitcoinHardLinkageAddress } from "../bitcoinUtils/btcAddresses"
|
||||||
|
import { SDK_NAME } from "../bitcoinUtils/constants"
|
||||||
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
import { getMetaPegInAddress } from "../metaUtils/btcAddresses"
|
||||||
import { isSupportedRunesRoute } from "../metaUtils/peggingHelpers"
|
import { isSupportedRunesRoute } from "../metaUtils/peggingHelpers"
|
||||||
import {
|
import {
|
||||||
@@ -260,7 +261,7 @@ async function estimateFromRunes_toBitcoin(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`estimateBridgeTransactionFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`estimateBridgeTransactionFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -317,7 +318,7 @@ async function estimateFromRunes_toMeta(
|
|||||||
if (info.toAddressScriptPubKey == null) {
|
if (info.toAddressScriptPubKey == null) {
|
||||||
throw new InvalidMethodParametersError(
|
throw new InvalidMethodParametersError(
|
||||||
[
|
[
|
||||||
"XLinkSDK",
|
SDK_NAME,
|
||||||
`estimateBridgeTransactionFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
`estimateBridgeTransactionFromRunes (to ${_knownChainIdToErrorMessagePart(info.toChain)})`,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { InvalidMethodParametersError } from "../utils/errors"
|
|||||||
type SDKBrandedLiteral<
|
type SDKBrandedLiteral<
|
||||||
Type extends string,
|
Type extends string,
|
||||||
T extends string | number,
|
T extends string | number,
|
||||||
> = `${T} (XLinkSDK ${Type})`
|
> = `${T} (BroSDK ${Type})`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a unique identifier for a blockchain network.
|
* Represents a unique identifier for a blockchain network.
|
||||||
@@ -63,7 +63,7 @@ export const isEVMAddress = isAddress
|
|||||||
export type RuneIdCombined = `${number}:${number}`
|
export type RuneIdCombined = `${number}:${number}`
|
||||||
|
|
||||||
export const evmNativeCurrencyAddress = Symbol(
|
export const evmNativeCurrencyAddress = Symbol(
|
||||||
"[XLinkSDK] EVM Native Currency Address",
|
"[BroSDK] EVM Native Currency Address",
|
||||||
)
|
)
|
||||||
export type EVMNativeCurrencyAddress = typeof evmNativeCurrencyAddress
|
export type EVMNativeCurrencyAddress = typeof evmNativeCurrencyAddress
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export interface ContractCallOptions {
|
|||||||
functionArgs: SerializedClarityValue[]
|
functionArgs: SerializedClarityValue[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _composeTxBrotocol = composeTxOptionsFactory(broContracts, {})
|
const _composeTxBro = composeTxOptionsFactory(broContracts, {})
|
||||||
export type ComposeTxOptionsFn<Contracts extends typeof broContracts> = <
|
export type ComposeTxOptionsFn<Contracts extends typeof broContracts> = <
|
||||||
T extends StringOnly<keyof Contracts>,
|
T extends StringOnly<keyof Contracts>,
|
||||||
F extends StringOnly<keyof Contracts[T]>,
|
F extends StringOnly<keyof Contracts[T]>,
|
||||||
@@ -78,10 +78,10 @@ export type ComposeTxOptionsFn<Contracts extends typeof broContracts> = <
|
|||||||
postConditions?: PC[]
|
postConditions?: PC[]
|
||||||
},
|
},
|
||||||
) => ContractCallOptions
|
) => ContractCallOptions
|
||||||
export const composeTxXLINK: ComposeTxOptionsFn<typeof broContracts> = (
|
export const composeTxBro: ComposeTxOptionsFn<typeof broContracts> = (
|
||||||
...args
|
...args
|
||||||
) => {
|
) => {
|
||||||
const options = _composeTxBrotocol(...args)
|
const options = _composeTxBro(...args)
|
||||||
return {
|
return {
|
||||||
...options,
|
...options,
|
||||||
functionArgs: options.functionArgs.map(arg => serializeCVBytes(arg)),
|
functionArgs: options.functionArgs.map(arg => serializeCVBytes(arg)),
|
||||||
@@ -91,7 +91,7 @@ export const composeTxXLINK: ComposeTxOptionsFn<typeof broContracts> = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const executeReadonlyCallXLINK = executeReadonlyCallFactory(
|
export const executeReadonlyCallBro = executeReadonlyCallFactory(
|
||||||
broContracts,
|
broContracts,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
|||||||
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
||||||
import { StacksContractName } from "./stxContractAddresses"
|
import { StacksContractName } from "./stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksTokenContractInfo,
|
getStacksTokenContractInfo,
|
||||||
numberToStacksContractNumber,
|
numberToStacksContractNumber,
|
||||||
@@ -272,7 +272,7 @@ async function createBridgeOrderFromBitcoinImpl(
|
|||||||
|
|
||||||
let data: undefined | Uint8Array
|
let data: undefined | Uint8Array
|
||||||
if (swapInfo == null) {
|
if (swapInfo == null) {
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractBaseCallInfo.contractName,
|
contractBaseCallInfo.contractName,
|
||||||
"create-order-cross-or-fail",
|
"create-order-cross-or-fail",
|
||||||
{
|
{
|
||||||
@@ -287,7 +287,7 @@ async function createBridgeOrderFromBitcoinImpl(
|
|||||||
contractBaseCallInfo.executeOptions,
|
contractBaseCallInfo.executeOptions,
|
||||||
).then(unwrapResponse)
|
).then(unwrapResponse)
|
||||||
} else if (swapInfo.via === "ALEX") {
|
} else if (swapInfo.via === "ALEX") {
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractSwapCallInfo.contractName,
|
contractSwapCallInfo.contractName,
|
||||||
"create-order-cross-swap-or-fail",
|
"create-order-cross-swap-or-fail",
|
||||||
{
|
{
|
||||||
@@ -330,7 +330,7 @@ async function createBridgeOrderFromBitcoinImpl(
|
|||||||
swapInfo,
|
swapInfo,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractAggCallInfo.contractName,
|
contractAggCallInfo.contractName,
|
||||||
"create-order-agg-or-fail",
|
"create-order-agg-or-fail",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { CreateBridgeOrderResult } from "./createBridgeOrderFromBitcoin"
|
|||||||
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
||||||
import { StacksContractName } from "./stxContractAddresses"
|
import { StacksContractName } from "./stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksTokenContractInfo,
|
getStacksTokenContractInfo,
|
||||||
numberToStacksContractNumber,
|
numberToStacksContractNumber,
|
||||||
@@ -268,7 +268,7 @@ async function createBridgeOrderFromMetaImpl(
|
|||||||
|
|
||||||
let data: undefined | Uint8Array
|
let data: undefined | Uint8Array
|
||||||
if (swapInfo == null) {
|
if (swapInfo == null) {
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractBaseCallInfo.contractName,
|
contractBaseCallInfo.contractName,
|
||||||
"create-order-cross-or-fail",
|
"create-order-cross-or-fail",
|
||||||
{
|
{
|
||||||
@@ -283,7 +283,7 @@ async function createBridgeOrderFromMetaImpl(
|
|||||||
contractBaseCallInfo.executeOptions,
|
contractBaseCallInfo.executeOptions,
|
||||||
).then(unwrapResponse)
|
).then(unwrapResponse)
|
||||||
} else if (swapInfo.via === "ALEX") {
|
} else if (swapInfo.via === "ALEX") {
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractSwapCallInfo.contractName,
|
contractSwapCallInfo.contractName,
|
||||||
"create-order-cross-swap-or-fail",
|
"create-order-cross-swap-or-fail",
|
||||||
{
|
{
|
||||||
@@ -326,7 +326,7 @@ async function createBridgeOrderFromMetaImpl(
|
|||||||
swapInfo,
|
swapInfo,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
data = await executeReadonlyCallXLINK(
|
data = await executeReadonlyCallBro(
|
||||||
contractAggCallInfo.contractName,
|
contractAggCallInfo.contractName,
|
||||||
"create-order-agg-or-fail",
|
"create-order-agg-or-fail",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { KnownChainId } from "../utils/types/knownIds"
|
|||||||
import { StacksContractAddress } from "../sdkUtils/types"
|
import { StacksContractAddress } from "../sdkUtils/types"
|
||||||
import { StacksContractName } from "./stxContractAddresses"
|
import { StacksContractName } from "./stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
} from "./contractHelpers"
|
} from "./contractHelpers"
|
||||||
import { checkNever } from "../utils/typeHelpers"
|
import { checkNever } from "../utils/typeHelpers"
|
||||||
@@ -54,7 +54,7 @@ export async function validateBridgeOrderFromBitcoin(info: {
|
|||||||
|
|
||||||
if (swapRoute == null || swapRoute.via === "ALEX") {
|
if (swapRoute == null || swapRoute.via === "ALEX") {
|
||||||
if (swapRoute == null || hasLength(swapRoute.swapPools, 0)) {
|
if (swapRoute == null || hasLength(swapRoute.swapPools, 0)) {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractBaseCallInfo.contractName,
|
contractBaseCallInfo.contractName,
|
||||||
"validate-tx-cross",
|
"validate-tx-cross",
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ export async function validateBridgeOrderFromBitcoin(info: {
|
|||||||
contractBaseCallInfo.executeOptions,
|
contractBaseCallInfo.executeOptions,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractSwapCallInfo.contractName,
|
contractSwapCallInfo.contractName,
|
||||||
"validate-tx-cross-swap",
|
"validate-tx-cross-swap",
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ export async function validateBridgeOrderFromBitcoin(info: {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (swapRoute.via === "evmDexAggregator") {
|
} else if (swapRoute.via === "evmDexAggregator") {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractAggCallInfo.contractName,
|
contractAggCallInfo.contractName,
|
||||||
"validate-tx-agg",
|
"validate-tx-agg",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { getChainIdNetworkType, KnownChainId } from "../utils/types/knownIds"
|
|||||||
import { StacksContractAddress } from "../sdkUtils/types"
|
import { StacksContractAddress } from "../sdkUtils/types"
|
||||||
import { StacksContractName } from "./stxContractAddresses"
|
import { StacksContractName } from "./stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
} from "./contractHelpers"
|
} from "./contractHelpers"
|
||||||
import { checkNever } from "../utils/typeHelpers"
|
import { checkNever } from "../utils/typeHelpers"
|
||||||
@@ -56,7 +56,7 @@ export async function validateBridgeOrderFromMeta(info: {
|
|||||||
|
|
||||||
if (swapRoute == null || swapRoute.via === "ALEX") {
|
if (swapRoute == null || swapRoute.via === "ALEX") {
|
||||||
if (swapRoute == null || hasLength(swapRoute.swapPools, 0)) {
|
if (swapRoute == null || hasLength(swapRoute.swapPools, 0)) {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractBaseCallInfo.contractName,
|
contractBaseCallInfo.contractName,
|
||||||
"validate-tx-cross",
|
"validate-tx-cross",
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ export async function validateBridgeOrderFromMeta(info: {
|
|||||||
contractBaseCallInfo.executeOptions,
|
contractBaseCallInfo.executeOptions,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractSwapCallInfo.contractName,
|
contractSwapCallInfo.contractName,
|
||||||
"validate-tx-cross-swap",
|
"validate-tx-cross-swap",
|
||||||
{
|
{
|
||||||
@@ -106,7 +106,7 @@ export async function validateBridgeOrderFromMeta(info: {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (swapRoute.via === "evmDexAggregator") {
|
} else if (swapRoute.via === "evmDexAggregator") {
|
||||||
resp = await executeReadonlyCallXLINK(
|
resp = await executeReadonlyCallBro(
|
||||||
contractAggCallInfo.contractName,
|
contractAggCallInfo.contractName,
|
||||||
"validate-tx-agg",
|
"validate-tx-agg",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
getPossibleEVMDexAggregatorSwapParameters_FromBitcoin,
|
getPossibleEVMDexAggregatorSwapParameters_FromBitcoin,
|
||||||
} from "./bitcoinUtils/swapHelpers"
|
} from "./bitcoinUtils/swapHelpers"
|
||||||
import { getALEXSwapParameters_FromEVM } from "./evmUtils/swapHelpers"
|
import { getALEXSwapParameters_FromEVM } from "./evmUtils/swapHelpers"
|
||||||
import { getXLinkSDKContext } from "./lowlevelUnstableInfos"
|
import { getSDKContext } from "./lowlevelUnstableInfos"
|
||||||
import {
|
import {
|
||||||
getALEXSwapParameters_FromMeta,
|
getALEXSwapParameters_FromMeta,
|
||||||
getPossibleEVMDexAggregatorSwapParameters_FromMeta,
|
getPossibleEVMDexAggregatorSwapParameters_FromMeta,
|
||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
} from "./utils/swapHelpers/getDexAggregatorRoutes"
|
} from "./utils/swapHelpers/getDexAggregatorRoutes"
|
||||||
import { checkNever } from "./utils/typeHelpers"
|
import { checkNever } from "./utils/typeHelpers"
|
||||||
import { KnownChainId, KnownTokenId } from "./utils/types/knownIds"
|
import { KnownChainId, KnownTokenId } from "./utils/types/knownIds"
|
||||||
import { XLinkSDK } from "./XLinkSDK"
|
import { BroSDK } from "./BroSDK"
|
||||||
import { SDKNumber, toSDKNumberOrUndefined } from "./sdkUtils/types"
|
import { SDKNumber, toSDKNumberOrUndefined } from "./sdkUtils/types"
|
||||||
|
|
||||||
export interface ALEXSwapParameters
|
export interface ALEXSwapParameters
|
||||||
@@ -31,11 +31,11 @@ export interface ALEXSwapParameters
|
|||||||
* It provides the required details to proceed with an ALEX swap, such as the
|
* It provides the required details to proceed with an ALEX swap, such as the
|
||||||
* tokens involved, and the amount to be swapped.
|
* tokens involved, and the amount to be swapped.
|
||||||
*
|
*
|
||||||
* @param sdk - The XLinkSDK instance
|
* @param sdk - The BroSDK instance
|
||||||
* @param info - The entire bridging route
|
* @param info - The entire bridging route
|
||||||
*/
|
*/
|
||||||
export async function getALEXSwapParameters(
|
export async function getALEXSwapParameters(
|
||||||
sdk: XLinkSDK,
|
sdk: BroSDK,
|
||||||
info: KnownRoute & {
|
info: KnownRoute & {
|
||||||
amount: SDKNumber
|
amount: SDKNumber
|
||||||
},
|
},
|
||||||
@@ -46,7 +46,7 @@ export async function getALEXSwapParameters(
|
|||||||
return
|
return
|
||||||
} else if (KnownChainId.isEVMChain(info.fromChain)) {
|
} else if (KnownChainId.isEVMChain(info.fromChain)) {
|
||||||
if (!KnownTokenId.isEVMToken(info.fromToken)) return
|
if (!KnownTokenId.isEVMToken(info.fromToken)) return
|
||||||
params = await getALEXSwapParameters_FromEVM(getXLinkSDKContext(sdk), {
|
params = await getALEXSwapParameters_FromEVM(getSDKContext(sdk), {
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
toChain: info.toChain as any,
|
toChain: info.toChain as any,
|
||||||
@@ -55,7 +55,7 @@ export async function getALEXSwapParameters(
|
|||||||
})
|
})
|
||||||
} else if (KnownChainId.isBitcoinChain(info.fromChain)) {
|
} else if (KnownChainId.isBitcoinChain(info.fromChain)) {
|
||||||
if (!KnownTokenId.isBitcoinToken(info.fromToken)) return
|
if (!KnownTokenId.isBitcoinToken(info.fromToken)) return
|
||||||
params = await getALEXSwapParameters_FromBitcoin(getXLinkSDKContext(sdk), {
|
params = await getALEXSwapParameters_FromBitcoin(getSDKContext(sdk), {
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
toChain: info.toChain as any,
|
toChain: info.toChain as any,
|
||||||
@@ -64,7 +64,7 @@ export async function getALEXSwapParameters(
|
|||||||
})
|
})
|
||||||
} else if (KnownChainId.isBRC20Chain(info.fromChain)) {
|
} else if (KnownChainId.isBRC20Chain(info.fromChain)) {
|
||||||
if (!KnownTokenId.isBRC20Token(info.fromToken)) return
|
if (!KnownTokenId.isBRC20Token(info.fromToken)) return
|
||||||
params = await getALEXSwapParameters_FromMeta(getXLinkSDKContext(sdk), {
|
params = await getALEXSwapParameters_FromMeta(getSDKContext(sdk), {
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
toChain: info.toChain as any,
|
toChain: info.toChain as any,
|
||||||
@@ -73,7 +73,7 @@ export async function getALEXSwapParameters(
|
|||||||
})
|
})
|
||||||
} else if (KnownChainId.isRunesChain(info.fromChain)) {
|
} else if (KnownChainId.isRunesChain(info.fromChain)) {
|
||||||
if (!KnownTokenId.isRunesToken(info.fromToken)) return
|
if (!KnownTokenId.isRunesToken(info.fromToken)) return
|
||||||
params = await getALEXSwapParameters_FromMeta(getXLinkSDKContext(sdk), {
|
params = await getALEXSwapParameters_FromMeta(getSDKContext(sdk), {
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
toChain: info.toChain as any,
|
toChain: info.toChain as any,
|
||||||
@@ -102,11 +102,11 @@ export interface EVMDexAggregatorSwapParameters
|
|||||||
* This function calculates and returns the necessary parameters for executing
|
* This function calculates and returns the necessary parameters for executing
|
||||||
* a swap through the aggregator
|
* a swap through the aggregator
|
||||||
*
|
*
|
||||||
* @param sdk - The XLinkSDK instance used for interacting with the blockchain.
|
* @param sdk - The BroSDK instance used for interacting with the blockchain.
|
||||||
* @param info - The entire bridging route
|
* @param info - The entire bridging route
|
||||||
*/
|
*/
|
||||||
export async function getPossibleEVMDexAggregatorSwapParameters(
|
export async function getPossibleEVMDexAggregatorSwapParameters(
|
||||||
sdk: XLinkSDK,
|
sdk: BroSDK,
|
||||||
info: KnownRoute & {
|
info: KnownRoute & {
|
||||||
amount: SDKNumber
|
amount: SDKNumber
|
||||||
},
|
},
|
||||||
@@ -123,7 +123,7 @@ export async function getPossibleEVMDexAggregatorSwapParameters(
|
|||||||
if (!KnownTokenId.isBitcoinToken(info.fromToken)) return []
|
if (!KnownTokenId.isBitcoinToken(info.fromToken)) return []
|
||||||
|
|
||||||
const res = await getPossibleEVMDexAggregatorSwapParameters_FromBitcoin(
|
const res = await getPossibleEVMDexAggregatorSwapParameters_FromBitcoin(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
{
|
{
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
@@ -146,7 +146,7 @@ export async function getPossibleEVMDexAggregatorSwapParameters(
|
|||||||
if (!KnownTokenId.isBRC20Token(info.fromToken)) return []
|
if (!KnownTokenId.isBRC20Token(info.fromToken)) return []
|
||||||
|
|
||||||
const res = await getPossibleEVMDexAggregatorSwapParameters_FromMeta(
|
const res = await getPossibleEVMDexAggregatorSwapParameters_FromMeta(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
{
|
{
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
@@ -169,7 +169,7 @@ export async function getPossibleEVMDexAggregatorSwapParameters(
|
|||||||
if (!KnownTokenId.isRunesToken(info.fromToken)) return []
|
if (!KnownTokenId.isRunesToken(info.fromToken)) return []
|
||||||
|
|
||||||
const res = await getPossibleEVMDexAggregatorSwapParameters_FromMeta(
|
const res = await getPossibleEVMDexAggregatorSwapParameters_FromMeta(
|
||||||
getXLinkSDKContext(sdk),
|
getSDKContext(sdk),
|
||||||
{
|
{
|
||||||
fromChain: info.fromChain,
|
fromChain: info.fromChain,
|
||||||
fromToken: info.fromToken,
|
fromToken: info.fromToken,
|
||||||
@@ -212,7 +212,7 @@ export interface DexAggregatorRoute
|
|||||||
slippage: SDKNumber
|
slippage: SDKNumber
|
||||||
}
|
}
|
||||||
export function getDexAggregatorRoutes(
|
export function getDexAggregatorRoutes(
|
||||||
sdk: XLinkSDK,
|
sdk: BroSDK,
|
||||||
info: {
|
info: {
|
||||||
routeFetcher: FetchRoutesImpl
|
routeFetcher: FetchRoutesImpl
|
||||||
routes: {
|
routes: {
|
||||||
@@ -224,7 +224,7 @@ export function getDexAggregatorRoutes(
|
|||||||
}[]
|
}[]
|
||||||
},
|
},
|
||||||
): Promise<DexAggregatorRoute[]> {
|
): Promise<DexAggregatorRoute[]> {
|
||||||
return _getDexAggregatorRoutes(getXLinkSDKContext(sdk), {
|
return _getDexAggregatorRoutes(getSDKContext(sdk), {
|
||||||
routeFetcher: info.routeFetcher,
|
routeFetcher: info.routeFetcher,
|
||||||
routes: info.routes.map(r => ({
|
routes: info.routes.map(r => ({
|
||||||
evmChain: r.evmChain,
|
evmChain: r.evmChain,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { evmTokenToCorrespondingStacksToken } from "../evmUtils/peggingHelpers"
|
|||||||
import { metaTokenToCorrespondingStacksToken } from "../metaUtils/peggingHelpers"
|
import { metaTokenToCorrespondingStacksToken } from "../metaUtils/peggingHelpers"
|
||||||
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
import { StacksContractName } from "../stacksUtils/stxContractAddresses"
|
||||||
import {
|
import {
|
||||||
executeReadonlyCallXLINK,
|
executeReadonlyCallBro,
|
||||||
getStacksContractCallInfo,
|
getStacksContractCallInfo,
|
||||||
getStacksToken,
|
getStacksToken,
|
||||||
numberFromStacksContractNumber,
|
numberFromStacksContractNumber,
|
||||||
@@ -382,14 +382,14 @@ export async function getSpecialFeeDetailsForSwapRoute(
|
|||||||
{
|
{
|
||||||
fromEVM: {
|
fromEVM: {
|
||||||
getFeeRate: () =>
|
getFeeRate: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
evmPegInContractCallInfo.contractName,
|
evmPegInContractCallInfo.contractName,
|
||||||
"get-peg-out-fee",
|
"get-peg-out-fee",
|
||||||
{},
|
{},
|
||||||
evmPegInContractCallInfo.executeOptions,
|
evmPegInContractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
getFixedFeeAmount: () =>
|
getFixedFeeAmount: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
evmPegInContractCallInfo.contractName,
|
evmPegInContractCallInfo.contractName,
|
||||||
"get-peg-out-gas-fee",
|
"get-peg-out-gas-fee",
|
||||||
{},
|
{},
|
||||||
@@ -427,14 +427,14 @@ export async function getSpecialFeeDetailsForSwapRoute(
|
|||||||
{
|
{
|
||||||
fromBitcoin: {
|
fromBitcoin: {
|
||||||
getFeeRate: () =>
|
getFeeRate: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
btcPegInSwapContractCallInfo.contractName,
|
btcPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-fee",
|
"get-peg-out-fee",
|
||||||
{},
|
{},
|
||||||
btcPegInSwapContractCallInfo.executeOptions,
|
btcPegInSwapContractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
getFixedFeeAmount: () =>
|
getFixedFeeAmount: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
btcPegInSwapContractCallInfo.contractName,
|
btcPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-gas-fee",
|
"get-peg-out-gas-fee",
|
||||||
{},
|
{},
|
||||||
@@ -443,14 +443,14 @@ export async function getSpecialFeeDetailsForSwapRoute(
|
|||||||
},
|
},
|
||||||
fromMeta: {
|
fromMeta: {
|
||||||
getFeeRate: () =>
|
getFeeRate: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
metaPegInSwapContractCallInfo.contractName,
|
metaPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-fee",
|
"get-peg-out-fee",
|
||||||
{},
|
{},
|
||||||
metaPegInSwapContractCallInfo.executeOptions,
|
metaPegInSwapContractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
getFixedFeeAmount: () =>
|
getFixedFeeAmount: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
metaPegInSwapContractCallInfo.contractName,
|
metaPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-gas-fee",
|
"get-peg-out-gas-fee",
|
||||||
{},
|
{},
|
||||||
@@ -459,14 +459,14 @@ export async function getSpecialFeeDetailsForSwapRoute(
|
|||||||
},
|
},
|
||||||
fromEVM: {
|
fromEVM: {
|
||||||
getFeeRate: () =>
|
getFeeRate: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
evmPegInSwapContractCallInfo.contractName,
|
evmPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-fee",
|
"get-peg-out-fee",
|
||||||
{},
|
{},
|
||||||
evmPegInSwapContractCallInfo.executeOptions,
|
evmPegInSwapContractCallInfo.executeOptions,
|
||||||
).then(numberFromStacksContractNumber),
|
).then(numberFromStacksContractNumber),
|
||||||
getFixedFeeAmount: () =>
|
getFixedFeeAmount: () =>
|
||||||
executeReadonlyCallXLINK(
|
executeReadonlyCallBro(
|
||||||
evmPegInSwapContractCallInfo.contractName,
|
evmPegInSwapContractCallInfo.contractName,
|
||||||
"get-peg-out-gas-fee",
|
"get-peg-out-gas-fee",
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -5,21 +5,21 @@ import {
|
|||||||
} from "./SwapRouteHelpers"
|
} from "./SwapRouteHelpers"
|
||||||
|
|
||||||
/** Extends the Error class and serves as the base for all custom errors within the SDK. */
|
/** Extends the Error class and serves as the base for all custom errors within the SDK. */
|
||||||
export class XLinkSDKErrorBase extends Error {
|
export class BroSDKErrorBase extends Error {
|
||||||
constructor(...args: ConstructorParameters<typeof Error>) {
|
constructor(...args: ConstructorParameters<typeof Error>) {
|
||||||
super(...args)
|
super(...args)
|
||||||
this.name = "XLinkSDKErrorBase"
|
this.name = "BroSDKErrorBase"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BridgeValidateFailedError extends XLinkSDKErrorBase {
|
export class BridgeValidateFailedError extends BroSDKErrorBase {
|
||||||
constructor(public cause: Error) {
|
constructor(public cause: Error) {
|
||||||
super("Bridge order validation failed", { cause })
|
super("Bridge order validation failed", { cause })
|
||||||
this.name = "BridgeValidateFailedError"
|
this.name = "BridgeValidateFailedError"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StacksAddressVersionNotSupportedError extends XLinkSDKErrorBase {
|
export class StacksAddressVersionNotSupportedError extends BroSDKErrorBase {
|
||||||
constructor(
|
constructor(
|
||||||
public address: string,
|
public address: string,
|
||||||
public versionName: string,
|
public versionName: string,
|
||||||
@@ -29,7 +29,7 @@ export class StacksAddressVersionNotSupportedError extends XLinkSDKErrorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TooFrequentlyError extends XLinkSDKErrorBase {
|
export class TooFrequentlyError extends BroSDKErrorBase {
|
||||||
constructor(
|
constructor(
|
||||||
public methodPath: string[],
|
public methodPath: string[],
|
||||||
public retryAfter?: number,
|
public retryAfter?: number,
|
||||||
@@ -46,7 +46,7 @@ export class TooFrequentlyError extends XLinkSDKErrorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** It is thrown when a method in the SDK receives invalid parameters. */
|
/** It is thrown when a method in the SDK receives invalid parameters. */
|
||||||
export class InvalidMethodParametersError extends XLinkSDKErrorBase {
|
export class InvalidMethodParametersError extends BroSDKErrorBase {
|
||||||
constructor(
|
constructor(
|
||||||
public methodPath: string[],
|
public methodPath: string[],
|
||||||
public params: {
|
public params: {
|
||||||
@@ -61,7 +61,7 @@ export class InvalidMethodParametersError extends XLinkSDKErrorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** It is thrown when an attempt is made to bridge tokens between unsupported chains in the SDK. */
|
/** It is thrown when an attempt is made to bridge tokens between unsupported chains in the SDK. */
|
||||||
export class UnsupportedBridgeRouteError extends XLinkSDKErrorBase {
|
export class UnsupportedBridgeRouteError extends BroSDKErrorBase {
|
||||||
constructor(
|
constructor(
|
||||||
public fromChain: ChainId,
|
public fromChain: ChainId,
|
||||||
public toChain: ChainId,
|
public toChain: ChainId,
|
||||||
@@ -77,14 +77,14 @@ export class UnsupportedBridgeRouteError extends XLinkSDKErrorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** It is thrown when a method in the SDK receives an unknown chain. */
|
/** It is thrown when a method in the SDK receives an unknown chain. */
|
||||||
export class UnsupportedChainError extends XLinkSDKErrorBase {
|
export class UnsupportedChainError extends BroSDKErrorBase {
|
||||||
constructor(public chain: ChainId) {
|
constructor(public chain: ChainId) {
|
||||||
super(`Unsupported chain: ${chain}`)
|
super(`Unsupported chain: ${chain}`)
|
||||||
this.name = "UnsupportedChainError"
|
this.name = "UnsupportedChainError"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** It is thrown when a smart contract is assigned an unknown or unsupported chain ID. */
|
/** It is thrown when a smart contract is assigned an unknown or unsupported chain ID. */
|
||||||
export class UnsupportedContractAssignedChainIdError extends XLinkSDKErrorBase {
|
export class UnsupportedContractAssignedChainIdError extends BroSDKErrorBase {
|
||||||
constructor(public chainId: bigint) {
|
constructor(public chainId: bigint) {
|
||||||
super(`Unsupported smart contract assigned chain id: ${chainId}`)
|
super(`Unsupported smart contract assigned chain id: ${chainId}`)
|
||||||
this.name = "UnsupportedContractAssignedChainIdError"
|
this.name = "UnsupportedContractAssignedChainIdError"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { SDK_NAME } from "../bitcoinUtils/constants"
|
||||||
import { BigNumber } from "./BigNumber"
|
import { BigNumber } from "./BigNumber"
|
||||||
import { concat, last, reduce } from "./arrayHelpers"
|
import { concat, last, reduce } from "./arrayHelpers"
|
||||||
import { checkNever, OneOrMore } from "./typeHelpers"
|
import { checkNever, OneOrMore } from "./typeHelpers"
|
||||||
@@ -35,7 +36,7 @@ export const applyTransferProphets = (
|
|||||||
exchangeRates.length < transferProphets.length - 1
|
exchangeRates.length < transferProphets.length - 1
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`[XLinkSDK#applyTransferProphets] exchangeRate count not match with transferProphet count, which is not expected`,
|
`[${SDK_NAME}#applyTransferProphets] exchangeRate count not match with transferProphet count, which is not expected`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ export const applyTransferProphet = (
|
|||||||
if (f.type === "rate") {
|
if (f.type === "rate") {
|
||||||
if (f.token !== transferProphet.bridgeToken) {
|
if (f.token !== transferProphet.bridgeToken) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`[XLinkSDK#applyTransferProphet] transferProphet.bridgeToken (${transferProphet.bridgeToken}) does not match rateFee.token (${f.token}), which is not expected`,
|
`[${SDK_NAME}#applyTransferProphet] transferProphet.bridgeToken (${transferProphet.bridgeToken}) does not match rateFee.token (${f.token}), which is not expected`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
feeAmount = BigNumber.max([
|
feeAmount = BigNumber.max([
|
||||||
@@ -133,7 +134,7 @@ export const composeTransferProphets = (
|
|||||||
exchangeRates.length < transferProphets.length - 1
|
exchangeRates.length < transferProphets.length - 1
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`[XLinkSDK#composeTransferProphets] exchangeRate count not match with transferProphet count, which is not expected`,
|
`[${SDK_NAME}#composeTransferProphets] exchangeRate count not match with transferProphet count, which is not expected`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { XLinkSDKErrorBase } from "./errors"
|
import { BroSDKErrorBase } from "./errors"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/wevm/viem/blob/d2f93e726df1ab1ff86098d68a4406f6fae315b8/src/utils/encoding/toBytes.ts#L150-L175
|
* https://github.com/wevm/viem/blob/d2f93e726df1ab1ff86098d68a4406f6fae315b8/src/utils/encoding/toBytes.ts#L150-L175
|
||||||
@@ -13,7 +13,7 @@ export function decodeHex(hex: string): Uint8Array {
|
|||||||
const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++))
|
const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++))
|
||||||
const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++))
|
const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++))
|
||||||
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
||||||
throw new XLinkSDKErrorBase(
|
throw new BroSDKErrorBase(
|
||||||
`Invalid byte sequence ("${hexString[j - 2]}${
|
`Invalid byte sequence ("${hexString[j - 2]}${
|
||||||
hexString[j - 1]
|
hexString[j - 1]
|
||||||
}" in "${hexString}").`,
|
}" in "${hexString}").`,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||||
import { arraySplit } from "../../arrayHelpers"
|
import { arraySplit } from "../../arrayHelpers"
|
||||||
import { BigNumber } from "../../BigNumber"
|
import { BigNumber } from "../../BigNumber"
|
||||||
import { XLinkSDKErrorBase } from "../../errors"
|
import { BroSDKErrorBase } from "../../errors"
|
||||||
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
||||||
|
|
||||||
export class FetchIceScreamSwapPossibleRoutesFailedError extends XLinkSDKErrorBase {
|
export class FetchIceScreamSwapPossibleRoutesFailedError extends BroSDKErrorBase {
|
||||||
constructor(message: null | string, options: ErrorConstructorOptions) {
|
constructor(message: null | string, options: ErrorConstructorOptions) {
|
||||||
super(message ?? "Request IceScreamSwap api failed", options)
|
super(message ?? "Request IceScreamSwap api failed", options)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||||
import { arraySplit } from "../../arrayHelpers"
|
import { arraySplit } from "../../arrayHelpers"
|
||||||
import { BigNumber } from "../../BigNumber"
|
import { BigNumber } from "../../BigNumber"
|
||||||
import { XLinkSDKErrorBase } from "../../errors"
|
import { BroSDKErrorBase } from "../../errors"
|
||||||
import { checkNever } from "../../typeHelpers"
|
import { checkNever } from "../../typeHelpers"
|
||||||
import { KnownChainId } from "../../types/knownIds"
|
import { KnownChainId } from "../../types/knownIds"
|
||||||
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
||||||
|
|
||||||
export class FetchKyberSwapPossibleRoutesFailedError extends XLinkSDKErrorBase {
|
export class FetchKyberSwapPossibleRoutesFailedError extends BroSDKErrorBase {
|
||||||
constructor(message: null | string, options: ErrorConstructorOptions) {
|
constructor(message: null | string, options: ErrorConstructorOptions) {
|
||||||
super(message ?? "Request KyberSwap api failed", options)
|
super(message ?? "Request KyberSwap api failed", options)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||||
import { arraySplit } from "../../arrayHelpers"
|
import { arraySplit } from "../../arrayHelpers"
|
||||||
import { BigNumber } from "../../BigNumber"
|
import { BigNumber } from "../../BigNumber"
|
||||||
import { XLinkSDKErrorBase } from "../../errors"
|
import { BroSDKErrorBase } from "../../errors"
|
||||||
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
import { FetchRoutesImpl, QueryableRoute } from "./helpers"
|
||||||
|
|
||||||
export class FetchMatchaPossibleRoutesFailedError extends XLinkSDKErrorBase {
|
export class FetchMatchaPossibleRoutesFailedError extends BroSDKErrorBase {
|
||||||
constructor(message: null | string, options: ErrorConstructorOptions) {
|
constructor(message: null | string, options: ErrorConstructorOptions) {
|
||||||
super(message ?? "Request 0x.org api failed", options)
|
super(message ?? "Request 0x.org api failed", options)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { SDK_NAME } from "../../bitcoinUtils/constants"
|
||||||
import {
|
import {
|
||||||
SDKNumber,
|
SDKNumber,
|
||||||
SDKNumberifyNestly,
|
SDKNumberifyNestly,
|
||||||
@@ -163,7 +164,7 @@ export const transformToPublicTransferProphetAggregated = (
|
|||||||
): PublicTransferProphetAggregated<PublicTransferProphet[]> => {
|
): PublicTransferProphetAggregated<PublicTransferProphet[]> => {
|
||||||
if (routes.length !== transferProphets.length) {
|
if (routes.length !== transferProphets.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`[XLinkSDK#transformToPublicTransferProphetAggregated2] route count not match with transferProphet count, which is not expected`,
|
`[${SDK_NAME}#transformToPublicTransferProphetAggregated2] route count not match with transferProphet count, which is not expected`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user