From 7c0ea259a1ef10d8eb928866492e2a1bf20bcfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B8b=C4=97rt=C3=B8?= <106074508+EchoDex@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:38:20 +0400 Subject: [PATCH] feat: update logic --- package.json | 2 +- src/SparkPerpetual.ts | 5 +++++ src/contracts/AccountBalanceContract.ts | 5 +++-- src/contracts/ClearingHouseContract.ts | 9 +++++---- src/contracts/PerpMarketContract.ts | 11 ++++++----- src/contracts/VaultContract.ts | 11 ++++++----- src/query/indexerQuery.ts | 3 ++- src/utils/GraphClient.ts | 3 ++- src/utils/createIdentity.ts | 3 ++- src/utils/sendTransaction.ts | 3 ++- tsconfig.json | 2 +- 11 files changed, 35 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index dca6d32..278ebf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@compolabs/spark-perpetual-ts-sdk", - "version": "0.0.2", + "version": "0.0.3", "type": "module", "main": "./dist/index.сjs", "module": "./dist/index.js", diff --git a/src/SparkPerpetual.ts b/src/SparkPerpetual.ts index a3aa882..1744eed 100644 --- a/src/SparkPerpetual.ts +++ b/src/SparkPerpetual.ts @@ -3,6 +3,7 @@ import { Account, Provider, Wallet, + WalletLocked, WalletUnlocked, } from "fuels"; @@ -45,6 +46,10 @@ export class SparkPerpetual { return { ...this.options, wallet: providerWallet }; } + setActiveWallet(wallet?: WalletLocked | WalletUnlocked): void { + this.options.wallet = wallet; + } + private getWriteOptions(): Options { if (!this.options.wallet) { throw new NetworkError(NETWORK_ERROR.UNKNOWN_WALLET); diff --git a/src/contracts/AccountBalanceContract.ts b/src/contracts/AccountBalanceContract.ts index 03c40d2..c9b5802 100644 --- a/src/contracts/AccountBalanceContract.ts +++ b/src/contracts/AccountBalanceContract.ts @@ -1,12 +1,13 @@ import { AbstractAddress, Account, Provider } from "fuels"; + import { createAddressIdentity, createAssetIdInput, createI64Input, fuelBNToBN, i64ToBN, -} from "src/utils/createIdentity"; -import { sendTransaction } from "src/utils/sendTransaction"; +} from "@src/utils/createIdentity"; +import { sendTransaction } from "@src/utils/sendTransaction"; import { AccountBalance } from "../types/account-balance"; import { diff --git a/src/contracts/ClearingHouseContract.ts b/src/contracts/ClearingHouseContract.ts index 78b7550..0ac99bd 100644 --- a/src/contracts/ClearingHouseContract.ts +++ b/src/contracts/ClearingHouseContract.ts @@ -1,14 +1,15 @@ import { AbstractAddress, Account, Provider } from "fuels"; -import { WriteTransactionResponse } from "src/interface"; -import { ClearingHouse } from "src/types/clearing-house"; + +import { WriteTransactionResponse } from "@src/interface"; +import { ClearingHouse } from "@src/types/clearing-house"; import { createAddressIdentity, createAssetIdInput, createI64Input, fuelBNToBN, i64ToBN, -} from "src/utils/createIdentity"; -import { sendTransaction } from "src/utils/sendTransaction"; +} from "@src/utils/createIdentity"; +import { sendTransaction } from "@src/utils/sendTransaction"; import { BN } from ".."; diff --git a/src/contracts/PerpMarketContract.ts b/src/contracts/PerpMarketContract.ts index 966d6ec..9926bd8 100644 --- a/src/contracts/PerpMarketContract.ts +++ b/src/contracts/PerpMarketContract.ts @@ -1,21 +1,22 @@ import { AbstractAddress, Account, Provider } from "fuels"; +import { Undefinable } from "tsdef"; + import { Market, MarketStatus, Order, Twap, WriteTransactionResponse, -} from "src/interface"; -import { PerpMarket } from "src/types/perp-market"; +} from "@src/interface"; +import { PerpMarket } from "@src/types/perp-market"; import { createAddressIdentity, createAssetIdInput, createI64Input, fuelBNToBN, i64ToBN, -} from "src/utils/createIdentity"; -import { sendTransaction } from "src/utils/sendTransaction"; -import { Undefinable } from "tsdef"; +} from "@src/utils/createIdentity"; +import { sendTransaction } from "@src/utils/sendTransaction"; import { BN } from ".."; diff --git a/src/contracts/VaultContract.ts b/src/contracts/VaultContract.ts index ebc2f3a..af63c05 100644 --- a/src/contracts/VaultContract.ts +++ b/src/contracts/VaultContract.ts @@ -1,15 +1,16 @@ import { AbstractAddress, Account, Provider } from "fuels"; -import { Deposit, WriteTransactionResponse } from "src/interface"; -import { Vault } from "src/types/vault/Vault"; -import BN from "src/utils/BN"; + +import { Deposit, WriteTransactionResponse } from "@src/interface"; +import { Vault } from "@src/types/vault"; +import BN from "@src/utils/BN"; import { createAddressIdentity, createAssetIdInput, createForward, createI64Input, fuelBNToBN, -} from "src/utils/createIdentity"; -import { sendTransaction } from "src/utils/sendTransaction"; +} from "@src/utils/createIdentity"; +import { sendTransaction } from "@src/utils/sendTransaction"; export class VaultContract { private contract: Vault; diff --git a/src/query/indexerQuery.ts b/src/query/indexerQuery.ts index 51d174a..3283d4e 100644 --- a/src/query/indexerQuery.ts +++ b/src/query/indexerQuery.ts @@ -1,5 +1,6 @@ import { gql, QueryOptions } from "@apollo/client"; -import { generateWhereFilter } from "src/utils/generateWhereFilter"; + +import { generateWhereFilter } from "@src/utils/generateWhereFilter"; import { GetActiveOrdersParams, GetOrdersParams } from ".."; diff --git a/src/utils/GraphClient.ts b/src/utils/GraphClient.ts index b3a34a7..d13092b 100644 --- a/src/utils/GraphClient.ts +++ b/src/utils/GraphClient.ts @@ -8,9 +8,10 @@ import { import { GraphQLWsLink } from "@apollo/client/link/subscriptions"; import { getMainDefinition } from "@apollo/client/utilities"; import { createClient } from "graphql-ws"; -import { GraphClientConfig } from "src/interface"; import { Nullable } from "tsdef"; +import { GraphClientConfig } from "@src/interface"; + export class GraphClient { client: ApolloClient; wsConnection: Nullable; diff --git a/src/utils/createIdentity.ts b/src/utils/createIdentity.ts index c6d7757..ec72f59 100644 --- a/src/utils/createIdentity.ts +++ b/src/utils/createIdentity.ts @@ -1,5 +1,6 @@ import { Address, BN as FuelBN, CoinQuantityLike } from "fuels"; -import { Deposit } from "src/interface"; + +import { Deposit } from "@src/interface"; import BN from "./BN"; diff --git a/src/utils/sendTransaction.ts b/src/utils/sendTransaction.ts index 895f973..1647668 100644 --- a/src/utils/sendTransaction.ts +++ b/src/utils/sendTransaction.ts @@ -1,5 +1,6 @@ import type { FunctionInvocationScope } from "fuels"; -import { WriteTransactionResponse } from "src/interface"; + +import { WriteTransactionResponse } from "@src/interface"; export const sendTransaction = async ( tx: FunctionInvocationScope, diff --git a/tsconfig.json b/tsconfig.json index 9620dcf..1fa67f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "baseUrl": ".", "declaration": true, "paths": { - "src/*": ["./src/*"] + "@src/*": ["./src/*"] }, "ignoreDeprecations": "5.0", "allowSyntheticDefaultImports": true,