Skip to content

Commit

Permalink
feat: update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoDex committed Dec 25, 2024
1 parent 71f9c17 commit 7c0ea25
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/SparkPerpetual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Account,
Provider,
Wallet,
WalletLocked,
WalletUnlocked,
} from "fuels";

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/contracts/AccountBalanceContract.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions src/contracts/ClearingHouseContract.ts
Original file line number Diff line number Diff line change
@@ -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 "..";

Expand Down
11 changes: 6 additions & 5 deletions src/contracts/PerpMarketContract.ts
Original file line number Diff line number Diff line change
@@ -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 "..";

Expand Down
11 changes: 6 additions & 5 deletions src/contracts/VaultContract.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/query/indexerQuery.ts
Original file line number Diff line number Diff line change
@@ -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 "..";

Expand Down
3 changes: 2 additions & 1 deletion src/utils/GraphClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NormalizedCacheObject>;
wsConnection: Nullable<GraphQLWsLink>;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/createIdentity.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
3 changes: 2 additions & 1 deletion src/utils/sendTransaction.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"baseUrl": ".",
"declaration": true,
"paths": {
"src/*": ["./src/*"]
"@src/*": ["./src/*"]
},
"ignoreDeprecations": "5.0",
"allowSyntheticDefaultImports": true,
Expand Down

0 comments on commit 7c0ea25

Please sign in to comment.