Added more tx types

This commit is contained in:
Aleksandr Kraiz
2023-08-23 18:19:22 +04:00
parent f5a21ced67
commit 9e0325b726
3 changed files with 56 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.19.61",
"version": "0.19.62",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -3,7 +3,7 @@ import type {
Unit, AtomicSwapLocal, SupportedChainId, TransactionInfo, AtomicSwap
} from '../../index.js';
import { INTERNAL_PROTOCOL_PRECISION, TxStatus, TxType } from '../../index.js';
import getHistoryExt from './getHistory.js';
import getHistory from './getHistory.js';
import swapExt from './swap.js';
import { BigNumber } from 'bignumber.js';
@@ -243,7 +243,7 @@ export default class Bridge {
}
getHistory(address: string, limit = 1000) {
return getHistoryExt(this.unitsArray, address, limit);
return getHistory(this.unitsArray, address, limit);
}
swap(

View File

@@ -329,29 +329,69 @@ export enum TxStatus {
}
export enum TxType {
SWAP_THROUGH_ORION_POOL = 'SWAP_THROUGH_ORION_POOL',
DEPOSIT = 'DEPOSIT',
WITHDRAW = 'WITHDRAW',
BRIDGE_LOCK = 'BRIDGE_LOCK',
BRIDGE_REDEEM = 'BRIDGE_REDEEM',
BRIDGE_REFUND = 'BRIDGE_REFUND',
LIQUIDITY_MIGRATION = 'LIQUIDITY_MIGRATION',
REDEEM_TWO_ATOMICS = 'REDEEM_TWO_ATOMICS',
}
type BridgeRedeemTxPayload = {
type: TxType.BRIDGE_REDEEM
export type TxDepositOrWithdrawPayload = {
type: TxType.DEPOSIT | TxType.WITHDRAW
data: {
asset: string
amount: string
}
};
export type TxSwapThroughOrionPoolPayload = {
type: TxType.SWAP_THROUGH_ORION_POOL
data: {
side: 'buy' | 'sell'
assetIn: string
assetOut: string
amount: string
price: string
}
};
type TxBridgePayload = {
type: TxType.BRIDGE_LOCK | TxType.BRIDGE_REDEEM | TxType.BRIDGE_REFUND
data: {
secretHash: string
}
}
type BridgeLockTxPayload = {
type: TxType.BRIDGE_LOCK
type TxLiquidityMigrationPayload = {
type: TxType.LIQUIDITY_MIGRATION
data: {
secretHash: string
source: SupportedChainId
target: SupportedChainId
pair: string
pairAddress: string
assetA: {
amount: string
secretHash: string
secret: string
}
assetB: {
amount: string
secretHash: string
secret: string
}
expiration: number
env?: string
}
}
type BridgeRefundTxPayload = {
type: TxType.BRIDGE_REFUND
type TxRedeemTwoAtomicsPayload = {
type: TxType.REDEEM_TWO_ATOMICS
data: {
secretHash: string
secretHash1: string
secretHash2: string
}
}
@@ -359,7 +399,11 @@ export type TransactionInfo = {
id?: string
status?: TxStatus
hash?: string
payload?: BridgeLockTxPayload | BridgeRedeemTxPayload | BridgeRefundTxPayload
payload?: TxDepositOrWithdrawPayload
| TxSwapThroughOrionPoolPayload
| TxBridgePayload
| TxLiquidityMigrationPayload
| TxRedeemTwoAtomicsPayload
}
type BridgeHistory = Awaited<ReturnType<typeof getHistory>>;