@naviprotocol/astros-bridge-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +204 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/providers/mayan.d.ts +44 -0
- package/dist/providers/mayan.d.ts.map +1 -0
- package/dist/types.d.ts +209 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @naviprotocol/astros-bridge-sdk
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40naviprotocol%2Fastros-bridge-sdk)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
NAVI Astros Bridge SDK is a cross-chain bridge SDK designed for the Sui blockchain. It supports token transfers between different blockchain networks, currently mainly supporting cross-chain operations through bridge providers like Mayan.
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
For SDK documentation visit http://sdk.naviprotocol.io/bridge
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- 🌉 **Cross-chain Bridging**: Supports token transfers between multiple blockchain networks
|
|
15
|
+
- 🔄 **Multi-chain Support**: Supports mainstream blockchains like Sui, Ethereum, Solana
|
|
16
|
+
- 💰 **Optimal Paths**: Automatically finds the best cross-chain paths
|
|
17
|
+
- 📊 **Real-time Quotes**: Provides real-time cross-chain swap quotes
|
|
18
|
+
- 📱 **Easy Integration**: Clean API design, easy to integrate into various applications
|
|
19
|
+
|
|
20
|
+
## Supported Blockchains
|
|
21
|
+
|
|
22
|
+
- Sui
|
|
23
|
+
- Solana
|
|
24
|
+
- Ethereum
|
|
25
|
+
- Polygon
|
|
26
|
+
- Avalanche
|
|
27
|
+
- Arbitrum
|
|
28
|
+
- More chains support coming soon...
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```npm
|
|
33
|
+
npm install @naviprotocol/astros-bridge-sdk
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Support
|
|
38
|
+
|
|
39
|
+
- Issues: [GitHub Issues](https://github.com/naviprotocol/naviprotocol-monorepo/issues)
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge SDK Configuration Management
|
|
3
|
+
*
|
|
4
|
+
* This module provides configuration management for the Astros bridge SDK.
|
|
5
|
+
* It handles base URL and API key management for cross-chain bridge API requests,
|
|
6
|
+
* and provides a configured Axios instance for HTTP requests.
|
|
7
|
+
*
|
|
8
|
+
* @module BridgeConfig
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Configuration object for the bridge SDK
|
|
12
|
+
*
|
|
13
|
+
* Contains the base URL for the bridge API and the API key for authentication.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BridgeConfig: {
|
|
16
|
+
/** Base URL for the bridge API */
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/** API key for authentication (optional) */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Axios instance configured for bridge API requests
|
|
23
|
+
*
|
|
24
|
+
* This instance is pre-configured with the base URL and timeout settings.
|
|
25
|
+
*/
|
|
26
|
+
export declare const apiInstance: import('axios').AxiosInstance;
|
|
27
|
+
/**
|
|
28
|
+
* Updates the bridge SDK configuration
|
|
29
|
+
*
|
|
30
|
+
* This function allows runtime updates to the configuration object,
|
|
31
|
+
* including the base URL and API key. It also updates the Axios instance
|
|
32
|
+
* to use the new configuration values.
|
|
33
|
+
*
|
|
34
|
+
* @param newConfig - Partial configuration object with new values to merge
|
|
35
|
+
*/
|
|
36
|
+
export declare function config(newConfig: Partial<typeof BridgeConfig>): void;
|
|
37
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;GAIG;AACH,eAAO,MAAM,YAAY;IACvB,kCAAkC;;IAElC,4CAA4C;;CAE7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAGtB,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,YAAY,CAAC,QAQ7D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@mayanfinance/swap-sdk"),m=require("ethers"),h=require("axios"),T=["function allowance(address owner, address spender) view returns (uint256)","function approve(address spender, uint256 amount) returns (bool)","function balanceOf(address account) view returns (uint256)"];async function k(a,e,o,t,d){if(!a)throw new Error("No route found");const r=a.info_for_bridge;let s;if(a.from_token.chainId===1999){if(!t.sui)throw new Error("Sui wallet connection not found");const n=t.sui.provider,i=await g.createSwapFromSuiMoveCalls(r,e,o,d,null,n),u=await t.sui.signTransaction({transaction:i});s=(await n.executeTransactionBlock({transactionBlock:u.bytes,signature:[u.signature],options:{showEffects:!0,showEvents:!0,showBalanceChanges:!0}})).digest,await n.waitForTransaction({digest:s})}else if(a.from_token.chainId===0){if(!t.solana)throw new Error("Solana wallet connection not found");const n=t.solana;s=(await g.swapFromSolana(r,e,o,d,n.signTransaction,n.connection,n.extraRpcs,n.sendOptions,n.jitoOptions)).signature}else{if(!t.evm)throw new Error("EVM wallet connection not found");const n=t.evm,i=r.fromToken;if(i.standard==="erc20"){const u=new m.Contract(i.realOriginContractAddress||i.contract,T,n.signer),w=await u.allowance(e,g.addresses.MAYAN_FORWARDER_CONTRACT),f=m.parseUnits(String(r.effectiveAmountIn),i.decimals);if(w<f&&!await(await u.approve(g.addresses.MAYAN_FORWARDER_CONTRACT,f)).wait())throw new Error("Failed to approve allowance")}const p=await g.swapFromEvm(r,e,o,d,n.signer,n.permit,n.overrides,null);s=typeof p=="string"?p:p.hash,await n.waitForTransaction({hash:s,confirmations:3})}return await new Promise(n=>{setTimeout(()=>{n(!0)},2e3)}),s}const l={baseUrl:"https://open-aggregator-api.naviprotocol.io",apiKey:""},c=h.create({baseURL:l.baseUrl,timeout:3e4});function b(a){Object.assign(l,a),c.defaults.baseURL=l.baseUrl,l.apiKey?c.defaults.headers.common["x-navi-token"]=l.apiKey:delete c.defaults.headers.common["x-navi-token"]}async function _(){return(await c.get("/chains/list")).data.data.chains}async function S(a,e=1,o=100){return(await c.get("/coins/support-token-list",{params:{chain:a,page:e,pageSize:o,scene:"bridge"}})).data.data.list}async function v(a,e){return(await c.get("/coins/search",{params:{chain:a,keyword:e,page:1,pageSize:30,scene:"bridge"}})).data.data.list}async function y(a,e,o,t){const r=(await c.get("/bridge-swap/find_routes",{params:{from:a.address,to:e.address,fromChain:a.chainId,toChain:e.chainId,amount:o,slippageBps:t==null?void 0:t.slippageBps,referrerBps:t==null?void 0:t.referrerBps}})).data.data;return r.routes.forEach(s=>{s.from_token.chain&&(s.from_token.chainId=parseInt(s.from_token.chain)),s.to_token.chain&&(s.to_token.chainId=parseInt(s.to_token.chain))}),r}async function A(a){return(await c.get(`/bridge-swap/transaction/${a}`)).data.data.transaction}async function I(a,e=1,o=10){return(await c.get("/bridge-swap/transactions/list",{params:{address:a,page:e,limit:o}})).data.data}async function E(a,e,o,t,d){const r=new Date().toISOString(),s=await k(a,e,o,t,d),n=new Date().toISOString(),i={address:a.from_token.address,symbol:a.from_token.symbol,decimals:a.from_token.decimals},p={address:a.to_token.address,symbol:a.to_token.symbol,decimals:a.to_token.decimals};return{id:s,status:"processing",lastUpdateAt:n,sourceChainId:a.from_token.chainId,destChainId:a.to_token.chainId,walletSourceAddress:e,walletDestAddress:o,totalFeeAmount:a.total_fee,sourceToken:a.from_token,destToken:a.to_token,bridgeFromAmount:a.amount_in,bridgeToAmount:a.amount_out,bridgeStartAt:r,bridgeEndAt:n,bridgeFeeAmount:"0",bridgeSourceTxHash:s,bridgeDestTxHash:"",bridgeRefundTxHash:"",bridgeStatus:"processing",bridgeProvider:"mayan",bridgeFromToken:i,bridgeToToken:p,hasSwap:!1}}exports.config=b;exports.getQuote=y;exports.getSupportChains=_;exports.getSupportTokens=S;exports.getTransaction=A;exports.getWalletTransactions=I;exports.searchSupportTokens=v;exports.swap=E;
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/providers/mayan.ts","../src/config.ts","../src/index.ts"],"sourcesContent":["import {\n createSwapFromSuiMoveCalls,\n Quote as MayanQuote,\n swapFromSolana,\n swapFromEvm,\n SolanaTransactionSigner,\n JitoBundleOptions,\n Erc20Permit,\n addresses\n} from '@mayanfinance/swap-sdk'\nimport { BridgeSwapQuote } from '../types'\nimport { SuiClient } from '@mysten/sui/client'\nimport { Transaction } from '@mysten/sui/transactions'\nimport { Connection, SendOptions } from '@solana/web3.js'\nimport { Signer, Overrides, Contract, parseUnits } from 'ethers'\n\nconst ERC20_ABI = [\n 'function allowance(address owner, address spender) view returns (uint256)',\n 'function approve(address spender, uint256 amount) returns (bool)',\n 'function balanceOf(address account) view returns (uint256)'\n]\n\ntype SuiWalletConnection = {\n provider: SuiClient\n signTransaction: (data: { transaction: Transaction }) => Promise<{\n bytes: string\n signature: string\n }>\n}\n\ntype SolanaWalletConnection = {\n signTransaction: SolanaTransactionSigner\n connection: Connection\n extraRpcs?: string[]\n sendOptions?: SendOptions\n jitoOptions?: JitoBundleOptions\n}\n\ntype EVMWalletConnection = {\n overrides: Overrides | null | undefined\n signer: Signer\n permit: Erc20Permit | null | undefined\n waitForTransaction: (data: { hash: string; confirmations: number }) => Promise<void>\n}\n\nexport type WalletConnection = {\n sui?: SuiWalletConnection\n solana?: SolanaWalletConnection\n evm?: EVMWalletConnection\n}\n\nenum BridgeChain {\n SUI = 1999,\n SOLANA = 0\n}\n\nexport async function swap(\n route: BridgeSwapQuote,\n fromAddress: string,\n toAddress: string,\n walletConnection: WalletConnection,\n referrerAddresses?: {\n sui?: string\n evm?: string\n solana?: string\n }\n): Promise<string> {\n if (!route) {\n throw new Error('No route found')\n }\n const mayanQuote = route.info_for_bridge as MayanQuote\n let hash: string\n if (route.from_token.chainId === BridgeChain.SUI) {\n if (!walletConnection.sui) {\n throw new Error('Sui wallet connection not found')\n }\n const client = walletConnection.sui.provider\n const swapTrx = await createSwapFromSuiMoveCalls(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n null,\n client\n )\n const connection = walletConnection.sui\n const signed: {\n bytes: string\n signature: string\n } = await connection.signTransaction({ transaction: swapTrx })\n const resp = await client.executeTransactionBlock({\n transactionBlock: signed.bytes,\n signature: [signed.signature],\n options: {\n showEffects: true,\n showEvents: true,\n showBalanceChanges: true\n }\n })\n hash = resp.digest\n await client.waitForTransaction({\n digest: hash\n })\n } else if (route.from_token.chainId === BridgeChain.SOLANA) {\n if (!walletConnection.solana) {\n throw new Error('Solana wallet connection not found')\n }\n const connection = walletConnection.solana\n const swapTrx = await swapFromSolana(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n connection.signTransaction,\n connection.connection,\n connection.extraRpcs,\n connection.sendOptions,\n connection.jitoOptions\n )\n hash = swapTrx.signature\n } else {\n if (!walletConnection.evm) {\n throw new Error('EVM wallet connection not found')\n }\n const connection = walletConnection.evm\n const fromToken = mayanQuote.fromToken\n if (fromToken.standard === 'erc20') {\n const erc20Contract = new Contract(\n fromToken.realOriginContractAddress || fromToken.contract,\n ERC20_ABI,\n connection.signer\n )\n const currentAllowance = await erc20Contract.allowance(\n fromAddress,\n addresses.MAYAN_FORWARDER_CONTRACT\n )\n const REQUIRED_ALLOWANCE = parseUnits(\n String(mayanQuote.effectiveAmountIn),\n fromToken.decimals\n )\n if (currentAllowance < REQUIRED_ALLOWANCE) {\n const approveTrx = await erc20Contract.approve(\n addresses.MAYAN_FORWARDER_CONTRACT,\n REQUIRED_ALLOWANCE\n )\n const receiptApprove = await approveTrx.wait()\n if (!receiptApprove) {\n throw new Error('Failed to approve allowance')\n }\n }\n }\n const swapTrx = await swapFromEvm(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n connection.signer,\n connection.permit,\n connection.overrides,\n null\n )\n hash = typeof swapTrx === 'string' ? swapTrx : swapTrx.hash\n await connection.waitForTransaction({\n hash,\n confirmations: 3\n })\n }\n // wait for 2 seconds to make sure the mayan has processed the transaction\n await new Promise((resolve) => {\n setTimeout(() => {\n resolve(true)\n }, 2000)\n })\n return hash\n}\n","/**\n * Bridge SDK Configuration Management\n *\n * This module provides configuration management for the Astros bridge SDK.\n * It handles base URL and API key management for cross-chain bridge API requests,\n * and provides a configured Axios instance for HTTP requests.\n *\n * @module BridgeConfig\n */\n\nimport axios from 'axios'\n\n/**\n * Configuration object for the bridge SDK\n *\n * Contains the base URL for the bridge API and the API key for authentication.\n */\nexport const BridgeConfig = {\n /** Base URL for the bridge API */\n baseUrl: 'https://open-aggregator-api.naviprotocol.io',\n /** API key for authentication (optional) */\n apiKey: ''\n}\n\n/**\n * Axios instance configured for bridge API requests\n *\n * This instance is pre-configured with the base URL and timeout settings.\n */\nexport const apiInstance = axios.create({\n baseURL: BridgeConfig.baseUrl,\n timeout: 30000\n})\n\n/**\n * Updates the bridge SDK configuration\n *\n * This function allows runtime updates to the configuration object,\n * including the base URL and API key. It also updates the Axios instance\n * to use the new configuration values.\n *\n * @param newConfig - Partial configuration object with new values to merge\n */\nexport function config(newConfig: Partial<typeof BridgeConfig>) {\n Object.assign(BridgeConfig, newConfig)\n apiInstance.defaults.baseURL = BridgeConfig.baseUrl\n if (BridgeConfig.apiKey) {\n apiInstance.defaults.headers.common['x-navi-token'] = BridgeConfig.apiKey\n } else {\n delete apiInstance.defaults.headers.common['x-navi-token']\n }\n}\n","/**\n * Astros Bridge SDK Package - Main Entry Point\n *\n * This package provides cross-chain bridge functionality for the Sui blockchain.\n * It enables users to transfer tokens between different blockchain networks through\n * various bridge providers like Mayan.\n *\n * @module AstrosBridgeSDK\n */\n\nimport { Chain, Token, BridgeSwapOptions, BridgeSwapQuote, BridgeSwapTransaction } from './types'\nimport * as mayan from './providers/mayan'\nimport { WalletConnection } from './providers/mayan'\nimport { apiInstance, config } from './config'\n\n// Export configuration for the bridge SDK\nexport { config }\n\nexport * from './types'\n\n/**\n * Retrieves a list of supported blockchain networks for bridging\n * @returns Promise<Chain[]> - Array of supported blockchain networks\n */\nexport async function getSupportChains(): Promise<Chain[]> {\n const res = await apiInstance.get<{\n data: {\n chains: Chain[]\n }\n }>('/chains/list')\n return res.data.data.chains\n}\n\n/**\n * Retrieves a list of supported tokens for a specific blockchain\n * @param chainId - The ID of the blockchain network\n * @param page - Page number for pagination (default: 1)\n * @param pageSize - Number of tokens per page (default: 100)\n * @returns Promise<Token[]> - Array of supported tokens\n */\nexport async function getSupportTokens(\n chainId: number,\n page: number = 1,\n pageSize: number = 100\n): Promise<Token[]> {\n const res = await apiInstance.get<{\n data: {\n list: Token[]\n }\n }>('/coins/support-token-list', {\n params: {\n chain: chainId,\n page,\n pageSize,\n scene: 'bridge'\n }\n })\n return res.data.data.list\n}\n\n/**\n * Searches for supported tokens by keyword on a specific blockchain\n * @param chainId - The ID of the blockchain network\n * @param keyword - Search keyword for token name or symbol\n * @returns Promise<Token[]> - Array of matching tokens\n */\nexport async function searchSupportTokens(chainId: number, keyword: string): Promise<Token[]> {\n const res = await apiInstance.get<{\n data: {\n list: Token[]\n }\n }>('/coins/search', {\n params: {\n chain: chainId,\n keyword,\n page: 1,\n pageSize: 30,\n scene: 'bridge'\n }\n })\n return res.data.data.list\n}\n\n/**\n * Gets a quote for cross-chain token swap\n * @param from - Source token information\n * @param to - Destination token information\n * @param amount - Amount to swap\n * @param options - Optional swap parameters (slippage, referrer fees)\n * @returns Promise<{routes: BridgeSwapQuote[]}> - Available swap routes\n */\nexport async function getQuote(\n from: Token,\n to: Token,\n amount: string | number,\n options?: BridgeSwapOptions\n) {\n const res = await apiInstance.get<{\n data: {\n routes: BridgeSwapQuote[]\n }\n }>('/bridge-swap/find_routes', {\n params: {\n from: from.address,\n to: to.address,\n fromChain: from.chainId,\n toChain: to.chainId,\n amount,\n slippageBps: options?.slippageBps,\n referrerBps: options?.referrerBps\n }\n })\n // Temporary fix for chain ID parsing\n const rtn = res.data.data\n rtn.routes.forEach((router: any) => {\n if (router.from_token.chain) {\n router.from_token.chainId = parseInt(router.from_token.chain)\n }\n if (router.to_token.chain) {\n router.to_token.chainId = parseInt(router.to_token.chain)\n }\n })\n return rtn\n}\n\n/**\n * Retrieves transaction details by transaction hash\n * @param hash - Transaction hash to look up\n * @returns Promise<BridgeSwapTransaction> - Transaction details\n */\nexport async function getTransaction(hash: string) {\n const res = await apiInstance.get<{\n data: {\n transaction: BridgeSwapTransaction\n }\n }>(`/bridge-swap/transaction/${hash}`)\n return res.data.data.transaction\n}\n\n/**\n * Retrieves wallet transaction history\n * @param address - Wallet address to get transactions for\n * @param page - Page number for pagination (default: 1)\n * @param limit - Number of transactions per page (default: 10)\n * @returns Promise<{transactions: BridgeSwapTransaction[]}> - Transaction history\n */\nexport async function getWalletTransactions(address: string, page: number = 1, limit: number = 10) {\n const res = await apiInstance.get<{\n data: {\n transactions: BridgeSwapTransaction[]\n }\n }>(`/bridge-swap/transactions/list`, {\n params: {\n address,\n page,\n limit\n }\n })\n return res.data.data\n}\n\n/**\n * Executes a cross-chain token swap\n * @param quote - The swap quote to execute\n * @param fromAddress - Source wallet address\n * @param toAddress - Destination wallet address\n * @param walletConnection - Wallet connection for signing\n * @param referrerAddresses - Optional referrer addresses for different chains\n * @returns Promise<BridgeSwapTransaction> - Transaction details\n */\nexport async function swap(\n quote: BridgeSwapQuote,\n fromAddress: string,\n toAddress: string,\n walletConnection: WalletConnection,\n referrerAddresses?: {\n sui?: string\n evm?: string\n solana?: string\n }\n): Promise<BridgeSwapTransaction> {\n const startAt = new Date().toISOString()\n const hash = await mayan.swap(quote, fromAddress, toAddress, walletConnection, referrerAddresses)\n const endAt = new Date().toISOString()\n\n // Prepare token information for the transaction record\n const sourceToken = {\n address: quote.from_token.address,\n symbol: quote.from_token.symbol,\n decimals: quote.from_token.decimals\n }\n const destToken = {\n address: quote.to_token.address,\n symbol: quote.to_token.symbol,\n decimals: quote.to_token.decimals\n }\n\n // Return transaction details\n return {\n id: hash,\n status: 'processing',\n lastUpdateAt: endAt,\n sourceChainId: quote.from_token.chainId,\n destChainId: quote.to_token.chainId,\n walletSourceAddress: fromAddress,\n walletDestAddress: toAddress,\n totalFeeAmount: quote.total_fee,\n sourceToken: quote.from_token,\n destToken: quote.to_token,\n bridgeFromAmount: quote.amount_in,\n bridgeToAmount: quote.amount_out,\n bridgeStartAt: startAt,\n bridgeEndAt: endAt,\n bridgeFeeAmount: '0',\n bridgeSourceTxHash: hash,\n bridgeDestTxHash: '',\n bridgeRefundTxHash: '',\n bridgeStatus: 'processing',\n bridgeProvider: 'mayan',\n bridgeFromToken: sourceToken,\n bridgeToToken: destToken,\n hasSwap: false\n }\n}\n"],"names":["ERC20_ABI","swap","route","fromAddress","toAddress","walletConnection","referrerAddresses","mayanQuote","hash","client","swapTrx","createSwapFromSuiMoveCalls","signed","connection","swapFromSolana","fromToken","erc20Contract","Contract","currentAllowance","addresses","REQUIRED_ALLOWANCE","parseUnits","swapFromEvm","resolve","BridgeConfig","apiInstance","axios","config","newConfig","getSupportChains","getSupportTokens","chainId","page","pageSize","searchSupportTokens","keyword","getQuote","from","to","amount","options","rtn","router","getTransaction","getWalletTransactions","address","limit","quote","startAt","mayan.swap","endAt","sourceToken","destToken"],"mappings":"iKAgBMA,EAAY,CAChB,4EACA,mEACA,4DACF,EAoCA,eAAsBC,EAC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,MAAO,CACL,GAAIvC,EACJ,OAAQ,aACR,aAAc0C,EACd,cAAeH,EAAM,WAAW,QAChC,YAAaA,EAAM,SAAS,QAC5B,oBAAqB5C,EACrB,kBAAmBC,EACnB,eAAgB2C,EAAM,UACtB,YAAaA,EAAM,WACnB,UAAWA,EAAM,SACjB,iBAAkBA,EAAM,UACxB,eAAgBA,EAAM,WACtB,cAAeC,EACf,YAAaE,EACb,gBAAiB,IACjB,mBAAoB1C,EACpB,iBAAkB,GAClB,mBAAoB,GACpB,aAAc,aACd,eAAgB,QAChB,gBAAiB2C,EACjB,cAAeC,EACf,QAAS,EAAA,CAEb"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Chain, Token, BridgeSwapOptions, BridgeSwapQuote, BridgeSwapTransaction } from './types';
|
|
2
|
+
import { WalletConnection } from './providers/mayan';
|
|
3
|
+
import { config } from './config';
|
|
4
|
+
|
|
5
|
+
export { config };
|
|
6
|
+
export * from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves a list of supported blockchain networks for bridging
|
|
9
|
+
* @returns Promise<Chain[]> - Array of supported blockchain networks
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSupportChains(): Promise<Chain[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves a list of supported tokens for a specific blockchain
|
|
14
|
+
* @param chainId - The ID of the blockchain network
|
|
15
|
+
* @param page - Page number for pagination (default: 1)
|
|
16
|
+
* @param pageSize - Number of tokens per page (default: 100)
|
|
17
|
+
* @returns Promise<Token[]> - Array of supported tokens
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSupportTokens(chainId: number, page?: number, pageSize?: number): Promise<Token[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Searches for supported tokens by keyword on a specific blockchain
|
|
22
|
+
* @param chainId - The ID of the blockchain network
|
|
23
|
+
* @param keyword - Search keyword for token name or symbol
|
|
24
|
+
* @returns Promise<Token[]> - Array of matching tokens
|
|
25
|
+
*/
|
|
26
|
+
export declare function searchSupportTokens(chainId: number, keyword: string): Promise<Token[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets a quote for cross-chain token swap
|
|
29
|
+
* @param from - Source token information
|
|
30
|
+
* @param to - Destination token information
|
|
31
|
+
* @param amount - Amount to swap
|
|
32
|
+
* @param options - Optional swap parameters (slippage, referrer fees)
|
|
33
|
+
* @returns Promise<{routes: BridgeSwapQuote[]}> - Available swap routes
|
|
34
|
+
*/
|
|
35
|
+
export declare function getQuote(from: Token, to: Token, amount: string | number, options?: BridgeSwapOptions): Promise<{
|
|
36
|
+
routes: BridgeSwapQuote[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves transaction details by transaction hash
|
|
40
|
+
* @param hash - Transaction hash to look up
|
|
41
|
+
* @returns Promise<BridgeSwapTransaction> - Transaction details
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTransaction(hash: string): Promise<BridgeSwapTransaction>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves wallet transaction history
|
|
46
|
+
* @param address - Wallet address to get transactions for
|
|
47
|
+
* @param page - Page number for pagination (default: 1)
|
|
48
|
+
* @param limit - Number of transactions per page (default: 10)
|
|
49
|
+
* @returns Promise<{transactions: BridgeSwapTransaction[]}> - Transaction history
|
|
50
|
+
*/
|
|
51
|
+
export declare function getWalletTransactions(address: string, page?: number, limit?: number): Promise<{
|
|
52
|
+
transactions: BridgeSwapTransaction[];
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Executes a cross-chain token swap
|
|
56
|
+
* @param quote - The swap quote to execute
|
|
57
|
+
* @param fromAddress - Source wallet address
|
|
58
|
+
* @param toAddress - Destination wallet address
|
|
59
|
+
* @param walletConnection - Wallet connection for signing
|
|
60
|
+
* @param referrerAddresses - Optional referrer addresses for different chains
|
|
61
|
+
* @returns Promise<BridgeSwapTransaction> - Transaction details
|
|
62
|
+
*/
|
|
63
|
+
export declare function swap(quote: BridgeSwapQuote, fromAddress: string, toAddress: string, walletConnection: WalletConnection, referrerAddresses?: {
|
|
64
|
+
sui?: string;
|
|
65
|
+
evm?: string;
|
|
66
|
+
solana?: string;
|
|
67
|
+
}): Promise<BridgeSwapTransaction>;
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAe,MAAM,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,cAAc,SAAS,CAAA;AAEvB;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAOzD;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAU,EAChB,QAAQ,GAAE,MAAY,GACrB,OAAO,CAAC,KAAK,EAAE,CAAC,CAclB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAe5F;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,KAAK,EACT,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,CAAC,EAAE,iBAAiB;YAIf,eAAe,EAAE;GAwB9B;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,kCAOhD;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,KAAK,GAAE,MAAW;kBAG7E,qBAAqB,EAAE;GAU1C;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CACxB,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,CAAC,EAAE;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GACA,OAAO,CAAC,qBAAqB,CAAC,CA2ChC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { createSwapFromSuiMoveCalls as m, swapFromSolana as h, addresses as w, swapFromEvm as k } from "@mayanfinance/swap-sdk";
|
|
2
|
+
import { Contract as T, parseUnits as b } from "ethers";
|
|
3
|
+
import _ from "axios";
|
|
4
|
+
const v = [
|
|
5
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
6
|
+
"function approve(address spender, uint256 amount) returns (bool)",
|
|
7
|
+
"function balanceOf(address account) view returns (uint256)"
|
|
8
|
+
];
|
|
9
|
+
async function y(a, e, o, t, d) {
|
|
10
|
+
if (!a)
|
|
11
|
+
throw new Error("No route found");
|
|
12
|
+
const r = a.info_for_bridge;
|
|
13
|
+
let s;
|
|
14
|
+
if (a.from_token.chainId === 1999) {
|
|
15
|
+
if (!t.sui)
|
|
16
|
+
throw new Error("Sui wallet connection not found");
|
|
17
|
+
const n = t.sui.provider, i = await m(
|
|
18
|
+
r,
|
|
19
|
+
e,
|
|
20
|
+
o,
|
|
21
|
+
d,
|
|
22
|
+
null,
|
|
23
|
+
n
|
|
24
|
+
), f = await t.sui.signTransaction({ transaction: i });
|
|
25
|
+
s = (await n.executeTransactionBlock({
|
|
26
|
+
transactionBlock: f.bytes,
|
|
27
|
+
signature: [f.signature],
|
|
28
|
+
options: {
|
|
29
|
+
showEffects: !0,
|
|
30
|
+
showEvents: !0,
|
|
31
|
+
showBalanceChanges: !0
|
|
32
|
+
}
|
|
33
|
+
})).digest, await n.waitForTransaction({
|
|
34
|
+
digest: s
|
|
35
|
+
});
|
|
36
|
+
} else if (a.from_token.chainId === 0) {
|
|
37
|
+
if (!t.solana)
|
|
38
|
+
throw new Error("Solana wallet connection not found");
|
|
39
|
+
const n = t.solana;
|
|
40
|
+
s = (await h(
|
|
41
|
+
r,
|
|
42
|
+
e,
|
|
43
|
+
o,
|
|
44
|
+
d,
|
|
45
|
+
n.signTransaction,
|
|
46
|
+
n.connection,
|
|
47
|
+
n.extraRpcs,
|
|
48
|
+
n.sendOptions,
|
|
49
|
+
n.jitoOptions
|
|
50
|
+
)).signature;
|
|
51
|
+
} else {
|
|
52
|
+
if (!t.evm)
|
|
53
|
+
throw new Error("EVM wallet connection not found");
|
|
54
|
+
const n = t.evm, i = r.fromToken;
|
|
55
|
+
if (i.standard === "erc20") {
|
|
56
|
+
const f = new T(
|
|
57
|
+
i.realOriginContractAddress || i.contract,
|
|
58
|
+
v,
|
|
59
|
+
n.signer
|
|
60
|
+
), l = await f.allowance(
|
|
61
|
+
e,
|
|
62
|
+
w.MAYAN_FORWARDER_CONTRACT
|
|
63
|
+
), u = b(
|
|
64
|
+
String(r.effectiveAmountIn),
|
|
65
|
+
i.decimals
|
|
66
|
+
);
|
|
67
|
+
if (l < u && !await (await f.approve(
|
|
68
|
+
w.MAYAN_FORWARDER_CONTRACT,
|
|
69
|
+
u
|
|
70
|
+
)).wait())
|
|
71
|
+
throw new Error("Failed to approve allowance");
|
|
72
|
+
}
|
|
73
|
+
const p = await k(
|
|
74
|
+
r,
|
|
75
|
+
e,
|
|
76
|
+
o,
|
|
77
|
+
d,
|
|
78
|
+
n.signer,
|
|
79
|
+
n.permit,
|
|
80
|
+
n.overrides,
|
|
81
|
+
null
|
|
82
|
+
);
|
|
83
|
+
s = typeof p == "string" ? p : p.hash, await n.waitForTransaction({
|
|
84
|
+
hash: s,
|
|
85
|
+
confirmations: 3
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return await new Promise((n) => {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
n(!0);
|
|
91
|
+
}, 2e3);
|
|
92
|
+
}), s;
|
|
93
|
+
}
|
|
94
|
+
const g = {
|
|
95
|
+
/** Base URL for the bridge API */
|
|
96
|
+
baseUrl: "https://open-aggregator-api.naviprotocol.io",
|
|
97
|
+
/** API key for authentication (optional) */
|
|
98
|
+
apiKey: ""
|
|
99
|
+
}, c = _.create({
|
|
100
|
+
baseURL: g.baseUrl,
|
|
101
|
+
timeout: 3e4
|
|
102
|
+
});
|
|
103
|
+
function R(a) {
|
|
104
|
+
Object.assign(g, a), c.defaults.baseURL = g.baseUrl, g.apiKey ? c.defaults.headers.common["x-navi-token"] = g.apiKey : delete c.defaults.headers.common["x-navi-token"];
|
|
105
|
+
}
|
|
106
|
+
async function F() {
|
|
107
|
+
return (await c.get("/chains/list")).data.data.chains;
|
|
108
|
+
}
|
|
109
|
+
async function O(a, e = 1, o = 100) {
|
|
110
|
+
return (await c.get("/coins/support-token-list", {
|
|
111
|
+
params: {
|
|
112
|
+
chain: a,
|
|
113
|
+
page: e,
|
|
114
|
+
pageSize: o,
|
|
115
|
+
scene: "bridge"
|
|
116
|
+
}
|
|
117
|
+
})).data.data.list;
|
|
118
|
+
}
|
|
119
|
+
async function C(a, e) {
|
|
120
|
+
return (await c.get("/coins/search", {
|
|
121
|
+
params: {
|
|
122
|
+
chain: a,
|
|
123
|
+
keyword: e,
|
|
124
|
+
page: 1,
|
|
125
|
+
pageSize: 30,
|
|
126
|
+
scene: "bridge"
|
|
127
|
+
}
|
|
128
|
+
})).data.data.list;
|
|
129
|
+
}
|
|
130
|
+
async function B(a, e, o, t) {
|
|
131
|
+
const r = (await c.get("/bridge-swap/find_routes", {
|
|
132
|
+
params: {
|
|
133
|
+
from: a.address,
|
|
134
|
+
to: e.address,
|
|
135
|
+
fromChain: a.chainId,
|
|
136
|
+
toChain: e.chainId,
|
|
137
|
+
amount: o,
|
|
138
|
+
slippageBps: t == null ? void 0 : t.slippageBps,
|
|
139
|
+
referrerBps: t == null ? void 0 : t.referrerBps
|
|
140
|
+
}
|
|
141
|
+
})).data.data;
|
|
142
|
+
return r.routes.forEach((s) => {
|
|
143
|
+
s.from_token.chain && (s.from_token.chainId = parseInt(s.from_token.chain)), s.to_token.chain && (s.to_token.chainId = parseInt(s.to_token.chain));
|
|
144
|
+
}), r;
|
|
145
|
+
}
|
|
146
|
+
async function U(a) {
|
|
147
|
+
return (await c.get(`/bridge-swap/transaction/${a}`)).data.data.transaction;
|
|
148
|
+
}
|
|
149
|
+
async function D(a, e = 1, o = 10) {
|
|
150
|
+
return (await c.get("/bridge-swap/transactions/list", {
|
|
151
|
+
params: {
|
|
152
|
+
address: a,
|
|
153
|
+
page: e,
|
|
154
|
+
limit: o
|
|
155
|
+
}
|
|
156
|
+
})).data.data;
|
|
157
|
+
}
|
|
158
|
+
async function N(a, e, o, t, d) {
|
|
159
|
+
const r = (/* @__PURE__ */ new Date()).toISOString(), s = await y(a, e, o, t, d), n = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
160
|
+
address: a.from_token.address,
|
|
161
|
+
symbol: a.from_token.symbol,
|
|
162
|
+
decimals: a.from_token.decimals
|
|
163
|
+
}, p = {
|
|
164
|
+
address: a.to_token.address,
|
|
165
|
+
symbol: a.to_token.symbol,
|
|
166
|
+
decimals: a.to_token.decimals
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
id: s,
|
|
170
|
+
status: "processing",
|
|
171
|
+
lastUpdateAt: n,
|
|
172
|
+
sourceChainId: a.from_token.chainId,
|
|
173
|
+
destChainId: a.to_token.chainId,
|
|
174
|
+
walletSourceAddress: e,
|
|
175
|
+
walletDestAddress: o,
|
|
176
|
+
totalFeeAmount: a.total_fee,
|
|
177
|
+
sourceToken: a.from_token,
|
|
178
|
+
destToken: a.to_token,
|
|
179
|
+
bridgeFromAmount: a.amount_in,
|
|
180
|
+
bridgeToAmount: a.amount_out,
|
|
181
|
+
bridgeStartAt: r,
|
|
182
|
+
bridgeEndAt: n,
|
|
183
|
+
bridgeFeeAmount: "0",
|
|
184
|
+
bridgeSourceTxHash: s,
|
|
185
|
+
bridgeDestTxHash: "",
|
|
186
|
+
bridgeRefundTxHash: "",
|
|
187
|
+
bridgeStatus: "processing",
|
|
188
|
+
bridgeProvider: "mayan",
|
|
189
|
+
bridgeFromToken: i,
|
|
190
|
+
bridgeToToken: p,
|
|
191
|
+
hasSwap: !1
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
R as config,
|
|
196
|
+
B as getQuote,
|
|
197
|
+
F as getSupportChains,
|
|
198
|
+
O as getSupportTokens,
|
|
199
|
+
U as getTransaction,
|
|
200
|
+
D as getWalletTransactions,
|
|
201
|
+
C as searchSupportTokens,
|
|
202
|
+
N as swap
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/providers/mayan.ts","../src/config.ts","../src/index.ts"],"sourcesContent":["import {\n createSwapFromSuiMoveCalls,\n Quote as MayanQuote,\n swapFromSolana,\n swapFromEvm,\n SolanaTransactionSigner,\n JitoBundleOptions,\n Erc20Permit,\n addresses\n} from '@mayanfinance/swap-sdk'\nimport { BridgeSwapQuote } from '../types'\nimport { SuiClient } from '@mysten/sui/client'\nimport { Transaction } from '@mysten/sui/transactions'\nimport { Connection, SendOptions } from '@solana/web3.js'\nimport { Signer, Overrides, Contract, parseUnits } from 'ethers'\n\nconst ERC20_ABI = [\n 'function allowance(address owner, address spender) view returns (uint256)',\n 'function approve(address spender, uint256 amount) returns (bool)',\n 'function balanceOf(address account) view returns (uint256)'\n]\n\ntype SuiWalletConnection = {\n provider: SuiClient\n signTransaction: (data: { transaction: Transaction }) => Promise<{\n bytes: string\n signature: string\n }>\n}\n\ntype SolanaWalletConnection = {\n signTransaction: SolanaTransactionSigner\n connection: Connection\n extraRpcs?: string[]\n sendOptions?: SendOptions\n jitoOptions?: JitoBundleOptions\n}\n\ntype EVMWalletConnection = {\n overrides: Overrides | null | undefined\n signer: Signer\n permit: Erc20Permit | null | undefined\n waitForTransaction: (data: { hash: string; confirmations: number }) => Promise<void>\n}\n\nexport type WalletConnection = {\n sui?: SuiWalletConnection\n solana?: SolanaWalletConnection\n evm?: EVMWalletConnection\n}\n\nenum BridgeChain {\n SUI = 1999,\n SOLANA = 0\n}\n\nexport async function swap(\n route: BridgeSwapQuote,\n fromAddress: string,\n toAddress: string,\n walletConnection: WalletConnection,\n referrerAddresses?: {\n sui?: string\n evm?: string\n solana?: string\n }\n): Promise<string> {\n if (!route) {\n throw new Error('No route found')\n }\n const mayanQuote = route.info_for_bridge as MayanQuote\n let hash: string\n if (route.from_token.chainId === BridgeChain.SUI) {\n if (!walletConnection.sui) {\n throw new Error('Sui wallet connection not found')\n }\n const client = walletConnection.sui.provider\n const swapTrx = await createSwapFromSuiMoveCalls(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n null,\n client\n )\n const connection = walletConnection.sui\n const signed: {\n bytes: string\n signature: string\n } = await connection.signTransaction({ transaction: swapTrx })\n const resp = await client.executeTransactionBlock({\n transactionBlock: signed.bytes,\n signature: [signed.signature],\n options: {\n showEffects: true,\n showEvents: true,\n showBalanceChanges: true\n }\n })\n hash = resp.digest\n await client.waitForTransaction({\n digest: hash\n })\n } else if (route.from_token.chainId === BridgeChain.SOLANA) {\n if (!walletConnection.solana) {\n throw new Error('Solana wallet connection not found')\n }\n const connection = walletConnection.solana\n const swapTrx = await swapFromSolana(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n connection.signTransaction,\n connection.connection,\n connection.extraRpcs,\n connection.sendOptions,\n connection.jitoOptions\n )\n hash = swapTrx.signature\n } else {\n if (!walletConnection.evm) {\n throw new Error('EVM wallet connection not found')\n }\n const connection = walletConnection.evm\n const fromToken = mayanQuote.fromToken\n if (fromToken.standard === 'erc20') {\n const erc20Contract = new Contract(\n fromToken.realOriginContractAddress || fromToken.contract,\n ERC20_ABI,\n connection.signer\n )\n const currentAllowance = await erc20Contract.allowance(\n fromAddress,\n addresses.MAYAN_FORWARDER_CONTRACT\n )\n const REQUIRED_ALLOWANCE = parseUnits(\n String(mayanQuote.effectiveAmountIn),\n fromToken.decimals\n )\n if (currentAllowance < REQUIRED_ALLOWANCE) {\n const approveTrx = await erc20Contract.approve(\n addresses.MAYAN_FORWARDER_CONTRACT,\n REQUIRED_ALLOWANCE\n )\n const receiptApprove = await approveTrx.wait()\n if (!receiptApprove) {\n throw new Error('Failed to approve allowance')\n }\n }\n }\n const swapTrx = await swapFromEvm(\n mayanQuote,\n fromAddress,\n toAddress,\n referrerAddresses,\n connection.signer,\n connection.permit,\n connection.overrides,\n null\n )\n hash = typeof swapTrx === 'string' ? swapTrx : swapTrx.hash\n await connection.waitForTransaction({\n hash,\n confirmations: 3\n })\n }\n // wait for 2 seconds to make sure the mayan has processed the transaction\n await new Promise((resolve) => {\n setTimeout(() => {\n resolve(true)\n }, 2000)\n })\n return hash\n}\n","/**\n * Bridge SDK Configuration Management\n *\n * This module provides configuration management for the Astros bridge SDK.\n * It handles base URL and API key management for cross-chain bridge API requests,\n * and provides a configured Axios instance for HTTP requests.\n *\n * @module BridgeConfig\n */\n\nimport axios from 'axios'\n\n/**\n * Configuration object for the bridge SDK\n *\n * Contains the base URL for the bridge API and the API key for authentication.\n */\nexport const BridgeConfig = {\n /** Base URL for the bridge API */\n baseUrl: 'https://open-aggregator-api.naviprotocol.io',\n /** API key for authentication (optional) */\n apiKey: ''\n}\n\n/**\n * Axios instance configured for bridge API requests\n *\n * This instance is pre-configured with the base URL and timeout settings.\n */\nexport const apiInstance = axios.create({\n baseURL: BridgeConfig.baseUrl,\n timeout: 30000\n})\n\n/**\n * Updates the bridge SDK configuration\n *\n * This function allows runtime updates to the configuration object,\n * including the base URL and API key. It also updates the Axios instance\n * to use the new configuration values.\n *\n * @param newConfig - Partial configuration object with new values to merge\n */\nexport function config(newConfig: Partial<typeof BridgeConfig>) {\n Object.assign(BridgeConfig, newConfig)\n apiInstance.defaults.baseURL = BridgeConfig.baseUrl\n if (BridgeConfig.apiKey) {\n apiInstance.defaults.headers.common['x-navi-token'] = BridgeConfig.apiKey\n } else {\n delete apiInstance.defaults.headers.common['x-navi-token']\n }\n}\n","/**\n * Astros Bridge SDK Package - Main Entry Point\n *\n * This package provides cross-chain bridge functionality for the Sui blockchain.\n * It enables users to transfer tokens between different blockchain networks through\n * various bridge providers like Mayan.\n *\n * @module AstrosBridgeSDK\n */\n\nimport { Chain, Token, BridgeSwapOptions, BridgeSwapQuote, BridgeSwapTransaction } from './types'\nimport * as mayan from './providers/mayan'\nimport { WalletConnection } from './providers/mayan'\nimport { apiInstance, config } from './config'\n\n// Export configuration for the bridge SDK\nexport { config }\n\nexport * from './types'\n\n/**\n * Retrieves a list of supported blockchain networks for bridging\n * @returns Promise<Chain[]> - Array of supported blockchain networks\n */\nexport async function getSupportChains(): Promise<Chain[]> {\n const res = await apiInstance.get<{\n data: {\n chains: Chain[]\n }\n }>('/chains/list')\n return res.data.data.chains\n}\n\n/**\n * Retrieves a list of supported tokens for a specific blockchain\n * @param chainId - The ID of the blockchain network\n * @param page - Page number for pagination (default: 1)\n * @param pageSize - Number of tokens per page (default: 100)\n * @returns Promise<Token[]> - Array of supported tokens\n */\nexport async function getSupportTokens(\n chainId: number,\n page: number = 1,\n pageSize: number = 100\n): Promise<Token[]> {\n const res = await apiInstance.get<{\n data: {\n list: Token[]\n }\n }>('/coins/support-token-list', {\n params: {\n chain: chainId,\n page,\n pageSize,\n scene: 'bridge'\n }\n })\n return res.data.data.list\n}\n\n/**\n * Searches for supported tokens by keyword on a specific blockchain\n * @param chainId - The ID of the blockchain network\n * @param keyword - Search keyword for token name or symbol\n * @returns Promise<Token[]> - Array of matching tokens\n */\nexport async function searchSupportTokens(chainId: number, keyword: string): Promise<Token[]> {\n const res = await apiInstance.get<{\n data: {\n list: Token[]\n }\n }>('/coins/search', {\n params: {\n chain: chainId,\n keyword,\n page: 1,\n pageSize: 30,\n scene: 'bridge'\n }\n })\n return res.data.data.list\n}\n\n/**\n * Gets a quote for cross-chain token swap\n * @param from - Source token information\n * @param to - Destination token information\n * @param amount - Amount to swap\n * @param options - Optional swap parameters (slippage, referrer fees)\n * @returns Promise<{routes: BridgeSwapQuote[]}> - Available swap routes\n */\nexport async function getQuote(\n from: Token,\n to: Token,\n amount: string | number,\n options?: BridgeSwapOptions\n) {\n const res = await apiInstance.get<{\n data: {\n routes: BridgeSwapQuote[]\n }\n }>('/bridge-swap/find_routes', {\n params: {\n from: from.address,\n to: to.address,\n fromChain: from.chainId,\n toChain: to.chainId,\n amount,\n slippageBps: options?.slippageBps,\n referrerBps: options?.referrerBps\n }\n })\n // Temporary fix for chain ID parsing\n const rtn = res.data.data\n rtn.routes.forEach((router: any) => {\n if (router.from_token.chain) {\n router.from_token.chainId = parseInt(router.from_token.chain)\n }\n if (router.to_token.chain) {\n router.to_token.chainId = parseInt(router.to_token.chain)\n }\n })\n return rtn\n}\n\n/**\n * Retrieves transaction details by transaction hash\n * @param hash - Transaction hash to look up\n * @returns Promise<BridgeSwapTransaction> - Transaction details\n */\nexport async function getTransaction(hash: string) {\n const res = await apiInstance.get<{\n data: {\n transaction: BridgeSwapTransaction\n }\n }>(`/bridge-swap/transaction/${hash}`)\n return res.data.data.transaction\n}\n\n/**\n * Retrieves wallet transaction history\n * @param address - Wallet address to get transactions for\n * @param page - Page number for pagination (default: 1)\n * @param limit - Number of transactions per page (default: 10)\n * @returns Promise<{transactions: BridgeSwapTransaction[]}> - Transaction history\n */\nexport async function getWalletTransactions(address: string, page: number = 1, limit: number = 10) {\n const res = await apiInstance.get<{\n data: {\n transactions: BridgeSwapTransaction[]\n }\n }>(`/bridge-swap/transactions/list`, {\n params: {\n address,\n page,\n limit\n }\n })\n return res.data.data\n}\n\n/**\n * Executes a cross-chain token swap\n * @param quote - The swap quote to execute\n * @param fromAddress - Source wallet address\n * @param toAddress - Destination wallet address\n * @param walletConnection - Wallet connection for signing\n * @param referrerAddresses - Optional referrer addresses for different chains\n * @returns Promise<BridgeSwapTransaction> - Transaction details\n */\nexport async function swap(\n quote: BridgeSwapQuote,\n fromAddress: string,\n toAddress: string,\n walletConnection: WalletConnection,\n referrerAddresses?: {\n sui?: string\n evm?: string\n solana?: string\n }\n): Promise<BridgeSwapTransaction> {\n const startAt = new Date().toISOString()\n const hash = await mayan.swap(quote, fromAddress, toAddress, walletConnection, referrerAddresses)\n const endAt = new Date().toISOString()\n\n // Prepare token information for the transaction record\n const sourceToken = {\n address: quote.from_token.address,\n symbol: quote.from_token.symbol,\n decimals: quote.from_token.decimals\n }\n const destToken = {\n address: quote.to_token.address,\n symbol: quote.to_token.symbol,\n decimals: quote.to_token.decimals\n }\n\n // Return transaction details\n return {\n id: hash,\n status: 'processing',\n lastUpdateAt: endAt,\n sourceChainId: quote.from_token.chainId,\n destChainId: quote.to_token.chainId,\n walletSourceAddress: fromAddress,\n walletDestAddress: toAddress,\n totalFeeAmount: quote.total_fee,\n sourceToken: quote.from_token,\n destToken: quote.to_token,\n bridgeFromAmount: quote.amount_in,\n bridgeToAmount: quote.amount_out,\n bridgeStartAt: startAt,\n bridgeEndAt: endAt,\n bridgeFeeAmount: '0',\n bridgeSourceTxHash: hash,\n bridgeDestTxHash: '',\n bridgeRefundTxHash: '',\n bridgeStatus: 'processing',\n bridgeProvider: 'mayan',\n bridgeFromToken: sourceToken,\n bridgeToToken: destToken,\n hasSwap: false\n }\n}\n"],"names":["ERC20_ABI","swap","route","fromAddress","toAddress","walletConnection","referrerAddresses","mayanQuote","hash","client","swapTrx","createSwapFromSuiMoveCalls","signed","connection","swapFromSolana","fromToken","erc20Contract","Contract","currentAllowance","addresses","REQUIRED_ALLOWANCE","parseUnits","swapFromEvm","resolve","BridgeConfig","apiInstance","axios","config","newConfig","getSupportChains","getSupportTokens","chainId","page","pageSize","searchSupportTokens","keyword","getQuote","from","to","amount","options","rtn","router","getTransaction","getWalletTransactions","address","limit","quote","startAt","mayan.swap","endAt","sourceToken","destToken"],"mappings":";;;AAgBA,MAAMA,IAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF;AAoCA,eAAsBC,EACpBC,GACAC,GACAC,GACAC,GACAC,GAKiB;AACjB,MAAI,CAACJ;AACH,UAAM,IAAI,MAAM,gBAAgB;AAElC,QAAMK,IAAaL,EAAM;AACzB,MAAIM;AACJ,MAAIN,EAAM,WAAW,YAAY,MAAiB;AAChD,QAAI,CAACG,EAAiB;AACpB,YAAM,IAAI,MAAM,iCAAiC;AAEnD,UAAMI,IAASJ,EAAiB,IAAI,UAC9BK,IAAU,MAAMC;AAAA,MACpBJ;AAAA,MACAJ;AAAA,MACAC;AAAA,MACAE;AAAA,MACA;AAAA,MACAG;AAAA,IAAA,GAGIG,IAGF,MAJeP,EAAiB,IAIf,gBAAgB,EAAE,aAAaK,GAAS;AAU7D,IAAAF,KATa,MAAMC,EAAO,wBAAwB;AAAA,MAChD,kBAAkBG,EAAO;AAAA,MACzB,WAAW,CAACA,EAAO,SAAS;AAAA,MAC5B,SAAS;AAAA,QACP,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,oBAAoB;AAAA,MAAA;AAAA,IACtB,CACD,GACW,QACZ,MAAMH,EAAO,mBAAmB;AAAA,MAC9B,QAAQD;AAAA,IAAA,CACT;AAAA,EAAA,WACQN,EAAM,WAAW,YAAY,GAAoB;AAC1D,QAAI,CAACG,EAAiB;AACpB,YAAM,IAAI,MAAM,oCAAoC;AAEtD,UAAMQ,IAAaR,EAAiB;AAYpC,IAAAG,KAXgB,MAAMM;AAAA,MACpBP;AAAA,MACAJ;AAAA,MACAC;AAAA,MACAE;AAAA,MACAO,EAAW;AAAA,MACXA,EAAW;AAAA,MACXA,EAAW;AAAA,MACXA,EAAW;AAAA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IACjB,oBAAoB1C;AAAA,IACpB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,iBAAiB2C;AAAA,IACjB,eAAeC;AAAA,IACf,SAAS;AAAA,EAAA;AAEb;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SolanaTransactionSigner, JitoBundleOptions, Erc20Permit } from '@mayanfinance/swap-sdk';
|
|
2
|
+
import { BridgeSwapQuote } from '../types';
|
|
3
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
4
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
5
|
+
import { Connection, SendOptions } from '@solana/web3.js';
|
|
6
|
+
import { Signer, Overrides } from 'ethers';
|
|
7
|
+
|
|
8
|
+
type SuiWalletConnection = {
|
|
9
|
+
provider: SuiClient;
|
|
10
|
+
signTransaction: (data: {
|
|
11
|
+
transaction: Transaction;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
bytes: string;
|
|
14
|
+
signature: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
type SolanaWalletConnection = {
|
|
18
|
+
signTransaction: SolanaTransactionSigner;
|
|
19
|
+
connection: Connection;
|
|
20
|
+
extraRpcs?: string[];
|
|
21
|
+
sendOptions?: SendOptions;
|
|
22
|
+
jitoOptions?: JitoBundleOptions;
|
|
23
|
+
};
|
|
24
|
+
type EVMWalletConnection = {
|
|
25
|
+
overrides: Overrides | null | undefined;
|
|
26
|
+
signer: Signer;
|
|
27
|
+
permit: Erc20Permit | null | undefined;
|
|
28
|
+
waitForTransaction: (data: {
|
|
29
|
+
hash: string;
|
|
30
|
+
confirmations: number;
|
|
31
|
+
}) => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export type WalletConnection = {
|
|
34
|
+
sui?: SuiWalletConnection;
|
|
35
|
+
solana?: SolanaWalletConnection;
|
|
36
|
+
evm?: EVMWalletConnection;
|
|
37
|
+
};
|
|
38
|
+
export declare function swap(route: BridgeSwapQuote, fromAddress: string, toAddress: string, walletConnection: WalletConnection, referrerAddresses?: {
|
|
39
|
+
sui?: string;
|
|
40
|
+
evm?: string;
|
|
41
|
+
solana?: string;
|
|
42
|
+
}): Promise<string>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=mayan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mayan.d.ts","sourceRoot":"","sources":["../../src/providers/mayan.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EAEZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAwB,MAAM,QAAQ,CAAA;AAQhE,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,SAAS,CAAA;IACnB,eAAe,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC;QAC/D,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;KAClB,CAAC,CAAA;CACH,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,eAAe,EAAE,uBAAuB,CAAA;IACxC,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IACtC,kBAAkB,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACrF,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,mBAAmB,CAAA;IACzB,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,GAAG,CAAC,EAAE,mBAAmB,CAAA;CAC1B,CAAA;AAOD,wBAAsB,IAAI,CACxB,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,CAAC,EAAE;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GACA,OAAO,CAAC,MAAM,CAAC,CA4GjB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astros Bridge SDK Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module contains type definitions for the cross-chain bridge functionality,
|
|
5
|
+
* including chain information, token details, swap quotes, and transaction tracking.
|
|
6
|
+
*
|
|
7
|
+
* @module AstrosBridgeTypes
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Blockchain network information
|
|
11
|
+
*
|
|
12
|
+
* This type defines the properties of a supported blockchain network
|
|
13
|
+
* for cross-chain bridging operations.
|
|
14
|
+
*/
|
|
15
|
+
export type Chain = {
|
|
16
|
+
/** Unique chain identifier */
|
|
17
|
+
id: number;
|
|
18
|
+
/** Human-readable chain name */
|
|
19
|
+
name: string;
|
|
20
|
+
/** URL to chain icon/logo */
|
|
21
|
+
iconUrl: string;
|
|
22
|
+
/** Native currency of the chain */
|
|
23
|
+
nativeCurrency: Token;
|
|
24
|
+
/** RPC endpoint configuration */
|
|
25
|
+
rpcUrl: {
|
|
26
|
+
/** Default RPC URL for the chain */
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
/** Block explorer configuration */
|
|
30
|
+
blockExplorers: {
|
|
31
|
+
/** Default block explorer */
|
|
32
|
+
default: {
|
|
33
|
+
/** Explorer URL */
|
|
34
|
+
url: string;
|
|
35
|
+
/** Explorer name */
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Token information for cross-chain operations
|
|
42
|
+
*
|
|
43
|
+
* This type defines the properties of a token that can be bridged
|
|
44
|
+
* between different blockchain networks.
|
|
45
|
+
*/
|
|
46
|
+
export type Token = {
|
|
47
|
+
/** Token contract address */
|
|
48
|
+
address: string;
|
|
49
|
+
/** Chain ID where this token exists */
|
|
50
|
+
chainId: number;
|
|
51
|
+
/** Token decimal places */
|
|
52
|
+
decimals: number;
|
|
53
|
+
/** URL to token logo */
|
|
54
|
+
logoURI: string;
|
|
55
|
+
/** Human-readable token name */
|
|
56
|
+
name: string;
|
|
57
|
+
/** Name of the chain where this token exists */
|
|
58
|
+
chainName: string;
|
|
59
|
+
/** Token symbol/ticker */
|
|
60
|
+
symbol: string;
|
|
61
|
+
/** Whether this token is suggested for users */
|
|
62
|
+
isSuggest: boolean;
|
|
63
|
+
/** Whether this token is verified */
|
|
64
|
+
isVerify: boolean;
|
|
65
|
+
/** Token categories/tags */
|
|
66
|
+
category: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Options for bridge swap operations
|
|
70
|
+
*/
|
|
71
|
+
export type BridgeSwapOptions = {
|
|
72
|
+
/** Slippage tolerance in basis points (1/10000) */
|
|
73
|
+
slippageBps?: number;
|
|
74
|
+
/** Referrer fee in basis points (1/10000) */
|
|
75
|
+
referrerBps?: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Quote information for a cross-chain swap
|
|
79
|
+
*
|
|
80
|
+
* This type contains all the information needed to execute a cross-chain swap,
|
|
81
|
+
* including amounts, tokens, fees, and routing information.
|
|
82
|
+
*/
|
|
83
|
+
export type BridgeSwapQuote = {
|
|
84
|
+
/** Bridge provider name */
|
|
85
|
+
provider: string;
|
|
86
|
+
/** Input amount for the swap */
|
|
87
|
+
amount_in: string;
|
|
88
|
+
/** Output amount from the swap */
|
|
89
|
+
amount_out: string;
|
|
90
|
+
/** Slippage tolerance in basis points */
|
|
91
|
+
slippage_bps: number;
|
|
92
|
+
/** Minimum output amount after slippage */
|
|
93
|
+
min_amount_out: string;
|
|
94
|
+
/** Source token information */
|
|
95
|
+
from_token: Token;
|
|
96
|
+
/** Target token information */
|
|
97
|
+
to_token: Token;
|
|
98
|
+
/** Total fee for the bridge operation */
|
|
99
|
+
total_fee: string;
|
|
100
|
+
/** Estimated time for the bridge operation */
|
|
101
|
+
spend_duration: number;
|
|
102
|
+
/** Additional information for the bridge provider */
|
|
103
|
+
info_for_bridge: any;
|
|
104
|
+
/** Token path for the bridge operation */
|
|
105
|
+
path: {
|
|
106
|
+
/** Token in the path */
|
|
107
|
+
token: Token;
|
|
108
|
+
/** Amount for this step (optional) */
|
|
109
|
+
amount?: string;
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Available bridge routes for a swap
|
|
114
|
+
*/
|
|
115
|
+
export type BridgeRoutes = {
|
|
116
|
+
/** Array of available bridge swap quotes */
|
|
117
|
+
routes: BridgeSwapQuote[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Status of a bridge swap transaction
|
|
121
|
+
*/
|
|
122
|
+
export type BridgeSwapStatus = 'processing' | 'completed' | 'fail';
|
|
123
|
+
/**
|
|
124
|
+
* Complete bridge swap transaction information
|
|
125
|
+
*
|
|
126
|
+
* This type contains comprehensive information about a cross-chain swap
|
|
127
|
+
* transaction, including status tracking, amounts, and transaction hashes.
|
|
128
|
+
*/
|
|
129
|
+
export type BridgeSwapTransaction = {
|
|
130
|
+
/** Unique transaction identifier */
|
|
131
|
+
id: string;
|
|
132
|
+
/** Current transaction status */
|
|
133
|
+
status: BridgeSwapStatus;
|
|
134
|
+
/** Last update timestamp */
|
|
135
|
+
lastUpdateAt: string;
|
|
136
|
+
/** Source chain ID */
|
|
137
|
+
sourceChainId: number;
|
|
138
|
+
/** Destination chain ID */
|
|
139
|
+
destChainId: number;
|
|
140
|
+
/** Source wallet address */
|
|
141
|
+
walletSourceAddress: string;
|
|
142
|
+
/** Destination wallet address */
|
|
143
|
+
walletDestAddress: string;
|
|
144
|
+
/** Total fee amount */
|
|
145
|
+
totalFeeAmount: string;
|
|
146
|
+
/** Source token details */
|
|
147
|
+
sourceToken: {
|
|
148
|
+
/** Token address */
|
|
149
|
+
address: string;
|
|
150
|
+
/** Token symbol */
|
|
151
|
+
symbol: string;
|
|
152
|
+
/** Token decimals */
|
|
153
|
+
decimals: number;
|
|
154
|
+
};
|
|
155
|
+
/** Destination token details */
|
|
156
|
+
destToken: {
|
|
157
|
+
/** Token address */
|
|
158
|
+
address: string;
|
|
159
|
+
/** Token symbol */
|
|
160
|
+
symbol: string;
|
|
161
|
+
/** Token decimals */
|
|
162
|
+
decimals: number;
|
|
163
|
+
};
|
|
164
|
+
/** Whether this includes a swap operation */
|
|
165
|
+
hasSwap: boolean;
|
|
166
|
+
/** Bridge provider name */
|
|
167
|
+
bridgeProvider: string;
|
|
168
|
+
/** Bridge operation status */
|
|
169
|
+
bridgeStatus: BridgeSwapStatus;
|
|
170
|
+
/** Bridge source token details */
|
|
171
|
+
bridgeFromToken: {
|
|
172
|
+
/** Token address */
|
|
173
|
+
address: string;
|
|
174
|
+
/** Token symbol */
|
|
175
|
+
symbol: string;
|
|
176
|
+
/** Token decimals */
|
|
177
|
+
decimals: number;
|
|
178
|
+
};
|
|
179
|
+
/** Bridge destination token details */
|
|
180
|
+
bridgeToToken: {
|
|
181
|
+
/** Token address */
|
|
182
|
+
address: string;
|
|
183
|
+
/** Token symbol */
|
|
184
|
+
symbol: string;
|
|
185
|
+
/** Token decimals */
|
|
186
|
+
decimals: number;
|
|
187
|
+
};
|
|
188
|
+
/** Bridge source amount */
|
|
189
|
+
bridgeFromAmount: string;
|
|
190
|
+
/** Bridge destination amount */
|
|
191
|
+
bridgeToAmount: string;
|
|
192
|
+
/** Bridge start timestamp */
|
|
193
|
+
bridgeStartAt: string;
|
|
194
|
+
/** Bridge end timestamp (optional) */
|
|
195
|
+
bridgeEndAt?: string;
|
|
196
|
+
/** Bridge fee amount */
|
|
197
|
+
bridgeFeeAmount: string;
|
|
198
|
+
/** Source chain transaction hash */
|
|
199
|
+
bridgeSourceTxHash: string;
|
|
200
|
+
/** Destination chain transaction hash (optional) */
|
|
201
|
+
bridgeDestTxHash?: string;
|
|
202
|
+
/** Refund transaction hash (optional) */
|
|
203
|
+
bridgeRefundTxHash?: string;
|
|
204
|
+
/** Block explorer link (optional) */
|
|
205
|
+
explorerLink?: string;
|
|
206
|
+
/** Mayan-specific data (optional) */
|
|
207
|
+
mayan?: any;
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,mCAAmC;IACnC,cAAc,EAAE,KAAK,CAAA;IACrB,iCAAiC;IACjC,MAAM,EAAE;QACN,oCAAoC;QACpC,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,mCAAmC;IACnC,cAAc,EAAE;QACd,6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AAA;IAChB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAA;IACtB,8BAA8B;IAC9B,YAAY,EAAE,gBAAgB,CAAA;IAC9B,kCAAkC;IAClC,eAAe,EAAE;QACf,oBAAoB;QACpB,OAAO,EAAE,MAAM,CAAA;QACf,mBAAmB;QACnB,MAAM,EAAE,MAAM,CAAA;QACd,qBAAqB;QACrB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,uCAAuC;IACvC,aAAa,EAAE;QACb,oBAAoB;QACpB,OAAO,EAAE,MAAM,CAAA;QACf,mBAAmB;QACnB,MAAM,EAAE,MAAM,CAAA;QACd,qBAAqB;QACrB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,2BAA2B;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAA;IACtB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wBAAwB;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,yCAAyC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qCAAqC;IACrC,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@naviprotocol/astros-bridge-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "NAVI Astros Aggregator SDK",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"navi",
|
|
8
|
+
"astros",
|
|
9
|
+
"aggregator",
|
|
10
|
+
"sui"
|
|
11
|
+
],
|
|
12
|
+
"author": "NAVI",
|
|
13
|
+
"homepage": "https://navprotocol.io",
|
|
14
|
+
"bugs": "https://github.com/naviprotocol/naviprotocol-monorepo/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/naviprotocol/naviprotocol-monorepo.git"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.cjs.js",
|
|
20
|
+
"module": "dist/index.esm.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"source": "src/index.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"node": "./dist/index.cjs.js",
|
|
33
|
+
"default": "./dist/index.esm.js"
|
|
34
|
+
},
|
|
35
|
+
"require": "./dist/index.cjs.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "run-p build:lib",
|
|
43
|
+
"build:lib": "vite build",
|
|
44
|
+
"prettier": "prettier --check src/",
|
|
45
|
+
"prettier:fix": "prettier --write src/",
|
|
46
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
47
|
+
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
48
|
+
"verify": "run-p prettier lint",
|
|
49
|
+
"verify:fix": "run-p prettier:fix lint:fix",
|
|
50
|
+
"test": "vitest --config ./vite.config.unit.js",
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"test:coverage": "vitest run --coverage",
|
|
53
|
+
"typedoc": "typedoc"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@mayanfinance/swap-sdk": "10.9.0",
|
|
57
|
+
"@mysten/sui": "1.34.0",
|
|
58
|
+
"@solana/web3.js": "1.98.2",
|
|
59
|
+
"axios": "1.11.0",
|
|
60
|
+
"ethers": "6.13.5"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^20.19.1",
|
|
64
|
+
"tsconfig-paths": "^4.2.0",
|
|
65
|
+
"tslint": "^6.1.3",
|
|
66
|
+
"typescript": "5.8.3",
|
|
67
|
+
"vitest": "^3.2.2"
|
|
68
|
+
}
|
|
69
|
+
}
|