@zebec-network/exchange-card-sdk 1.5.0-beta.2 → 1.5.0-beta.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./artifacts";
2
+ export * from "./helpers/apiHelpers";
2
3
  export * from "./constants";
3
4
  export * from "./services";
4
5
  export * from "./types";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./artifacts";
2
+ export * from "./helpers/apiHelpers";
2
3
  export * from "./constants";
3
4
  export * from "./services";
4
5
  export * from "./types";
@@ -4,4 +4,3 @@ export * from "./nearService";
4
4
  export * from "./algorandService";
5
5
  export * from "./xdbService";
6
6
  export * from "./octaService";
7
- export * from "./zanoService";
@@ -5,4 +5,3 @@ export * from "./nearService";
5
5
  export * from "./algorandService";
6
6
  export * from "./xdbService";
7
7
  export * from "./octaService";
8
- export * from "./zanoService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/exchange-card-sdk",
3
- "version": "1.5.0-beta.2",
3
+ "version": "1.5.0-beta.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",
@@ -64,4 +64,4 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  }
67
- }
67
+ }
@@ -1,56 +0,0 @@
1
- import { APIAsset, BalanceInfo } from "zano_web3/server";
2
- import { APIConfig } from "../helpers/apiHelpers";
3
- import { Quote } from "../types";
4
- export interface ZanoServiceConfig {
5
- walletUrl: string;
6
- daemonUrl: string;
7
- walletAuthToken: string;
8
- }
9
- export interface ZanoTransferParams {
10
- assetId: string;
11
- amount: string;
12
- comment?: string;
13
- }
14
- export declare class ZanoService {
15
- readonly apiConfig: APIConfig;
16
- private readonly serverWallet;
17
- private readonly apiService;
18
- constructor(config: ZanoServiceConfig, apiConfig: APIConfig, sdkOptions?: {
19
- sandbox?: boolean;
20
- });
21
- /**
22
- * Fetches a quote for Bitcoin transfer.
23
- *
24
- * @returns {Promise<Quote>} A promise that resolves to a Quote object.
25
- */
26
- fetchQuote(symbol?: string): Promise<Quote>;
27
- /**
28
- * Fetches the Bitcoin vault address.
29
- *
30
- * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
31
- */
32
- fetchVault(symbol?: string): Promise<{
33
- address: string;
34
- tag?: string;
35
- }>;
36
- /**
37
- * Send a transfer
38
- */
39
- transferAssets(params: ZanoTransferParams): Promise<string>;
40
- /**
41
- * Get asset information
42
- */
43
- getAssetDetails(assetId: string): Promise<APIAsset>;
44
- /**
45
- * Validate if the amount is valid for the given asset
46
- */
47
- validateAmount(amount: string, decimalPoints: number): boolean;
48
- /**
49
- * Get wallet balances
50
- */
51
- getBalances(): Promise<BalanceInfo[]>;
52
- /**
53
- * Get balance for a specific asset
54
- */
55
- getAssetBalance(assetId: string): Promise<BalanceInfo | null>;
56
- }
@@ -1,107 +0,0 @@
1
- import { BigNumber } from "bignumber.js";
2
- import { ServerWallet } from "zano_web3/server";
3
- import { ZebecCardAPIService } from "../helpers/apiHelpers";
4
- export class ZanoService {
5
- apiConfig;
6
- serverWallet;
7
- apiService;
8
- // private readonly network: "mainnet" | "testnet";
9
- constructor(config, apiConfig, sdkOptions) {
10
- this.apiConfig = apiConfig;
11
- // this.network = sdkOptions?.sandbox ? "testnet" : "mainnet";
12
- this.apiService = new ZebecCardAPIService(apiConfig, sdkOptions?.sandbox || false);
13
- this.serverWallet = new ServerWallet({
14
- walletUrl: config.walletUrl,
15
- daemonUrl: config.daemonUrl,
16
- walletAuthToken: config.walletAuthToken,
17
- });
18
- }
19
- /**
20
- * Fetches a quote for Bitcoin transfer.
21
- *
22
- * @returns {Promise<Quote>} A promise that resolves to a Quote object.
23
- */
24
- async fetchQuote(symbol = "ZANO") {
25
- const res = await this.apiService.fetchQuote(symbol);
26
- return res;
27
- }
28
- /**
29
- * Fetches the Bitcoin vault address.
30
- *
31
- * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
32
- */
33
- async fetchVault(symbol = "ZANO") {
34
- const data = await this.apiService.fetchVault(symbol);
35
- return data;
36
- }
37
- /**
38
- * Send a transfer
39
- */
40
- async transferAssets(params) {
41
- // Check if we have sufficient balance
42
- const balances = await this.serverWallet.getBalances();
43
- const assetBalance = balances.find((balance) => balance.asset_info.asset_id === params.assetId);
44
- if (assetBalance) {
45
- const availableBalance = BigNumber(assetBalance.unlocked);
46
- const fee = BigNumber(0.1);
47
- const transferAmount = BigNumber(params.amount).plus(fee);
48
- if (transferAmount.isGreaterThan(availableBalance)) {
49
- throw new Error(`Insufficient balance. Available: ${assetBalance.unlocked} ${assetBalance.ticker || "tokens"}`);
50
- }
51
- }
52
- else {
53
- throw new Error(`Sender does not have ${params.assetId} balance.`);
54
- }
55
- const vault = await this.fetchVault("ZANO");
56
- const receiver = vault.address;
57
- // Send the transfer
58
- const result = await this.serverWallet.sendTransfer(params.assetId, receiver, params.amount);
59
- console.debug("result:", result);
60
- return result.tx_hash;
61
- }
62
- /**
63
- * Get asset information
64
- */
65
- async getAssetDetails(assetId) {
66
- try {
67
- return await this.serverWallet.getAssetDetails(assetId);
68
- }
69
- catch (error) {
70
- console.error(`Error getting asset info for ${assetId}:`, error);
71
- throw error;
72
- }
73
- }
74
- /**
75
- * Validate if the amount is valid for the given asset
76
- */
77
- validateAmount(amount, decimalPoints) {
78
- const decimals = BigNumber(amount).decimalPlaces();
79
- return Boolean(decimals) && decimals == decimalPoints;
80
- }
81
- /**
82
- * Get wallet balances
83
- */
84
- async getBalances() {
85
- try {
86
- const balances = await this.serverWallet.getBalances();
87
- return balances;
88
- }
89
- catch (error) {
90
- console.error("Error getting balances:", error);
91
- throw error;
92
- }
93
- }
94
- /**
95
- * Get balance for a specific asset
96
- */
97
- async getAssetBalance(assetId) {
98
- try {
99
- const balances = await this.getBalances();
100
- return balances.find((balance) => balance.asset_info.asset_id === assetId) || null;
101
- }
102
- catch (error) {
103
- console.error(`Error getting balance for asset ${assetId}:`, error);
104
- return null;
105
- }
106
- }
107
- }