@zebec-network/exchange-card-sdk 1.2.1 → 1.2.3

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.
@@ -7,7 +7,7 @@ export interface TransferConfig {
7
7
  note?: string;
8
8
  }
9
9
  export interface AlgorandWallet {
10
- address: algosdk.Address;
10
+ address: string;
11
11
  signAndSendTransaction: (txn: algosdk.Transaction) => Promise<string>;
12
12
  }
13
13
  export declare class AlgorandService {
@@ -1,11 +1,14 @@
1
- import { StellarWalletsKit } from "@creit.tech/stellar-wallets-kit";
2
- import { Asset } from "@stellar/stellar-sdk";
1
+ import { Asset, Horizon } from "@stellar/stellar-sdk";
3
2
  import { APIConfig } from "../helpers/apiHelpers";
4
3
  import { Quote } from "../types";
4
+ export interface StellarWallet {
5
+ address: string;
6
+ signTransaction: (txXdr: string) => Promise<string>;
7
+ }
5
8
  export declare class StellarService {
6
- readonly kit: StellarWalletsKit;
9
+ readonly wallet: StellarWallet;
7
10
  private apiService;
8
- private server;
11
+ readonly server: Horizon.Server;
9
12
  private sandbox;
10
13
  /**
11
14
  * Constructs an instance of the service.
@@ -14,7 +17,7 @@ export declare class StellarService {
14
17
  * @param {APIConfig} apiConfig - The configuration object for the API.
15
18
  * @param sdkOptions - Optional configuration for the SDK.
16
19
  */
17
- constructor(kit: StellarWalletsKit, apiConfig: APIConfig, sdkOptions?: {
20
+ constructor(wallet: StellarWallet, apiConfig: APIConfig, sdkOptions?: {
18
21
  sandbox?: boolean;
19
22
  apiKey?: string;
20
23
  });
@@ -5,7 +5,7 @@ const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
5
  const constants_1 = require("../constants");
6
6
  const apiHelpers_1 = require("../helpers/apiHelpers");
7
7
  class StellarService {
8
- kit;
8
+ wallet;
9
9
  apiService;
10
10
  server;
11
11
  sandbox;
@@ -16,8 +16,8 @@ class StellarService {
16
16
  * @param {APIConfig} apiConfig - The configuration object for the API.
17
17
  * @param sdkOptions - Optional configuration for the SDK.
18
18
  */
19
- constructor(kit, apiConfig, sdkOptions) {
20
- this.kit = kit;
19
+ constructor(wallet, apiConfig, sdkOptions) {
20
+ this.wallet = wallet;
21
21
  const sandbox = sdkOptions?.sandbox ? sdkOptions.sandbox : false;
22
22
  this.apiService = new apiHelpers_1.ZebecCardAPIService(apiConfig, sandbox);
23
23
  this.server = new stellar_sdk_1.Horizon.Server(sandbox ? constants_1.STELLAR_RPC_URL.Sandbox : constants_1.STELLAR_RPC_URL.Production);
@@ -62,13 +62,12 @@ class StellarService {
62
62
  async transferXLM(amount) {
63
63
  // Fetch deposit address
64
64
  const vault = await this.fetchVault();
65
- const accountAddress = await this.kit.getAddress();
66
65
  // Prepare transaction
67
- const account = await this.server.loadAccount(accountAddress.address);
66
+ const account = await this.server.loadAccount(this.wallet.address);
68
67
  const fee = await this.server.fetchBaseFee();
69
68
  const memo = stellar_sdk_1.Memo.id(vault.tag?.toString() || "");
70
69
  // Check Wallet balance
71
- const balance = await this.getWalletBalance(accountAddress.address);
70
+ const balance = await this.getWalletBalance(this.wallet.address);
72
71
  if (Number(balance) < Number(amount)) {
73
72
  throw new Error("Insufficient balance");
74
73
  }
@@ -86,7 +85,7 @@ class StellarService {
86
85
  .setTimeout(stellar_sdk_1.TimeoutInfinite)
87
86
  .build();
88
87
  // Sign the transaction
89
- const { signedTxXdr } = await this.kit.signTransaction(transaction.toXDR());
88
+ const signedTxXdr = await this.wallet.signTransaction(transaction.toXDR());
90
89
  const tx = stellar_sdk_1.TransactionBuilder.fromXDR(signedTxXdr, this.sandbox ? stellar_sdk_1.Networks.TESTNET : stellar_sdk_1.Networks.PUBLIC);
91
90
  let retries = 0;
92
91
  const maxRetries = 5;
@@ -122,14 +121,13 @@ class StellarService {
122
121
  async transferUSDC(amount) {
123
122
  // Fetch deposit address
124
123
  const vault = await this.fetchUSDCVault();
125
- const accountAddress = await this.kit.getAddress();
126
124
  // Prepare transaction
127
- const account = await this.server.loadAccount(accountAddress.address);
125
+ const account = await this.server.loadAccount(this.wallet.address);
128
126
  const fee = await this.server.fetchBaseFee();
129
127
  // Create USDC asset object
130
128
  const usdcAsset = new stellar_sdk_1.Asset("USDC", this.sandbox ? constants_1.STELLAR_USDC_ISSUER.Sandbox : constants_1.STELLAR_USDC_ISSUER.Production);
131
129
  // Check Wallet balance
132
- const balance = await this.getTokenBalance(accountAddress.address, usdcAsset);
130
+ const balance = await this.getTokenBalance(this.wallet.address, usdcAsset);
133
131
  if (Number(balance) < Number(amount)) {
134
132
  throw new Error("Insufficient USDC balance");
135
133
  }
@@ -146,7 +144,7 @@ class StellarService {
146
144
  .setTimeout(stellar_sdk_1.TimeoutInfinite)
147
145
  .build();
148
146
  // Sign the transaction
149
- const { signedTxXdr } = await this.kit.signTransaction(transaction.toXDR());
147
+ const signedTxXdr = await this.wallet.signTransaction(transaction.toXDR());
150
148
  const tx = stellar_sdk_1.TransactionBuilder.fromXDR(signedTxXdr, this.sandbox ? stellar_sdk_1.Networks.TESTNET : stellar_sdk_1.Networks.PUBLIC);
151
149
  let retries = 0;
152
150
  const maxRetries = 5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/exchange-card-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "An sdk for purchasing silver card in zebec",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,7 +36,6 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@algorandfoundation/algokit-utils": "^9.1.1",
39
- "@creit.tech/stellar-wallets-kit": "^1.7.1",
40
39
  "@mempool/mempool.js": "^3.0.0",
41
40
  "@near-js/crypto": "^2.0.1",
42
41
  "@near-js/providers": "^2.0.1",