mirror of
https://github.com/Brotocol-xyz/bro-sdk.git
synced 2026-01-12 06:44:18 +08:00
refactor: rebrand to Brotocol [WIP]
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: [
|
||||
"./node_modules/@c4605/toolconfs/eslintrc.base",
|
||||
"./node_modules/@c4605/toolconfs/eslintrc.prettier",
|
||||
"./node_modules/@c4605/toolconfs/eslintrc.ts",
|
||||
],
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
},
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
@xlink-network:registry=https://npm.pkg.github.com
|
||||
@brotocol-xyz:registry=https://npm.pkg.github.com
|
||||
//npm.pkg.github.com/:_authToken=${GITHUB_NPM_KEY}
|
||||
@@ -1,2 +1,2 @@
|
||||
@xlink-network:registry=https://registry.npmjs.org/
|
||||
@brotocol-xyz:registry=https://registry.npmjs.org/
|
||||
//registry.npmjs.org/:_authToken=${NPM_KEY}
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = {
|
||||
...require("@c4605/toolconfs/prettierrc"),
|
||||
trailingComma: "all",
|
||||
semi: false,
|
||||
arrowParens: "avoid",
|
||||
singleQuote: false,
|
||||
}
|
||||
}
|
||||
|
||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -3,6 +3,7 @@
|
||||
"cSpell.words": [
|
||||
"abtc",
|
||||
"Bitlayer",
|
||||
"Brotocol",
|
||||
"Bsquared",
|
||||
"BTCB",
|
||||
"codegen",
|
||||
@@ -15,7 +16,6 @@
|
||||
"susdt",
|
||||
"txid",
|
||||
"UTXO",
|
||||
"viem",
|
||||
"xlink"
|
||||
"viem"
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@ This document explains the process for adding support for a new EVM token in the
|
||||
Adding support for a new EVM token requires modifying the following files:
|
||||
|
||||
1. `src/utils/types/knownIds.ts` - Add the new Token ID
|
||||
2. `src/evmUtils/xlinkContractHelpers.ts` - Add the token to the contract configuration
|
||||
2. `src/evmUtils/contractHelpers.ts` - Add the token to the contract configuration
|
||||
3. `src/stacksUtils/stxContractAddresses.ts` - Add contract addresses for the corresponding token on the Stacks chain
|
||||
|
||||
## Important Notice for Developers and AI Assistants
|
||||
@@ -47,9 +47,9 @@ export namespace KnownTokenId {
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Update Contract Configuration in xlinkContractHelpers.ts
|
||||
### 2. Update Contract Configuration in contractHelpers.ts
|
||||
|
||||
In the `src/evmUtils/xlinkContractHelpers.ts` file, you need to update the following sections:
|
||||
In the `src/evmUtils/contractHelpers.ts` file, you need to update the following sections:
|
||||
|
||||
1. Add a new token key to the `ONCHAIN_CONFIG_KEY` enum:
|
||||
|
||||
@@ -105,12 +105,12 @@ export const stxTokenContractAddresses_legacy: Record<
|
||||
[KnownTokenId.Stacks.TOKEN_NAME]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
// IMPORTANT: Use the exact addresses provided by the contract deployers
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-name", // This contract name must be obtained from the team
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
// IMPORTANT: Use the exact addresses provided by the contract deployers
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "token-name", // This contract name must be obtained from the team
|
||||
}),
|
||||
},
|
||||
@@ -127,7 +127,7 @@ Here's a real example of adding support for the ETH token:
|
||||
export const ETH = tokenId("stx-eth") // In Stacks namespace - same name as EVM
|
||||
```
|
||||
|
||||
2. Updating `xlinkContractHelpers.ts`:
|
||||
2. Updating `contractHelpers.ts`:
|
||||
```typescript
|
||||
// Add to enum - this key was provided by the contract deployers
|
||||
// Note that this is TOKEN_ETH, not just ETH
|
||||
@@ -148,11 +148,11 @@ Here's a real example of adding support for the ETH token:
|
||||
```typescript
|
||||
[KnownTokenId.Stacks.ETH]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-eth", // This name was provided by the team
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "token-eth", // This name was provided by the team
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
2. Add a `.npmrc` file to the project that needs to install this package (the `GITHUB_NPM_KEY' is an environment variable, which is the personal access token created in the previous step)
|
||||
```
|
||||
@xlink-network:registry=https://npm.pkg.github.com
|
||||
@brotocol-xyz:registry=https://npm.pkg.github.com
|
||||
//npm.pkg.github.com/:_authToken=${GITHUB_NPM_KEY}
|
||||
```
|
||||
|
||||
|
||||
74
eslint.config.mjs
Normal file
74
eslint.config.mjs
Normal file
@@ -0,0 +1,74 @@
|
||||
import prettierPlugin from "eslint-plugin-prettier"
|
||||
import prettierPluginRecommendedConfig from "eslint-plugin-prettier/recommended"
|
||||
import prettierConfig from "eslint-config-prettier"
|
||||
import tseslint from "typescript-eslint"
|
||||
|
||||
export default tseslint.config(
|
||||
prettierConfig,
|
||||
prettierPluginRecommendedConfig,
|
||||
tseslint.configs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
prettier: prettierPlugin,
|
||||
},
|
||||
rules: {
|
||||
"no-unused-vars": "off",
|
||||
"max-classes-per-file": "off",
|
||||
"no-shadow": "off",
|
||||
"no-extra-semi": "off",
|
||||
curly: ["error", "multi-line"],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.ts", "examples/**/*.ts", "examples/**/*.tsx"],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"@typescript-eslint/consistent-type-definitions": "off",
|
||||
"@typescript-eslint/no-empty-interface": "off",
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-parameter-properties": "off",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "off",
|
||||
"@typescript-eslint/no-extra-semi": "off",
|
||||
"@typescript-eslint/no-redeclare": [
|
||||
"off",
|
||||
{ ignoreDeclarationMerge: true },
|
||||
],
|
||||
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
args: "after-used",
|
||||
caughtErrors: "none",
|
||||
argsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
|
||||
"@typescript-eslint/explicit-member-accessibility": [
|
||||
"error",
|
||||
{
|
||||
accessibility: "no-public",
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-floating-promises": [
|
||||
"error",
|
||||
{
|
||||
ignoreVoid: true,
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/explicit-function-return-type": [
|
||||
"error",
|
||||
{
|
||||
allowExpressions: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "xlink-sdk-cross-chain-swap-example",
|
||||
"name": "bro-sdk-cross-chain-swap-example",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
@@ -15,7 +15,7 @@
|
||||
"@stacks/network": "^7.0.2",
|
||||
"@stacks/stacks-blockchain-api-types": "^7.14.1",
|
||||
"@stacks/transactions": "^7.0.5",
|
||||
"@xlink-network/xlink-sdk": "file:../..",
|
||||
"@brotocol-xyz/bro-sdk": "file:../..",
|
||||
"alex-sdk": "^3.2.0",
|
||||
"c32check": "^2.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
||||
56
examples/cross-chain-swap/pnpm-lock.yaml
generated
56
examples/cross-chain-swap/pnpm-lock.yaml
generated
@@ -8,6 +8,9 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@brotocol-xyz/bro-sdk':
|
||||
specifier: file:../..
|
||||
version: file:../..(@stacks/common@7.0.2)(typescript@5.8.2)
|
||||
'@stacks/common':
|
||||
specifier: ^7.0.2
|
||||
version: 7.0.2
|
||||
@@ -23,9 +26,6 @@ importers:
|
||||
'@stacks/transactions':
|
||||
specifier: ^7.0.5
|
||||
version: 7.0.5
|
||||
'@xlink-network/xlink-sdk':
|
||||
specifier: file:../..
|
||||
version: file:../..(@stacks/common@7.0.2)(typescript@5.8.2)
|
||||
alex-sdk:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0(@stacks/common@7.0.2)(@stacks/network@7.0.2)(@stacks/transactions@7.0.5)
|
||||
@@ -165,6 +165,9 @@ packages:
|
||||
resolution: {integrity: sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@brotocol-xyz/bro-sdk@file:../..':
|
||||
resolution: {directory: ../.., type: directory}
|
||||
|
||||
'@c4/btc-utils@0.3.1':
|
||||
resolution: {integrity: sha512-mhJ43BhjJP7KspiWZVNnvCy3VTmN8EksBiV+d49jVPBDwrj8dBGuhbv3aM+AVnIfq4Z0Ds6k6q2wkl/lKeNcOA==}
|
||||
|
||||
@@ -536,9 +539,6 @@ packages:
|
||||
peerDependencies:
|
||||
vite: ^4.2.0 || ^5.0.0 || ^6.0.0
|
||||
|
||||
'@xlink-network/xlink-sdk@file:../..':
|
||||
resolution: {directory: ../.., type: directory}
|
||||
|
||||
abitype@1.0.8:
|
||||
resolution: {integrity: sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg==}
|
||||
peerDependencies:
|
||||
@@ -1235,6 +1235,25 @@ snapshots:
|
||||
'@babel/helper-string-parser': 7.25.9
|
||||
'@babel/helper-validator-identifier': 7.25.9
|
||||
|
||||
'@brotocol-xyz/bro-sdk@file:../..(@stacks/common@7.0.2)(typescript@5.8.2)':
|
||||
dependencies:
|
||||
'@c4/btc-utils': 0.3.1
|
||||
'@scure/btc-signer': 1.7.0
|
||||
'@stacks/network': 7.0.2
|
||||
'@stacks/transactions': 7.0.5
|
||||
big.js: 6.2.2
|
||||
c32check: 2.0.0
|
||||
clarity-codegen: 1.1.3(@stacks/common@7.0.2)(@stacks/transactions@7.0.5)
|
||||
viem: 2.23.11(typescript@5.8.2)
|
||||
transitivePeerDependencies:
|
||||
- '@stacks/common'
|
||||
- bufferutil
|
||||
- debug
|
||||
- encoding
|
||||
- typescript
|
||||
- utf-8-validate
|
||||
- zod
|
||||
|
||||
'@c4/btc-utils@0.3.1':
|
||||
optionalDependencies:
|
||||
'@scure/btc-signer': 1.7.0
|
||||
@@ -1516,7 +1535,7 @@ snapshots:
|
||||
|
||||
'@types/bn.js@5.1.6':
|
||||
dependencies:
|
||||
'@types/node': 18.19.80
|
||||
'@types/node': 22.13.10
|
||||
|
||||
'@types/estree@1.0.6': {}
|
||||
|
||||
@@ -1533,7 +1552,6 @@ snapshots:
|
||||
'@types/node@22.13.10':
|
||||
dependencies:
|
||||
undici-types: 6.20.0
|
||||
optional: true
|
||||
|
||||
'@types/react-dom@19.0.4(@types/react@19.0.10)':
|
||||
dependencies:
|
||||
@@ -1554,25 +1572,6 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@xlink-network/xlink-sdk@file:../..(@stacks/common@7.0.2)(typescript@5.8.2)':
|
||||
dependencies:
|
||||
'@c4/btc-utils': 0.3.1
|
||||
'@scure/btc-signer': 1.7.0
|
||||
'@stacks/network': 7.0.2
|
||||
'@stacks/transactions': 7.0.5
|
||||
big.js: 6.2.2
|
||||
c32check: 2.0.0
|
||||
clarity-codegen: 1.1.3(@stacks/common@7.0.2)(@stacks/transactions@7.0.5)
|
||||
viem: 2.23.11(typescript@5.8.2)
|
||||
transitivePeerDependencies:
|
||||
- '@stacks/common'
|
||||
- bufferutil
|
||||
- debug
|
||||
- encoding
|
||||
- typescript
|
||||
- utf-8-validate
|
||||
- zod
|
||||
|
||||
abitype@1.0.8(typescript@5.8.2):
|
||||
optionalDependencies:
|
||||
typescript: 5.8.2
|
||||
@@ -2061,8 +2060,7 @@ snapshots:
|
||||
|
||||
undici-types@5.26.5: {}
|
||||
|
||||
undici-types@6.20.0:
|
||||
optional: true
|
||||
undici-types@6.20.0: {}
|
||||
|
||||
unload@2.2.0:
|
||||
dependencies:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { XLinkSDK } from "@xlink-network/xlink-sdk"
|
||||
import { XLinkSDK } from "@brotocol-xyz/bro-sdk"
|
||||
import { AlexSDK } from "alex-sdk"
|
||||
import { FC } from "react"
|
||||
import "./App.css"
|
||||
@@ -6,7 +6,7 @@ import { SwapRouteSelector } from "./components/SwapRouteSelector"
|
||||
import { QueryClient, QueryClientProvider } from "react-query"
|
||||
|
||||
const alex = new AlexSDK()
|
||||
const xlink = new XLinkSDK()
|
||||
const sdk = new XLinkSDK()
|
||||
const queryClient = new QueryClient()
|
||||
|
||||
const App: FC = () => {
|
||||
@@ -18,7 +18,7 @@ const App: FC = () => {
|
||||
</header>
|
||||
<main className="app-main">
|
||||
<div className="content-wrapper">
|
||||
<SwapRouteSelector alexSDK={alex} xlinkSDK={xlink} />
|
||||
<SwapRouteSelector alexSDK={alex} sdk={sdk} />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
SwapRoute_WithExchangeRate,
|
||||
toSDKNumberOrUndefined,
|
||||
XLinkSDK,
|
||||
} from "@xlink-network/xlink-sdk"
|
||||
} from "@brotocol-xyz/bro-sdk"
|
||||
import { AlexSDK } from "alex-sdk"
|
||||
import { FC, Fragment, useState } from "react"
|
||||
import { useQuery } from "react-query"
|
||||
@@ -17,8 +17,8 @@ import { getSwapRoutesViaEVMDEX } from "../utils/getSwapRoutesViaEVMDEX"
|
||||
|
||||
export const SwapRouteSelector: FC<{
|
||||
alexSDK: AlexSDK
|
||||
xlinkSDK: XLinkSDK
|
||||
}> = ({ alexSDK, xlinkSDK }) => {
|
||||
sdk: XLinkSDK
|
||||
}> = ({ alexSDK, sdk }) => {
|
||||
const [swapAmount, setSwapAmount] = useState("")
|
||||
const [selectedRoute, setSelectedRoute] = useState<null | KnownRoute>(null)
|
||||
const [selectedSwapRoute, setSelectedSwapRoute] =
|
||||
@@ -29,7 +29,7 @@ export const SwapRouteSelector: FC<{
|
||||
|
||||
const availableRoutes = useQuery({
|
||||
queryKey: ["availableRoutes"],
|
||||
queryFn: () => getAvailableRoutes(xlinkSDK),
|
||||
queryFn: () => getAvailableRoutes(sdk),
|
||||
})
|
||||
|
||||
const alexRoutes = useQuery({
|
||||
@@ -50,7 +50,7 @@ export const SwapRouteSelector: FC<{
|
||||
return getSwapRoutesViaALEX(
|
||||
{
|
||||
alexSDK: alexSDK,
|
||||
xlinkSDK: xlinkSDK,
|
||||
sdk: sdk,
|
||||
},
|
||||
{
|
||||
...debouncedRoute,
|
||||
@@ -78,7 +78,7 @@ export const SwapRouteSelector: FC<{
|
||||
|
||||
return getSwapRoutesViaEVMDEX(
|
||||
{
|
||||
xlinkSDK: xlinkSDK,
|
||||
sdk: sdk,
|
||||
},
|
||||
{
|
||||
...debouncedRoute,
|
||||
@@ -94,7 +94,9 @@ export const SwapRouteSelector: FC<{
|
||||
queryKey: [
|
||||
"bridgeInfo",
|
||||
JSON.stringify(selectedRoute),
|
||||
JSON.stringify(selectedSwapRoute),
|
||||
JSON.stringify(selectedSwapRoute, (k, v) =>
|
||||
typeof v === "bigint" ? `${v}` : v,
|
||||
),
|
||||
],
|
||||
queryFn: () => {
|
||||
if (selectedRoute == null) {
|
||||
@@ -105,7 +107,7 @@ export const SwapRouteSelector: FC<{
|
||||
}
|
||||
|
||||
if (KnownChainId.isBitcoinChain(selectedRoute.fromChain)) {
|
||||
return xlinkSDK.bridgeInfoFromBitcoin({
|
||||
return sdk.bridgeInfoFromBitcoin({
|
||||
...selectedRoute,
|
||||
swapRoute: selectedSwapRoute,
|
||||
amount: toSDKNumberOrUndefined(Number(swapAmount)),
|
||||
@@ -113,7 +115,7 @@ export const SwapRouteSelector: FC<{
|
||||
}
|
||||
|
||||
if (KnownChainId.isBRC20Chain(selectedRoute.fromChain)) {
|
||||
return xlinkSDK.bridgeInfoFromBRC20({
|
||||
return sdk.bridgeInfoFromBRC20({
|
||||
...selectedRoute,
|
||||
swapRoute: selectedSwapRoute,
|
||||
amount: toSDKNumberOrUndefined(Number(swapAmount)),
|
||||
@@ -121,7 +123,7 @@ export const SwapRouteSelector: FC<{
|
||||
}
|
||||
|
||||
if (KnownChainId.isRunesChain(selectedRoute.fromChain)) {
|
||||
return xlinkSDK.bridgeInfoFromRunes({
|
||||
return sdk.bridgeInfoFromRunes({
|
||||
...selectedRoute,
|
||||
swapRoute: selectedSwapRoute,
|
||||
amount: toSDKNumberOrUndefined(Number(swapAmount)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { KnownChainId } from "../../node_modules/@xlink-network/xlink-sdk/lib/utils/types/knownIds"
|
||||
import { KnownChainId } from "@brotocol-xyz/bro-sdk"
|
||||
|
||||
export const formatXLinkSDKChainName = (
|
||||
chain: KnownChainId.KnownChain,
|
||||
|
||||
@@ -3,12 +3,12 @@ import {
|
||||
KnownRoute,
|
||||
KnownTokenId,
|
||||
XLinkSDK,
|
||||
} from "@xlink-network/xlink-sdk"
|
||||
} from "@brotocol-xyz/bro-sdk"
|
||||
|
||||
export const getAvailableRoutes = async (
|
||||
xlinkSDK: XLinkSDK,
|
||||
sdk: XLinkSDK,
|
||||
): Promise<(KnownRoute & { fromTokenName: string; toTokenName: string })[]> => {
|
||||
const routes = await _getAvailableRoutes(xlinkSDK)
|
||||
const routes = await _getAvailableRoutes(sdk)
|
||||
return routes.map(
|
||||
(route): KnownRoute & { fromTokenName: string; toTokenName: string } =>
|
||||
({
|
||||
@@ -31,14 +31,14 @@ type ChainTokenPair = readonly [
|
||||
type AvailableRoute = readonly [from: ChainTokenPair, to: ChainTokenPair]
|
||||
|
||||
const _getAvailableRoutes = async (
|
||||
xlinkSDK: XLinkSDK,
|
||||
sdk: XLinkSDK,
|
||||
): Promise<AvailableRoute[]> => {
|
||||
const alexBrc20 = await xlinkSDK.brc20TickToBRC20Token(
|
||||
const alexBrc20 = await sdk.brc20TickToBRC20Token(
|
||||
KnownChainId.BRC20.Mainnet,
|
||||
"alex$",
|
||||
)
|
||||
|
||||
const ausdBrc20 = await xlinkSDK.brc20TickToBRC20Token(
|
||||
const ausdBrc20 = await sdk.brc20TickToBRC20Token(
|
||||
KnownChainId.BRC20.Mainnet,
|
||||
"ausd$",
|
||||
)
|
||||
|
||||
@@ -6,15 +6,15 @@ import {
|
||||
SwapRouteViaALEX_WithMinimumAmountsOut,
|
||||
toSDKNumberOrUndefined,
|
||||
XLinkSDK,
|
||||
} from "@xlink-network/xlink-sdk"
|
||||
import { getALEXSwapParameters } from "@xlink-network/xlink-sdk/swapHelpers"
|
||||
} from "@brotocol-xyz/bro-sdk"
|
||||
import { getALEXSwapParameters } from "@brotocol-xyz/bro-sdk/swapHelpers"
|
||||
import { AlexSDK } from "alex-sdk"
|
||||
import { sortBy, uniqBy } from "lodash-es"
|
||||
|
||||
export async function getSwapRoutesViaALEX(
|
||||
context: {
|
||||
alexSDK: AlexSDK
|
||||
xlinkSDK: XLinkSDK
|
||||
sdk: XLinkSDK
|
||||
},
|
||||
swapRequest: KnownRoute & {
|
||||
amount: SDKNumber
|
||||
@@ -28,9 +28,9 @@ export async function getSwapRoutesViaALEX(
|
||||
SwapRouteViaALEX_WithMinimumAmountsOut)[]
|
||||
}
|
||||
> {
|
||||
const { alexSDK, xlinkSDK } = context
|
||||
const { alexSDK, sdk } = context
|
||||
|
||||
const swapParameters = await getALEXSwapParameters(xlinkSDK, swapRequest)
|
||||
const swapParameters = await getALEXSwapParameters(sdk, swapRequest)
|
||||
if (swapParameters == null) {
|
||||
return { type: "failed", reason: "unsupported-route" }
|
||||
}
|
||||
@@ -43,11 +43,11 @@ export async function getSwapRoutesViaALEX(
|
||||
}
|
||||
|
||||
const [fromTokenAddress, toTokenAddress] = await Promise.all([
|
||||
xlinkSDK.stacksAddressFromStacksToken(
|
||||
sdk.stacksAddressFromStacksToken(
|
||||
swapParameters.stacksChain,
|
||||
swapParameters.fromToken,
|
||||
),
|
||||
xlinkSDK.stacksAddressFromStacksToken(
|
||||
sdk.stacksAddressFromStacksToken(
|
||||
swapParameters.stacksChain,
|
||||
swapParameters.toToken,
|
||||
),
|
||||
|
||||
@@ -5,16 +5,16 @@ import {
|
||||
SwapRouteViaEVMDexAggregator_WithMinimumAmountsOut,
|
||||
toSDKNumberOrUndefined,
|
||||
XLinkSDK,
|
||||
} from "@xlink-network/xlink-sdk"
|
||||
} from "@brotocol-xyz/bro-sdk"
|
||||
import {
|
||||
fetchIceScreamSwapPossibleRoutesFactory,
|
||||
fetchKyberSwapPossibleRoutesFactory,
|
||||
getDexAggregatorRoutes,
|
||||
getPossibleEVMDexAggregatorSwapParameters,
|
||||
} from "@xlink-network/xlink-sdk/swapHelpers"
|
||||
} from "@brotocol-xyz/bro-sdk/swapHelpers"
|
||||
|
||||
export async function getSwapRoutesViaEVMDEX(
|
||||
context: {
|
||||
xlinkSDK: XLinkSDK
|
||||
sdk: XLinkSDK
|
||||
},
|
||||
swapRequest: KnownRoute & {
|
||||
amount: SDKNumber
|
||||
@@ -28,16 +28,16 @@ export async function getSwapRoutesViaEVMDEX(
|
||||
SwapRouteViaEVMDexAggregator_WithMinimumAmountsOut)[]
|
||||
}
|
||||
> {
|
||||
const { xlinkSDK } = context
|
||||
const { sdk } = context
|
||||
|
||||
const possibleSwapParameters =
|
||||
await getPossibleEVMDexAggregatorSwapParameters(xlinkSDK, swapRequest)
|
||||
await getPossibleEVMDexAggregatorSwapParameters(sdk, swapRequest)
|
||||
if (possibleSwapParameters.length === 0) {
|
||||
return { type: "failed", reason: "unsupported-route" }
|
||||
}
|
||||
|
||||
const routes = await getDexAggregatorRoutes(xlinkSDK, {
|
||||
routeFetcher: fetchIceScreamSwapPossibleRoutesFactory({}),
|
||||
const routes = await getDexAggregatorRoutes(sdk, {
|
||||
routeFetcher: fetchKyberSwapPossibleRoutesFactory({}),
|
||||
routes: possibleSwapParameters.map(p => ({
|
||||
evmChain: p.evmChain,
|
||||
fromToken: p.fromToken,
|
||||
|
||||
@@ -4,7 +4,7 @@ import react from "@vitejs/plugin-react"
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: "/xlink-sdk-example/cross-chain-swap/",
|
||||
base: "/bro-sdk-example/cross-chain-swap/",
|
||||
server: {
|
||||
proxy: {
|
||||
"/api/matcha": {
|
||||
|
||||
32
generated/smartContract/contracts_bro.ts
Normal file
32
generated/smartContract/contracts_bro.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { defineContract } from "../smartContractHelpers/codegenImport";
|
||||
import { btcPegInEndpointV207 } from "./contract_bro_btc-peg-in-endpoint-v2-07"
|
||||
import { btcPegInEndpointV207Swap } from "./contract_bro_btc-peg-in-endpoint-v2-07-swap"
|
||||
import { btcPegInEndpointV207Agg } from "./contract_bro_btc-peg-in-endpoint-v2-07-agg"
|
||||
import { btcPegInEndpointV205Launchpad } from "./contract_bro_btc-peg-in-endpoint-v2-05-launchpad"
|
||||
import { btcPegOutEndpointV201 } from "./contract_bro_btc-peg-out-endpoint-v2-01"
|
||||
import { crossPegInEndpointV204 } from "./contract_bro_cross-peg-in-endpoint-v2-04"
|
||||
import { crossPegInEndpointV204Swap } from "./contract_bro_cross-peg-in-endpoint-v2-04-swap"
|
||||
import { crossPegOutEndpointV201 } from "./contract_bro_cross-peg-out-endpoint-v2-01"
|
||||
import { crossPegOutEndpointV201Agg } from "./contract_bro_cross-peg-out-endpoint-v2-01-agg"
|
||||
import { metaPegInEndpointV204 } from "./contract_bro_meta-peg-in-endpoint-v2-04"
|
||||
import { metaPegInEndpointV206Swap } from "./contract_bro_meta-peg-in-endpoint-v2-06-swap"
|
||||
import { metaPegInEndpointV206Agg } from "./contract_bro_meta-peg-in-endpoint-v2-06-agg"
|
||||
import { metaPegOutEndpointV204 } from "./contract_bro_meta-peg-out-endpoint-v2-04"
|
||||
|
||||
export const broContracts = defineContract({
|
||||
...btcPegInEndpointV207,
|
||||
...btcPegInEndpointV207Swap,
|
||||
...btcPegInEndpointV207Agg,
|
||||
...btcPegInEndpointV205Launchpad,
|
||||
...btcPegOutEndpointV201,
|
||||
...crossPegInEndpointV204,
|
||||
...crossPegInEndpointV204Swap,
|
||||
...crossPegOutEndpointV201,
|
||||
...crossPegOutEndpointV201Agg,
|
||||
...metaPegInEndpointV204,
|
||||
...metaPegInEndpointV206Swap,
|
||||
...metaPegInEndpointV206Agg,
|
||||
...metaPegOutEndpointV204
|
||||
});
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import { defineContract } from "../smartContractHelpers/codegenImport";
|
||||
import { btcPegInEndpointV207 } from "./contract_xlink_btc-peg-in-endpoint-v2-07"
|
||||
import { btcPegInEndpointV207Swap } from "./contract_xlink_btc-peg-in-endpoint-v2-07-swap"
|
||||
import { btcPegInEndpointV207Agg } from "./contract_xlink_btc-peg-in-endpoint-v2-07-agg"
|
||||
import { btcPegInEndpointV205Launchpad } from "./contract_xlink_btc-peg-in-endpoint-v2-05-launchpad"
|
||||
import { btcPegOutEndpointV201 } from "./contract_xlink_btc-peg-out-endpoint-v2-01"
|
||||
import { crossPegInEndpointV204 } from "./contract_xlink_cross-peg-in-endpoint-v2-04"
|
||||
import { crossPegInEndpointV204Swap } from "./contract_xlink_cross-peg-in-endpoint-v2-04-swap"
|
||||
import { crossPegOutEndpointV201 } from "./contract_xlink_cross-peg-out-endpoint-v2-01"
|
||||
import { crossPegOutEndpointV201Agg } from "./contract_xlink_cross-peg-out-endpoint-v2-01-agg"
|
||||
import { metaPegInEndpointV204 } from "./contract_xlink_meta-peg-in-endpoint-v2-04"
|
||||
import { metaPegInEndpointV206Swap } from "./contract_xlink_meta-peg-in-endpoint-v2-06-swap"
|
||||
import { metaPegInEndpointV206Agg } from "./contract_xlink_meta-peg-in-endpoint-v2-06-agg"
|
||||
import { metaPegOutEndpointV204 } from "./contract_xlink_meta-peg-out-endpoint-v2-04"
|
||||
|
||||
export const xlinkContracts = defineContract({
|
||||
...btcPegInEndpointV207,
|
||||
...btcPegInEndpointV207Swap,
|
||||
...btcPegInEndpointV207Agg,
|
||||
...btcPegInEndpointV205Launchpad,
|
||||
...btcPegOutEndpointV201,
|
||||
...crossPegInEndpointV204,
|
||||
...crossPegInEndpointV204Swap,
|
||||
...crossPegOutEndpointV201,
|
||||
...crossPegOutEndpointV201Agg,
|
||||
...metaPegInEndpointV204,
|
||||
...metaPegInEndpointV206Swap,
|
||||
...metaPegInEndpointV206Agg,
|
||||
...metaPegOutEndpointV204
|
||||
});
|
||||
|
||||
|
||||
26
package.json
26
package.json
@@ -1,17 +1,16 @@
|
||||
{
|
||||
"name": "@xlink-network/xlink-sdk",
|
||||
"name": "@brotocol-xyz/bro-sdk",
|
||||
"version": "0.4.3",
|
||||
"description": "XLINK js SDK",
|
||||
"description": "Brotocol js SDK",
|
||||
"packageManager": "pnpm@9.9.0",
|
||||
"keywords": [
|
||||
"bitcoin",
|
||||
"ethereum",
|
||||
"stacks",
|
||||
"XLINK",
|
||||
"alexlab"
|
||||
"brotocol"
|
||||
],
|
||||
"repository": "github:xlink-network/xlink-sdk",
|
||||
"author": "c4605 <yuntao@alexgo.io>",
|
||||
"repository": "github:brotocol-xyz/bro-sdk",
|
||||
"author": "c4605",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"lib",
|
||||
@@ -57,23 +56,22 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@c4/btc-utils": "^0.3.1",
|
||||
"c32check": "^2.0.0",
|
||||
"clarity-codegen": "^1.1.3",
|
||||
"@scure/btc-signer": "^1.2.2",
|
||||
"@stacks/network": "^7.0.2",
|
||||
"@stacks/transactions": "^7.0.5",
|
||||
"big.js": "^6.2.2",
|
||||
"c32check": "^2.0.0",
|
||||
"clarity-codegen": "^1.1.3",
|
||||
"viem": "^2.23.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@c4605/toolconfs": "^5.3.0",
|
||||
"@stacks/stacks-blockchain-api-types": "^7.14.1",
|
||||
"@types/big.js": "^6.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^7.5.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
||||
"@typescript-eslint/parser": "^8.24.0",
|
||||
"eslint": "^9.20.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.3",
|
||||
"prettier": "^3.2.5",
|
||||
"tsup": "^8.4.0",
|
||||
"tsx": "^4.19.3",
|
||||
|
||||
800
pnpm-lock.yaml
generated
800
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,8 @@ import {
|
||||
import {
|
||||
StacksContractName,
|
||||
stxContractAddresses,
|
||||
xlinkContractsMultisigMainnet,
|
||||
xlinkContractsMultisigTestnet,
|
||||
contractsMultisigMainnet,
|
||||
contractsMultisigTestnet,
|
||||
} from "../src/stacksUtils/stxContractAddresses"
|
||||
import { KnownChainId } from "../src/utils/types/knownIds"
|
||||
|
||||
@@ -23,8 +23,8 @@ const envName = process.env.ENV_NAME === "dev" ? "dev" : "prod"
|
||||
: KnownChainId.Stacks.Testnet
|
||||
const fallbackDeployerAddress =
|
||||
envName === "prod"
|
||||
? xlinkContractsMultisigMainnet
|
||||
: xlinkContractsMultisigTestnet
|
||||
? contractsMultisigMainnet
|
||||
: contractsMultisigTestnet
|
||||
const fallbackStacksNetwork =
|
||||
envName === "prod" ? STACKS_MAINNET : STACKS_TESTNET
|
||||
|
||||
@@ -53,7 +53,7 @@ const envName = process.env.ENV_NAME === "dev" ? "dev" : "prod"
|
||||
"meta-peg-out-endpoint-v2-04",
|
||||
],
|
||||
path.resolve(__dirname, "../generated/smartContract/"),
|
||||
"xlink",
|
||||
"bro",
|
||||
"../smartContractHelpers/codegenImport",
|
||||
envName === "prod"
|
||||
? contractNameOverrides_mainnet
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { XLinkSDK } from "../src"
|
||||
import { getAllAddresses } from "../src/evmUtils/xlinkContractHelpers"
|
||||
import { getAllAddresses } from "../src/evmUtils/contractHelpers"
|
||||
import { getXLinkSDKContext } from "../src/lowlevelUnstableInfos"
|
||||
import { _allKnownEVMChains } from "../src/utils/types/knownIds"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
getEVMContractCallInfo,
|
||||
getEVMToken,
|
||||
getEVMTokenContractInfo,
|
||||
} from "./evmUtils/xlinkContractHelpers"
|
||||
} from "./evmUtils/contractHelpers"
|
||||
import { getBRC20SupportedRoutes } from "./metaUtils/apiHelpers/getBRC20SupportedRoutes"
|
||||
import { getRunesSupportedRoutes } from "./metaUtils/apiHelpers/getRunesSupportedRoutes"
|
||||
import {
|
||||
@@ -23,7 +23,7 @@ import { isSupportedStacksRoute } from "./stacksUtils/peggingHelpers"
|
||||
import {
|
||||
getStacksToken,
|
||||
getStacksTokenContractInfo,
|
||||
} from "./stacksUtils/xlinkContractHelpers"
|
||||
} from "./stacksUtils/contractHelpers"
|
||||
import { TooManyRequestsError } from "./utils/apiHelpers"
|
||||
import {
|
||||
DefinedRoute,
|
||||
@@ -41,37 +41,37 @@ import {
|
||||
BridgeFromBitcoinInput,
|
||||
BridgeFromBitcoinOutput,
|
||||
bridgeFromBitcoin,
|
||||
} from "./xlinkSdkUtils/bridgeFromBitcoin"
|
||||
} from "./sdkUtils/bridgeFromBitcoin"
|
||||
import {
|
||||
BridgeFromBRC20Input,
|
||||
BridgeFromBRC20Output,
|
||||
bridgeFromBRC20,
|
||||
} from "./xlinkSdkUtils/bridgeFromBRC20"
|
||||
} from "./sdkUtils/bridgeFromBRC20"
|
||||
import {
|
||||
BridgeFromEVMInput,
|
||||
BridgeFromEVMOutput,
|
||||
bridgeFromEVM,
|
||||
} from "./xlinkSdkUtils/bridgeFromEVM"
|
||||
} from "./sdkUtils/bridgeFromEVM"
|
||||
import {
|
||||
BridgeFromRunesInput,
|
||||
BridgeFromRunesOutput,
|
||||
bridgeFromRunes,
|
||||
} from "./xlinkSdkUtils/bridgeFromRunes"
|
||||
} from "./sdkUtils/bridgeFromRunes"
|
||||
import {
|
||||
BridgeFromStacksInput,
|
||||
BridgeFromStacksOutput,
|
||||
bridgeFromStacks,
|
||||
} from "./xlinkSdkUtils/bridgeFromStacks"
|
||||
} from "./sdkUtils/bridgeFromStacks"
|
||||
import {
|
||||
BridgeInfoFromBitcoinInput,
|
||||
BridgeInfoFromBitcoinOutput,
|
||||
bridgeInfoFromBitcoin,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromBitcoin"
|
||||
} from "./sdkUtils/bridgeInfoFromBitcoin"
|
||||
import {
|
||||
BridgeInfoFromEVMInput,
|
||||
BridgeInfoFromEVMOutput,
|
||||
bridgeInfoFromEVM,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromEVM"
|
||||
} from "./sdkUtils/bridgeInfoFromEVM"
|
||||
import {
|
||||
BridgeInfoFromBRC20Input,
|
||||
BridgeInfoFromBRC20Output,
|
||||
@@ -79,27 +79,27 @@ import {
|
||||
BridgeInfoFromRunesOutput,
|
||||
bridgeInfoFromBRC20,
|
||||
bridgeInfoFromRunes,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromMeta"
|
||||
} from "./sdkUtils/bridgeInfoFromMeta"
|
||||
import {
|
||||
BridgeInfoFromStacksInput,
|
||||
BridgeInfoFromStacksOutput,
|
||||
bridgeInfoFromStacks,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromStacks"
|
||||
} from "./sdkUtils/bridgeInfoFromStacks"
|
||||
import {
|
||||
EstimateBridgeTransactionFromBitcoinInput,
|
||||
EstimateBridgeTransactionFromBitcoinOutput,
|
||||
estimateBridgeTransactionFromBitcoin,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromBitcoin"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromBitcoin"
|
||||
import {
|
||||
EstimateBridgeTransactionFromBRC20Input,
|
||||
EstimateBridgeTransactionFromBRC20Output,
|
||||
estimateBridgeTransactionFromBRC20,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromBRC20"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromBRC20"
|
||||
import {
|
||||
EstimateBridgeTransactionFromRunesInput,
|
||||
EstimateBridgeTransactionFromRunesOutput,
|
||||
estimateBridgeTransactionFromRunes,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromRunes"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromRunes"
|
||||
import {
|
||||
ClaimTimeLockedAssetsInput,
|
||||
ClaimTimeLockedAssetsOutput,
|
||||
@@ -107,7 +107,7 @@ import {
|
||||
GetTimeLockedAssetsOutput,
|
||||
claimTimeLockedAssetsFromEVM,
|
||||
getTimeLockedAssetsFromEVM,
|
||||
} from "./xlinkSdkUtils/timelockFromEVM"
|
||||
} from "./sdkUtils/timelockFromEVM"
|
||||
import {
|
||||
ChainId,
|
||||
EVMAddress,
|
||||
@@ -116,8 +116,8 @@ import {
|
||||
RuneIdCombined,
|
||||
StacksContractAddress,
|
||||
evmNativeCurrencyAddress,
|
||||
} from "./xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "./xlinkSdkUtils/types.internal"
|
||||
} from "./sdkUtils/types"
|
||||
import { SDKGlobalContext } from "./sdkUtils/types.internal"
|
||||
import { DumpableCache, getCacheInside } from "./utils/DumpableCache"
|
||||
import { isNotNull } from "./utils/typeHelpers"
|
||||
import { SwapRoute } from "./utils/SwapRouteHelpers"
|
||||
@@ -131,64 +131,64 @@ export {
|
||||
BridgeFromBitcoinInput_signPsbtFn,
|
||||
BridgeFromBitcoinInput_reselectSpendableUTXOs,
|
||||
BridgeFromBitcoinOutput,
|
||||
} from "./xlinkSdkUtils/bridgeFromBitcoin"
|
||||
} from "./sdkUtils/bridgeFromBitcoin"
|
||||
export {
|
||||
BridgeFromBRC20Input,
|
||||
BridgeFromBRC20Input_signPsbtFn,
|
||||
BridgeFromBRC20Input_reselectSpendableNetworkFeeUTXOs,
|
||||
BridgeFromBRC20Output,
|
||||
} from "./xlinkSdkUtils/bridgeFromBRC20"
|
||||
} from "./sdkUtils/bridgeFromBRC20"
|
||||
export {
|
||||
BridgeFromEVMInput,
|
||||
BridgeFromEVMOutput,
|
||||
} from "./xlinkSdkUtils/bridgeFromEVM"
|
||||
} from "./sdkUtils/bridgeFromEVM"
|
||||
export {
|
||||
BridgeFromRunesInput,
|
||||
BridgeFromRunesInput_signPsbtFn,
|
||||
BridgeFromRunesInput_reselectSpendableNetworkFeeUTXOs,
|
||||
BridgeFromRunesOutput,
|
||||
RunesUTXOSpendable,
|
||||
} from "./xlinkSdkUtils/bridgeFromRunes"
|
||||
} from "./sdkUtils/bridgeFromRunes"
|
||||
export {
|
||||
BridgeFromStacksInput,
|
||||
BridgeFromStacksOutput,
|
||||
} from "./xlinkSdkUtils/bridgeFromStacks"
|
||||
} from "./sdkUtils/bridgeFromStacks"
|
||||
export {
|
||||
BridgeInfoFromBitcoinInput,
|
||||
BridgeInfoFromBitcoinOutput,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromBitcoin"
|
||||
} from "./sdkUtils/bridgeInfoFromBitcoin"
|
||||
export {
|
||||
BridgeInfoFromEVMInput,
|
||||
BridgeInfoFromEVMOutput,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromEVM"
|
||||
} from "./sdkUtils/bridgeInfoFromEVM"
|
||||
export {
|
||||
BridgeInfoFromBRC20Input,
|
||||
BridgeInfoFromBRC20Output,
|
||||
BridgeInfoFromRunesInput,
|
||||
BridgeInfoFromRunesOutput,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromMeta"
|
||||
} from "./sdkUtils/bridgeInfoFromMeta"
|
||||
export {
|
||||
BridgeInfoFromStacksInput,
|
||||
BridgeInfoFromStacksOutput,
|
||||
} from "./xlinkSdkUtils/bridgeInfoFromStacks"
|
||||
} from "./sdkUtils/bridgeInfoFromStacks"
|
||||
export {
|
||||
EstimateBridgeTransactionFromBitcoinInput,
|
||||
EstimateBridgeTransactionFromBitcoinOutput,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromBitcoin"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromBitcoin"
|
||||
export {
|
||||
EstimateBridgeTransactionFromBRC20Input,
|
||||
EstimateBridgeTransactionFromBRC20Output,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromBRC20"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromBRC20"
|
||||
export {
|
||||
EstimateBridgeTransactionFromRunesInput,
|
||||
EstimateBridgeTransactionFromRunesOutput,
|
||||
} from "./xlinkSdkUtils/estimateBridgeTransactionFromRunes"
|
||||
} from "./sdkUtils/estimateBridgeTransactionFromRunes"
|
||||
export {
|
||||
ClaimTimeLockedAssetsInput,
|
||||
ClaimTimeLockedAssetsOutput,
|
||||
GetTimeLockedAssetsInput,
|
||||
GetTimeLockedAssetsOutput,
|
||||
} from "./xlinkSdkUtils/timelockFromEVM"
|
||||
} from "./sdkUtils/timelockFromEVM"
|
||||
export type { DumpableCache } from "./utils/DumpableCache"
|
||||
|
||||
export interface XLinkSDKOptions {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { toHex } from "viem"
|
||||
import { requestAPI } from "../../utils/apiHelpers"
|
||||
import { KnownChainId } from "../../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export async function broadcastRevealableTransaction(
|
||||
sdkContext: Pick<SDKGlobalContext, "backendAPI">,
|
||||
@@ -14,7 +14,7 @@ export async function broadcastRevealableTransaction(
|
||||
orderData: Uint8Array
|
||||
orderOutputIndex: number
|
||||
orderOutputSatsAmount: bigint
|
||||
xlinkPegInAddress: {
|
||||
pegInAddress: {
|
||||
address: string
|
||||
scriptPubKey: Uint8Array
|
||||
}
|
||||
@@ -32,8 +32,8 @@ export async function broadcastRevealableTransaction(
|
||||
orderOutputIndex: info.orderOutputIndex,
|
||||
orderOutputSatoshiAmount: info.orderOutputSatsAmount.toString(),
|
||||
xlinkPegInAddress: {
|
||||
address: info.xlinkPegInAddress.address,
|
||||
scriptPubKeyHex: toHex(info.xlinkPegInAddress.scriptPubKey),
|
||||
address: info.pegInAddress.address,
|
||||
scriptPubKeyHex: toHex(info.pegInAddress.scriptPubKey),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import { BigNumber } from "../../utils/BigNumber"
|
||||
import { UnsupportedBridgeRouteError } from "../../utils/errors"
|
||||
import { decodeHex } from "../../utils/hexHelpers"
|
||||
import { KnownChainId, KnownTokenId } from "../../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
import { getBTCPegInAddress } from "../btcAddresses"
|
||||
import { BITCOIN_OUTPUT_MINIMUM_AMOUNT } from "../constants"
|
||||
import { calculateFee } from "../prepareTransaction"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { toHex } from "viem"
|
||||
import { requestAPI } from "../../utils/apiHelpers"
|
||||
import { KnownChainId } from "../../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export async function createRevealTx(
|
||||
sdkContext: Pick<SDKGlobalContext, "backendAPI">,
|
||||
@@ -14,7 +14,7 @@ export async function createRevealTx(
|
||||
vout: number
|
||||
satsAmount: bigint
|
||||
orderData: Uint8Array
|
||||
xlinkPegInAddress: {
|
||||
pegInAddress: {
|
||||
address: string
|
||||
scriptPubKey: Uint8Array
|
||||
}
|
||||
@@ -32,8 +32,8 @@ export async function createRevealTx(
|
||||
satsAmount: info.satsAmount,
|
||||
orderDataHex: toHex(info.orderData),
|
||||
xlinkPegInAddress: {
|
||||
address: info.xlinkPegInAddress.address,
|
||||
scriptPubKeyHex: toHex(info.xlinkPegInAddress.scriptPubKey),
|
||||
address: info.pegInAddress.address,
|
||||
scriptPubKeyHex: toHex(info.pegInAddress.scriptPubKey),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksTokenContractInfo,
|
||||
numberFromStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
IsSupportedFn,
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
import {
|
||||
SDKGlobalContext,
|
||||
withGlobalContextCache,
|
||||
} from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types.internal"
|
||||
import { getBTCPegInAddress } from "./btcAddresses"
|
||||
|
||||
export const getBtc2StacksFeeInfo = async (
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
RuneIdCombined,
|
||||
SDKNumber,
|
||||
toSDKNumberOrUndefined,
|
||||
} from "../xlinkSdkUtils/types"
|
||||
} from "../sdkUtils/types"
|
||||
import { UTXOSpendable } from "./bitcoinHelpers"
|
||||
|
||||
export class NotEnoughRunesError extends Error {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { sortBy } from "../utils/arrayHelpers"
|
||||
import { MAX_BIGINT, sum } from "../utils/bigintHelpers"
|
||||
import { decodeHex } from "../utils/hexHelpers"
|
||||
import { isNotNull } from "../utils/typeHelpers"
|
||||
import { ReselectSpendableUTXOsFn_Public } from "../xlinkSdkUtils/bridgeFromBitcoin"
|
||||
import { ReselectSpendableUTXOsFn_Public } from "../sdkUtils/bridgeFromBitcoin"
|
||||
import {
|
||||
isSameUTXO,
|
||||
sumUTXO,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
EVMDexAggregatorSwapParameters,
|
||||
getPossibleEVMDexAggregatorSwapParametersImpl,
|
||||
} from "../utils/swapHelpers/evmDexAggregatorSwapParametersHelpers"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { getBtc2StacksFeeInfo } from "./peggingHelpers"
|
||||
|
||||
export async function getALEXSwapParameters_FromBitcoin(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { getStacksToken } from "../../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksToken } from "../../stacksUtils/contractHelpers"
|
||||
import { requestAPI } from "../../utils/apiHelpers"
|
||||
import { BigNumber } from "../../utils/BigNumber"
|
||||
import { isNotNull } from "../../utils/typeHelpers"
|
||||
import { KnownChainId, KnownTokenId } from "../../utils/types/knownIds"
|
||||
import { StacksContractAddress } from "../../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { StacksContractAddress } from "../../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export interface EVMSupportedRoute {
|
||||
evmChain: KnownChainId.EVMChain
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
EVMAddress,
|
||||
EVMNativeCurrencyAddress,
|
||||
evmNativeCurrencyAddress,
|
||||
} from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { BridgeConfigAbi } from "./contractAbi/bridgeConfig"
|
||||
import {
|
||||
EVMEndpointContract,
|
||||
@@ -303,11 +303,16 @@ function maybeAddress(value: string | null): Address | undefined {
|
||||
}
|
||||
|
||||
enum ONCHAIN_CONFIG_KEY {
|
||||
/**
|
||||
* https://t.me/c/1599543687/57298
|
||||
*/
|
||||
ENDPOINT = "ENDPOINT",
|
||||
ENDPOINT_NATIVE = "ENDPOINT_NATIVE",
|
||||
REGISTRY = "REGISTRY",
|
||||
TIMELOCK = "TIMELOCK",
|
||||
MULTISIG = "MULTISIG",
|
||||
MIGRATE = "MIGRATE",
|
||||
MIGRATE_BOB = "MIGRATE_BOB",
|
||||
MIGRATE_BOB_L2 = "MIGRATE_BOB_L2",
|
||||
MIGRATE_BOB_L2_S = "MIGRATE_BOB_L2_S",
|
||||
|
||||
TOKEN_ABTC = "TOKEN_ABTC",
|
||||
TOKEN_ALEX = "TOKEN_ALEX",
|
||||
TOKEN_ATALEX = "TOKEN_ATALEX",
|
||||
@@ -319,35 +324,12 @@ enum ONCHAIN_CONFIG_KEY {
|
||||
TOKEN_SUSDT = "TOKEN_SUSDT",
|
||||
TOKEN_DB20 = "TOKEN_DB20",
|
||||
TOKEN_DOG = "TOKEN_DOG",
|
||||
TIMELOCK = "TIMELOCK",
|
||||
MULTISIG = "MULTISIG",
|
||||
MIGRATE = "MIGRATE",
|
||||
MIGRATE_BOB = "MIGRATE_BOB",
|
||||
MIGRATE_BOB_L2 = "MIGRATE_BOB_L2",
|
||||
MIGRATE_BOB_L2_S = "MIGRATE_BOB_L2_S",
|
||||
|
||||
// https://github.com/xlink-network/xlink/blob/9e6e268d820f2f9756ca15a36f8580e4f98c087e/packages/contracts/bridge-solidity/scripts/params.ts
|
||||
ENDPOINT_NATIVE = "ENDPOINT_NATIVE",
|
||||
|
||||
// https://github.com/xlink-network/xlink/pull/299/commits/22b23c9ff3ea65eeb7c632db4255afe803f97fef#diff-8302902f9863ee3c7928a0fa6eb6ca22edd10f5553708459cdd072c1ea3ef696
|
||||
TOKEN_UBTC = "TOKEN_UBTC",
|
||||
TOKEN_WUBTC = "TOKEN_WUBTC",
|
||||
|
||||
// https://github.com/xlink-network/xlink/pull/366/files#diff-84d6042780ec5ce60f8e5349d20baf5f577f9d878feb8a703748ad37a91e31fd
|
||||
TOKEN_STX = "TOKEN_STX",
|
||||
|
||||
// https://t.me/c/1599543687/69562
|
||||
TOKEN_TRUMP = "TOKEN_TRUMP",
|
||||
|
||||
// https://t.me/c/1599543687/73009
|
||||
TOKEN_GHIBLICZ = "TOKEN_GHIBLICZ",
|
||||
|
||||
// https://t.me/c/1599543687/73347
|
||||
TOKEN_ETH = "TOKEN_ETH",
|
||||
|
||||
// https://t.me/c/1599543687/73387
|
||||
TOKEN_SOL = "TOKEN_SOL",
|
||||
|
||||
// https://t.me/c/1599543687/73476
|
||||
TOKEN_LINK = "TOKEN_LINK",
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksTokenContractInfo,
|
||||
numberFromStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
getAndCheckTransitStacksTokens,
|
||||
@@ -37,11 +37,11 @@ import {
|
||||
evmNativeCurrencyAddress,
|
||||
isStacksContractAddressEqual,
|
||||
StacksContractAddress,
|
||||
} from "../xlinkSdkUtils/types"
|
||||
} from "../sdkUtils/types"
|
||||
import {
|
||||
SDKGlobalContext,
|
||||
withGlobalContextCache,
|
||||
} from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types.internal"
|
||||
import {
|
||||
getEVMSupportedRoutes,
|
||||
getEVMSupportedRoutesByChainType,
|
||||
@@ -52,7 +52,7 @@ import {
|
||||
getEVMContractCallInfo,
|
||||
getEVMTokenContractInfo,
|
||||
numberFromSolidityContractNumber,
|
||||
} from "./xlinkContractHelpers"
|
||||
} from "./contractHelpers"
|
||||
|
||||
export const getEvm2StacksFeeInfo = async (
|
||||
ctx: SDKGlobalContext,
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ALEXSwapParameters,
|
||||
getALEXSwapParametersImpl,
|
||||
} from "../utils/swapHelpers/alexSwapParametersHelpers"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { getEvm2StacksFeeInfo } from "./peggingHelpers"
|
||||
|
||||
export async function getALEXSwapParameters_FromEVM(
|
||||
|
||||
@@ -12,7 +12,7 @@ export {
|
||||
StacksContractAddress,
|
||||
PublicEVMContractType as EVMContractType,
|
||||
RuneIdCombined,
|
||||
} from "./xlinkSdkUtils/types"
|
||||
} from "./sdkUtils/types"
|
||||
export {
|
||||
SwapRoute,
|
||||
SwapRoute_WithMinimumAmountsToReceive_Public as SwapRoute_WithMinimumAmountsOut,
|
||||
@@ -24,7 +24,7 @@ export {
|
||||
SwapRouteViaEVMDexAggregator_WithMinimumAmountsToReceive_Public as SwapRouteViaEVMDexAggregator_WithMinimumAmountsOut,
|
||||
SwapRouteViaEVMDexAggregator_WithExchangeRate_Public as SwapRouteViaEVMDexAggregator_WithExchangeRate,
|
||||
} from "./utils/SwapRouteHelpers"
|
||||
export { TimeLockedAsset } from "./xlinkSdkUtils/timelockFromEVM"
|
||||
export { TimeLockedAsset } from "./sdkUtils/timelockFromEVM"
|
||||
export {
|
||||
PublicTransferProphet as TransferProphet,
|
||||
PublicTransferProphetAggregated as TransferProphetAggregated,
|
||||
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
metaTokenToCorrespondingStacksToken,
|
||||
} from "./metaUtils/peggingHelpers"
|
||||
import { KnownChainId, KnownTokenId } from "./utils/types/knownIds"
|
||||
import { StacksContractAddress } from "./xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "./xlinkSdkUtils/types.internal"
|
||||
import { StacksContractAddress } from "./sdkUtils/types"
|
||||
import { SDKGlobalContext } from "./sdkUtils/types.internal"
|
||||
|
||||
export {
|
||||
contractAssignedChainIdFromKnownChain,
|
||||
@@ -30,10 +30,10 @@ export {
|
||||
legacyAlexContractDeployerMainnet,
|
||||
legacyAlexContractDeployerTestnet,
|
||||
wrapContractAddress,
|
||||
xlinkContractsDeployerMainnet,
|
||||
xlinkContractsDeployerTestnet,
|
||||
xlinkContractsMultisigMainnet,
|
||||
xlinkContractsMultisigTestnet,
|
||||
contractsDeployerMainnet as brotocolContractsDeployerMainnet,
|
||||
contractsDeployerTestnet as brotocolContractsDeployerTestnet,
|
||||
contractsMultisigMainnet as brotocolContractsMultisigMainnet,
|
||||
contractsMultisigTestnet as brotocolContractsMultisigTestnet,
|
||||
} from "./stacksUtils/stxContractAddresses"
|
||||
|
||||
export {
|
||||
@@ -74,9 +74,9 @@ export {
|
||||
|
||||
export { addressFromBuffer, addressToBuffer } from "./utils/addressHelpers"
|
||||
|
||||
export { bridgeFromEVM_toLaunchpad } from "./xlinkSdkUtils/bridgeFromEVM"
|
||||
export { bridgeInfoFromEVM_toLaunchpad } from "./xlinkSdkUtils/bridgeInfoFromEVM"
|
||||
export { bridgeInfoFromBitcoin_toLaunchpad } from "./xlinkSdkUtils/bridgeInfoFromBitcoin"
|
||||
export { bridgeFromEVM_toLaunchpad } from "./sdkUtils/bridgeFromEVM"
|
||||
export { bridgeInfoFromEVM_toLaunchpad } from "./sdkUtils/bridgeInfoFromEVM"
|
||||
export { bridgeInfoFromBitcoin_toLaunchpad } from "./sdkUtils/bridgeInfoFromBitcoin"
|
||||
|
||||
export { getBitcoinHardLinkageAddress } from "./bitcoinUtils/btcAddresses"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getStacksToken } from "../../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksToken } from "../../stacksUtils/contractHelpers"
|
||||
import { requestAPI } from "../../utils/apiHelpers"
|
||||
import { BigNumber } from "../../utils/BigNumber"
|
||||
import { isNotNull } from "../../utils/typeHelpers"
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
KnownChainId,
|
||||
createBRC20Token,
|
||||
} from "../../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export interface BRC20SupportedRoute {
|
||||
brc20Tick: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getStacksToken } from "../../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksToken } from "../../stacksUtils/contractHelpers"
|
||||
import { requestAPI } from "../../utils/apiHelpers"
|
||||
import { BigNumber } from "../../utils/BigNumber"
|
||||
import { isNotNull } from "../../utils/typeHelpers"
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
KnownChainId,
|
||||
KnownTokenId,
|
||||
} from "../../utils/types/knownIds"
|
||||
import { RuneIdCombined } from "../../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { RuneIdCombined } from "../../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export interface RunesSupportedRoute {
|
||||
runesId: RuneIdCombined
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
executeReadonlyCallXLINK,
|
||||
getStacksContractCallInfo,
|
||||
numberFromStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
getAndCheckTransitStacksTokens,
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
import {
|
||||
SDKGlobalContext,
|
||||
withGlobalContextCache,
|
||||
} from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types.internal"
|
||||
import { getBRC20SupportedRoutes } from "./apiHelpers/getBRC20SupportedRoutes"
|
||||
import { getRunesSupportedRoutes } from "./apiHelpers/getRunesSupportedRoutes"
|
||||
import { getMetaPegInAddress } from "./btcAddresses"
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
getPossibleEVMDexAggregatorSwapParametersImpl,
|
||||
} from "../utils/swapHelpers/evmDexAggregatorSwapParametersHelpers"
|
||||
import { KnownChainId, KnownTokenId } from "../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { getMeta2StacksFeeInfo } from "./peggingHelpers"
|
||||
|
||||
export async function getALEXSwapParameters_FromMeta(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { KnownChainId, KnownTokenId } from "../utils/types/knownIds"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { getRunesSupportedRoutes } from "./apiHelpers/getRunesSupportedRoutes"
|
||||
import { getBRC20SupportedRoutes } from "./apiHelpers/getBRC20SupportedRoutes"
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { RuneIdCombined, toSDKNumberOrUndefined } from "./xlinkSdkUtils/types"
|
||||
import { RuneIdCombined, toSDKNumberOrUndefined } from "./sdkUtils/types"
|
||||
import {
|
||||
GetAvailableRuneUTXOFn as _GetAvailableRuneUTXOFn,
|
||||
RuneInfo,
|
||||
selectRuneUTXOs as _selectRuneUTXOs,
|
||||
} from "./bitcoinUtils/selectRuneUTXOs"
|
||||
import { SDKNumber } from "./xlinkSdkUtils/types"
|
||||
import { SDKNumber } from "./sdkUtils/types"
|
||||
import { UTXOSpendable } from "./bitcoinHelpers"
|
||||
import { BigNumber } from "./utils/BigNumber"
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
createBridgeOrder_MetaToStacks,
|
||||
} from "../stacksUtils/createBridgeOrderFromMeta"
|
||||
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||
import { range } from "../utils/arrayHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
@@ -641,7 +641,7 @@ async function broadcastBRC20Transaction(
|
||||
orderData: createdOrder.data,
|
||||
orderOutputIndex: tx.revealOutput.index,
|
||||
orderOutputSatsAmount: tx.revealOutput.satsAmount,
|
||||
xlinkPegInAddress: pegInAddress,
|
||||
pegInAddress: pegInAddress,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -656,7 +656,7 @@ async function broadcastBRC20Transaction(
|
||||
|
||||
if (apiBroadcastedTxId !== delegateBroadcastedTxId) {
|
||||
console.warn(
|
||||
"[xlink-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
"[bro-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
`API: ${apiBroadcastedTxId}, `,
|
||||
`Delegatee: ${delegateBroadcastedTxId}`,
|
||||
)
|
||||
@@ -723,7 +723,7 @@ async function constructBRC20Transaction(
|
||||
vout: txOptions.revealOutput.index,
|
||||
satsAmount: txOptions.revealOutput.satsAmount,
|
||||
orderData: info.orderData,
|
||||
xlinkPegInAddress: info.pegInAddress,
|
||||
pegInAddress: info.pegInAddress,
|
||||
})
|
||||
|
||||
await info
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
createBridgeOrder_BitcoinToStacks,
|
||||
} from "../stacksUtils/createBridgeOrderFromBitcoin"
|
||||
import { validateBridgeOrderFromBitcoin } from "../stacksUtils/validateBridgeOrderFromBitcoin"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||
import { range } from "../utils/arrayHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
@@ -462,7 +462,7 @@ async function broadcastBitcoinTransaction(
|
||||
orderData: createdOrder.data,
|
||||
orderOutputIndex: tx.revealOutput.index,
|
||||
orderOutputSatsAmount: tx.revealOutput.satsAmount,
|
||||
xlinkPegInAddress: pegInAddress,
|
||||
pegInAddress: pegInAddress,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -477,7 +477,7 @@ async function broadcastBitcoinTransaction(
|
||||
|
||||
if (apiBroadcastedTxId !== delegateBroadcastedTxId) {
|
||||
console.warn(
|
||||
"[xlink-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
"[bro-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
`API: ${apiBroadcastedTxId}, `,
|
||||
`Delegatee: ${delegateBroadcastedTxId}`,
|
||||
)
|
||||
@@ -539,7 +539,7 @@ async function constructBitcoinTransaction(
|
||||
vout: txOptions.revealOutput.index,
|
||||
satsAmount: txOptions.revealOutput.satsAmount,
|
||||
orderData: info.orderData,
|
||||
xlinkPegInAddress: info.pegInAddress,
|
||||
pegInAddress: info.pegInAddress,
|
||||
})
|
||||
|
||||
await info
|
||||
@@ -8,10 +8,10 @@ import {
|
||||
getEVMContractCallInfo,
|
||||
getEVMTokenContractInfo,
|
||||
numberToSolidityContractNumber,
|
||||
} from "../evmUtils/xlinkContractHelpers"
|
||||
} from "../evmUtils/contractHelpers"
|
||||
import { metaTokenToCorrespondingStacksToken } from "../metaUtils/peggingHelpers"
|
||||
import { contractAssignedChainIdFromKnownChain } from "../stacksUtils/crossContractDataMapping"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||
import { addressToBuffer } from "../utils/addressHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
createBridgeOrder_MetaToStacks,
|
||||
} from "../stacksUtils/createBridgeOrderFromMeta"
|
||||
import { validateBridgeOrderFromMeta } from "../stacksUtils/validateBridgeOrderFromMeta"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/xlinkContractHelpers"
|
||||
import { getStacksTokenContractInfo } from "../stacksUtils/contractHelpers"
|
||||
import { range } from "../utils/arrayHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
@@ -583,7 +583,7 @@ async function broadcastRunesTransaction(
|
||||
orderData: createdOrder.data,
|
||||
orderOutputIndex: tx.revealOutput.index,
|
||||
orderOutputSatsAmount: tx.revealOutput.satsAmount,
|
||||
xlinkPegInAddress: pegInAddress,
|
||||
pegInAddress: pegInAddress,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -598,7 +598,7 @@ async function broadcastRunesTransaction(
|
||||
|
||||
if (apiBroadcastedTxId !== delegateBroadcastedTxId) {
|
||||
console.warn(
|
||||
"[xlink-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
"[bro-sdk] Transaction id broadcasted by API and delegatee are different:",
|
||||
`API: ${apiBroadcastedTxId}, `,
|
||||
`Delegatee: ${delegateBroadcastedTxId}`,
|
||||
)
|
||||
@@ -669,7 +669,7 @@ async function constructRunesTransaction(
|
||||
vout: txOptions.revealOutput.index,
|
||||
satsAmount: txOptions.revealOutput.satsAmount,
|
||||
orderData: info.orderData,
|
||||
xlinkPegInAddress: info.pegInAddress,
|
||||
pegInAddress: info.pegInAddress,
|
||||
})
|
||||
|
||||
await info
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksTokenContractInfo,
|
||||
numberToStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import {
|
||||
checkRouteValid,
|
||||
KnownRoute_FromStacks_ToBitcoin,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
executeReadonlyCallXLINK,
|
||||
getStacksContractCallInfo,
|
||||
numberFromStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import {
|
||||
getAndCheckTransitStacksTokens,
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
getEVMContractCallInfo,
|
||||
getEVMTokenContractInfo,
|
||||
numberFromSolidityContractNumber,
|
||||
} from "../evmUtils/xlinkContractHelpers"
|
||||
} from "../evmUtils/contractHelpers"
|
||||
import { BigNumber } from "../utils/BigNumber"
|
||||
import { UnsupportedChainError } from "../utils/errors"
|
||||
import { decodeHex } from "../utils/hexHelpers"
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
createStacksToken,
|
||||
KnownTokenId,
|
||||
} from "../../utils/types/knownIds"
|
||||
import { StacksContractAddress } from "../../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { StacksContractAddress } from "../../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
|
||||
export interface StacksTokenInfo {
|
||||
stacksTokenId: KnownTokenId.StacksToken
|
||||
|
||||
@@ -13,15 +13,15 @@ import {
|
||||
ParameterObjOfDescriptor,
|
||||
StringOnly,
|
||||
} from "clarity-codegen"
|
||||
import { xlinkContracts } from "../../generated/smartContract/contracts_xlink"
|
||||
import { broContracts } from "../../generated/smartContract/contracts_bro"
|
||||
import { STACKS_MAINNET, STACKS_TESTNET } from "../config"
|
||||
import { BigNumber, BigNumberSource } from "../utils/BigNumber"
|
||||
import { KnownChainId, KnownTokenId } from "../utils/types/knownIds"
|
||||
import {
|
||||
isStacksContractAddressEqual,
|
||||
StacksContractAddress,
|
||||
} from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { BigNumber, BigNumberSource } from "../utils/BigNumber"
|
||||
import { KnownChainId, KnownTokenId } from "../utils/types/knownIds"
|
||||
import { getAllStacksTokens } from "./apiHelpers/getAllStacksTokens"
|
||||
import {
|
||||
StacksContractName,
|
||||
@@ -61,8 +61,8 @@ export interface ContractCallOptions {
|
||||
functionArgs: SerializedClarityValue[]
|
||||
}
|
||||
|
||||
const _composeTxXLINK = composeTxOptionsFactory(xlinkContracts, {})
|
||||
export type ComposeTxOptionsFn<Contracts extends typeof xlinkContracts> = <
|
||||
const _composeTxBrotocol = composeTxOptionsFactory(broContracts, {})
|
||||
export type ComposeTxOptionsFn<Contracts extends typeof broContracts> = <
|
||||
T extends StringOnly<keyof Contracts>,
|
||||
F extends StringOnly<keyof Contracts[T]>,
|
||||
Descriptor extends Contracts[T][F],
|
||||
@@ -78,10 +78,10 @@ export type ComposeTxOptionsFn<Contracts extends typeof xlinkContracts> = <
|
||||
postConditions?: PC[]
|
||||
},
|
||||
) => ContractCallOptions
|
||||
export const composeTxXLINK: ComposeTxOptionsFn<typeof xlinkContracts> = (
|
||||
export const composeTxXLINK: ComposeTxOptionsFn<typeof broContracts> = (
|
||||
...args
|
||||
) => {
|
||||
const options = _composeTxXLINK(...args)
|
||||
const options = _composeTxBrotocol(...args)
|
||||
return {
|
||||
...options,
|
||||
functionArgs: options.functionArgs.map(arg => serializeCVBytes(arg)),
|
||||
@@ -92,7 +92,7 @@ export const composeTxXLINK: ComposeTxOptionsFn<typeof xlinkContracts> = (
|
||||
}
|
||||
|
||||
export const executeReadonlyCallXLINK = executeReadonlyCallFactory(
|
||||
xlinkContracts,
|
||||
broContracts,
|
||||
{},
|
||||
)
|
||||
|
||||
@@ -22,8 +22,8 @@ import {
|
||||
EVMAddress,
|
||||
isEVMAddress,
|
||||
StacksContractAddress,
|
||||
} from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
} from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
||||
import { StacksContractName } from "./stxContractAddresses"
|
||||
import {
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksTokenContractInfo,
|
||||
numberToStacksContractNumber,
|
||||
} from "./xlinkContractHelpers"
|
||||
} from "./contractHelpers"
|
||||
|
||||
export interface BridgeSwapRouteNode {
|
||||
poolId: bigint
|
||||
|
||||
@@ -20,8 +20,8 @@ import {
|
||||
KnownChainId,
|
||||
KnownTokenId,
|
||||
} from "../utils/types/knownIds"
|
||||
import { EVMAddress } from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { EVMAddress } from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { CreateBridgeOrderResult } from "./createBridgeOrderFromBitcoin"
|
||||
import { contractAssignedChainIdFromKnownChain } from "./crossContractDataMapping"
|
||||
import { StacksContractName } from "./stxContractAddresses"
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksTokenContractInfo,
|
||||
numberToStacksContractNumber,
|
||||
} from "./xlinkContractHelpers"
|
||||
} from "./contractHelpers"
|
||||
|
||||
export async function createBridgeOrderFromMeta(
|
||||
sdkContext: SDKGlobalContext,
|
||||
|
||||
@@ -3,16 +3,16 @@ import {
|
||||
contractNameOverrides_testnet,
|
||||
} from "../config"
|
||||
import { KnownChainId, KnownTokenId } from "../utils/types/knownIds"
|
||||
import { StacksContractAddress } from "../xlinkSdkUtils/types"
|
||||
import { StacksContractAddress } from "../sdkUtils/types"
|
||||
|
||||
export const xlinkContractsDeployerMainnet =
|
||||
export const contractsDeployerMainnet =
|
||||
"SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK"
|
||||
export const xlinkContractsDeployerTestnet =
|
||||
export const contractsDeployerTestnet =
|
||||
"ST2QXSK64YQX3CQPC530K79XWQ98XFAM9W3XKEH3N"
|
||||
|
||||
export const xlinkContractsMultisigMainnet =
|
||||
export const contractsMultisigMainnet =
|
||||
"SP673Z4BPB4R73359K9HE55F2X91V5BJTN5SXZ5T"
|
||||
export const xlinkContractsMultisigTestnet =
|
||||
export const contractsMultisigTestnet =
|
||||
"ST2QXSK64YQX3CQPC530K79XWQ98XFAM9W3XKEH3N"
|
||||
|
||||
export const alexContractDeployerMainnet =
|
||||
@@ -68,131 +68,131 @@ export enum StacksContractName {
|
||||
export const stxContractAddresses = {
|
||||
[StacksContractName.BTCPegInEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.BTCPegInEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.BTCPegInEndpoint,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.BTCPegInEndpointSwap]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointSwap,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointSwap,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.BTCPegInEndpointAggregator]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointAggregator,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointAggregator,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.BTCPegInEndpointLaunchpad]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointLaunchpad,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.BTCPegInEndpointLaunchpad,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.BTCPegOutEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: StacksContractName.BTCPegOutEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: StacksContractName.BTCPegOutEndpoint,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.EVMPegInEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.EVMPegInEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.EVMPegInEndpoint,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.EVMPegInEndpointSwap]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.EVMPegInEndpointSwap,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.EVMPegInEndpointSwap,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.EVMPegOutEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: StacksContractName.EVMPegOutEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: StacksContractName.EVMPegOutEndpoint,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.EVMPegOutEndpointAggregator]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.EVMPegOutEndpointAggregator,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.EVMPegOutEndpointAggregator,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.MetaPegInEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.MetaPegInEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.MetaPegInEndpoint,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.MetaPegInEndpointSwap]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.MetaPegInEndpointSwap,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.MetaPegInEndpointSwap,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.MetaPegInEndpointAggregator]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.MetaPegInEndpointAggregator,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.MetaPegInEndpointAggregator,
|
||||
}),
|
||||
},
|
||||
[StacksContractName.MetaPegOutEndpoint]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: StacksContractName.MetaPegOutEndpoint,
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: StacksContractName.MetaPegOutEndpoint,
|
||||
}),
|
||||
},
|
||||
@@ -222,41 +222,41 @@ export const stxTokenContractAddresses_legacy: Record<
|
||||
},
|
||||
[KnownTokenId.Stacks.aBTC]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: "token-abtc",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: "token-abtc",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.sUSDT]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: "token-susdt",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: "token-susdt",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.sLUNR]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: "token-slunr",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: "token-slunr",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.sSKO]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsDeployerMainnet,
|
||||
deployerAddress: contractsDeployerMainnet,
|
||||
contractName: "token-ssko",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: "token-ssko",
|
||||
}),
|
||||
},
|
||||
@@ -292,11 +292,11 @@ export const stxTokenContractAddresses_legacy: Record<
|
||||
},
|
||||
[KnownTokenId.Stacks.uBTC]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-ubtc",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsDeployerTestnet,
|
||||
deployerAddress: contractsDeployerTestnet,
|
||||
contractName: "token-ubtc",
|
||||
}),
|
||||
},
|
||||
@@ -332,51 +332,51 @@ export const stxTokenContractAddresses_legacy: Record<
|
||||
},
|
||||
[KnownTokenId.Stacks.TRUMP]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "runes-trump",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "runes-trump",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.GHIBLICZ]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "bsc-ghiblicz",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "bsc-ghiblicz",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.ETH]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-eth",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "token-eth",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.SOL]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-sol",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "token-sol",
|
||||
}),
|
||||
},
|
||||
[KnownTokenId.Stacks.LINK]: {
|
||||
[KnownChainId.Stacks.Mainnet]: wrapContractAddress("mainnet", {
|
||||
deployerAddress: xlinkContractsMultisigMainnet,
|
||||
deployerAddress: contractsMultisigMainnet,
|
||||
contractName: "token-link",
|
||||
}),
|
||||
[KnownChainId.Stacks.Testnet]: wrapContractAddress("testnet", {
|
||||
deployerAddress: xlinkContractsMultisigTestnet,
|
||||
deployerAddress: contractsMultisigTestnet,
|
||||
contractName: "token-link",
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -5,12 +5,12 @@ import {
|
||||
SwapRouteViaEVMDexAggregator,
|
||||
} from "../utils/SwapRouteHelpers"
|
||||
import { KnownChainId } from "../utils/types/knownIds"
|
||||
import { StacksContractAddress } from "../xlinkSdkUtils/types"
|
||||
import { StacksContractAddress } from "../sdkUtils/types"
|
||||
import { StacksContractName } from "./stxContractAddresses"
|
||||
import {
|
||||
executeReadonlyCallXLINK,
|
||||
getStacksContractCallInfo,
|
||||
} from "./xlinkContractHelpers"
|
||||
} from "./contractHelpers"
|
||||
import { checkNever } from "../utils/typeHelpers"
|
||||
|
||||
export async function validateBridgeOrderFromBitcoin(info: {
|
||||
|
||||
@@ -5,12 +5,12 @@ import {
|
||||
SwapRouteViaEVMDexAggregator,
|
||||
} from "../utils/SwapRouteHelpers"
|
||||
import { getChainIdNetworkType, KnownChainId } from "../utils/types/knownIds"
|
||||
import { StacksContractAddress } from "../xlinkSdkUtils/types"
|
||||
import { StacksContractAddress } from "../sdkUtils/types"
|
||||
import { StacksContractName } from "./stxContractAddresses"
|
||||
import {
|
||||
executeReadonlyCallXLINK,
|
||||
getStacksContractCallInfo,
|
||||
} from "./xlinkContractHelpers"
|
||||
} from "./contractHelpers"
|
||||
import { checkNever } from "../utils/typeHelpers"
|
||||
|
||||
export async function validateBridgeOrderFromMeta(info: {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { checkNever } from "./utils/typeHelpers"
|
||||
import { KnownChainId, KnownTokenId } from "./utils/types/knownIds"
|
||||
import { XLinkSDK } from "./XLinkSDK"
|
||||
import { SDKNumber, toSDKNumberOrUndefined } from "./xlinkSdkUtils/types"
|
||||
import { SDKNumber, toSDKNumberOrUndefined } from "./sdkUtils/types"
|
||||
|
||||
export interface ALEXSwapParameters
|
||||
extends Omit<_ALEXSwapParameters, "fromAmount"> {
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
getStacksContractCallInfo,
|
||||
getStacksToken,
|
||||
numberFromStacksContractNumber,
|
||||
} from "../stacksUtils/xlinkContractHelpers"
|
||||
import { SDKNumber, StacksContractAddress } from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
} from "../stacksUtils/contractHelpers"
|
||||
import { SDKNumber, StacksContractAddress } from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { last } from "./arrayHelpers"
|
||||
import { BigNumber } from "./BigNumber"
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { backendAPIPrefix } from "../config"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
|
||||
export async function requestAPI<T>(
|
||||
sdkContext: Pick<SDKGlobalContext, "backendAPI">,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChainId, TokenId } from "../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { ChainId, TokenId } from "../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { UnsupportedBridgeRouteError } from "./errors"
|
||||
import { pMemoize } from "./pMemoize"
|
||||
import { SwapRoute } from "./SwapRouteHelpers"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getEVMSupportedRoutesByChainType } from "../evmUtils/apiHelpers/getEVMSupportedRoutes"
|
||||
import { getBRC20SupportedRoutes } from "../metaUtils/apiHelpers/getBRC20SupportedRoutes"
|
||||
import { getRunesSupportedRoutes } from "../metaUtils/apiHelpers/getRunesSupportedRoutes"
|
||||
import { SDKGlobalContext } from "../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../sdkUtils/types.internal"
|
||||
import { KnownRoute } from "./buildSupportedRoutes"
|
||||
import { KnownChainId, KnownTokenId } from "./types/knownIds"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChainId, TokenId } from "../xlinkSdkUtils/types"
|
||||
import { ChainId, TokenId } from "../sdkUtils/types"
|
||||
import {
|
||||
SwapRouteViaALEX,
|
||||
SwapRouteViaEVMDexAggregator,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getStacksTokenContractInfo } from "../../stacksUtils/xlinkContractHelpers"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { getStacksTokenContractInfo } from "../../stacksUtils/contractHelpers"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
import { BigNumber } from "../BigNumber"
|
||||
import { KnownRoute } from "../buildSupportedRoutes"
|
||||
import { applyTransferProphet } from "../feeRateHelpers"
|
||||
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
getEvm2StacksFeeInfo,
|
||||
getStacks2EvmFeeInfo,
|
||||
} from "../../evmUtils/peggingHelpers"
|
||||
import { getEVMTokenContractInfo } from "../../evmUtils/xlinkContractHelpers"
|
||||
import { evmNativeCurrencyAddress } from "../../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { getEVMTokenContractInfo } from "../../evmUtils/contractHelpers"
|
||||
import { evmNativeCurrencyAddress } from "../../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
import { hasAny, last } from "../arrayHelpers"
|
||||
import { BigNumber } from "../BigNumber"
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toSDKNumberOrUndefined } from "../../../xlinkSdkUtils/types"
|
||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||
import { arraySplit } from "../../arrayHelpers"
|
||||
import { BigNumber } from "../../BigNumber"
|
||||
import { XLinkSDKErrorBase } from "../../errors"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toSDKNumberOrUndefined } from "../../../xlinkSdkUtils/types"
|
||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||
import { arraySplit } from "../../arrayHelpers"
|
||||
import { BigNumber } from "../../BigNumber"
|
||||
import { XLinkSDKErrorBase } from "../../errors"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toSDKNumberOrUndefined } from "../../../xlinkSdkUtils/types"
|
||||
import { toSDKNumberOrUndefined } from "../../../sdkUtils/types"
|
||||
import { arraySplit } from "../../arrayHelpers"
|
||||
import { BigNumber } from "../../BigNumber"
|
||||
import { XLinkSDKErrorBase } from "../../errors"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { readContract } from "viem/actions"
|
||||
import { ERC20Abi } from "../../../evmUtils/contractAbi/ERC20Abi"
|
||||
import { evmChainIdFromKnownChainId } from "../../../evmUtils/evmClients"
|
||||
import { getEVMTokenContractInfo } from "../../../evmUtils/xlinkContractHelpers"
|
||||
import { getEVMTokenContractInfo } from "../../../evmUtils/contractHelpers"
|
||||
import {
|
||||
EVMAddress,
|
||||
evmNativeCurrencyAddress,
|
||||
SDKNumber,
|
||||
toSDKNumberOrUndefined,
|
||||
} from "../../../xlinkSdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../../xlinkSdkUtils/types.internal"
|
||||
} from "../../../sdkUtils/types"
|
||||
import { SDKGlobalContext } from "../../../sdkUtils/types.internal"
|
||||
import { BigNumber } from "../../BigNumber"
|
||||
import { KnownChainId, KnownTokenId } from "../../types/knownIds"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SDKGlobalContext } from "../../xlinkSdkUtils/types.internal"
|
||||
import { SDKGlobalContext } from "../../sdkUtils/types.internal"
|
||||
import { uniqBy } from "../arrayHelpers"
|
||||
import { BigNumber } from "../BigNumber"
|
||||
import { isNotNull } from "../typeHelpers"
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
SDKNumber,
|
||||
SDKNumberifyNestly,
|
||||
toSDKNumberOrUndefined,
|
||||
} from "../../xlinkSdkUtils/types"
|
||||
} from "../../sdkUtils/types"
|
||||
import { BigNumber } from "../BigNumber"
|
||||
import { first, last } from "../arrayHelpers"
|
||||
import { KnownRoute } from "../buildSupportedRoutes"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChainId, RuneIdCombined, TokenId } from "../../xlinkSdkUtils/types"
|
||||
import { ChainId, RuneIdCombined, TokenId } from "../../sdkUtils/types"
|
||||
import { checkNever } from "../typeHelpers"
|
||||
|
||||
const chainId = <const T extends string>(value: T): ChainId<T> => value as any
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
||||
"extends": "@c4605/toolconfs/tsconfig-esModule",
|
||||
"exclude": ["lib", "examples/cross-chain-swap"],
|
||||
"exclude": ["node_modules", "lib", "examples/cross-chain-swap"],
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ES2023", "WebWorker"],
|
||||
"noEmit": true
|
||||
|
||||
Reference in New Issue
Block a user