@zebec-network/exchange-card-sdk 1.6.1 → 1.7.1

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.
@@ -1,5 +1,4 @@
1
1
  import algosdk from "algosdk";
2
- import { AlgorandClient } from "@algorandfoundation/algokit-utils";
3
2
  import { APIConfig } from "../helpers/apiHelpers";
4
3
  import { Quote } from "../types";
5
4
  /**
@@ -26,9 +25,7 @@ export declare class AlgorandService {
26
25
  readonly wallet: AlgorandWallet;
27
26
  readonly apiConfig: APIConfig;
28
27
  readonly algodClient: algosdk.Algodv2;
29
- readonly algorandClient: AlgorandClient;
30
28
  private apiService;
31
- private readonly network;
32
29
  constructor(wallet: AlgorandWallet, apiConfig: APIConfig, sdkOptions?: {
33
30
  sandbox?: boolean;
34
31
  });
@@ -1,23 +1,17 @@
1
1
  import algosdk from "algosdk";
2
- import { AlgorandClient } from "@algorandfoundation/algokit-utils";
3
- import { ClientManager } from "@algorandfoundation/algokit-utils/types/client-manager";
2
+ import { ALGORAND_RPC_URL } from "../constants";
4
3
  import { ZebecCardAPIService } from "../helpers/apiHelpers";
5
4
  import { formatAlgo, formatAlgorandAsset, getAssetDecimals, parseAlgo, parseAlgorandAsset, } from "../utils";
6
5
  export class AlgorandService {
7
6
  wallet;
8
7
  apiConfig;
9
8
  algodClient;
10
- algorandClient;
11
9
  apiService;
12
- network;
13
10
  constructor(wallet, apiConfig, sdkOptions) {
14
11
  this.wallet = wallet;
15
12
  this.apiConfig = apiConfig;
16
- this.network = sdkOptions?.sandbox ? "testnet" : "mainnet";
17
- this.algodClient = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig(this.network, "algod"));
18
- this.algorandClient = AlgorandClient.fromClients({
19
- algod: this.algodClient,
20
- });
13
+ const rpcUrl = ALGORAND_RPC_URL[sdkOptions?.sandbox ? "Sandbox" : "Production"];
14
+ this.algodClient = new algosdk.Algodv2({}, rpcUrl, 443);
21
15
  this.apiService = new ZebecCardAPIService(apiConfig, sdkOptions?.sandbox || false);
22
16
  }
23
17
  /**
@@ -5,3 +5,4 @@ export * from "./algorandService";
5
5
  export * from "./xdbService";
6
6
  export * from "./octaService";
7
7
  export * from "./bobaService";
8
+ export * from "./quaiService";
@@ -1,4 +1,3 @@
1
- // export * from "./bitcoinService";
2
1
  export * from "./stellarService";
3
2
  export * from "./xrplService";
4
3
  export * from "./nearService";
@@ -6,3 +5,4 @@ export * from "./algorandService";
6
5
  export * from "./xdbService";
7
6
  export * from "./octaService";
8
7
  export * from "./bobaService";
8
+ export * from "./quaiService";
@@ -0,0 +1,35 @@
1
+ import { QuaiTransactionRequest } from "quais/providers";
2
+ import { APIConfig } from "../helpers/apiHelpers";
3
+ import { Quote } from "../types";
4
+ export type TransferQuaiParams = {
5
+ amount: string | number;
6
+ overrides?: Omit<QuaiTransactionRequest, "from" | "value" | "chainId">;
7
+ };
8
+ export type QuaiWallet = {
9
+ address: string;
10
+ signAndSendTransaction: (tx: QuaiTransactionRequest) => Promise<string>;
11
+ };
12
+ export declare class QuaiService {
13
+ readonly signer: QuaiWallet;
14
+ readonly apiConfig: APIConfig;
15
+ private apiService;
16
+ constructor(signer: QuaiWallet, apiConfig: APIConfig, sdkOptions?: {
17
+ sandbox?: boolean;
18
+ });
19
+ /**
20
+ * Fetches a quote for Bitcoin transfer.
21
+ *
22
+ * @returns {Promise<Quote>} A promise that resolves to a Quote object.
23
+ */
24
+ fetchQuote(symbol: string): Promise<Quote>;
25
+ /**
26
+ * Fetches the Bitcoin vault address.
27
+ *
28
+ * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
29
+ */
30
+ fetchVault(symbol: string): Promise<{
31
+ address: string;
32
+ tag?: string;
33
+ }>;
34
+ transferQuai(params: TransferQuaiParams): Promise<string>;
35
+ }
@@ -0,0 +1,46 @@
1
+ import { parseQuai } from "quais";
2
+ import { DEFAULT_QUAI_GAS_LIMIT } from "../constants";
3
+ import { ZebecCardAPIService } from "../helpers/apiHelpers";
4
+ export class QuaiService {
5
+ signer;
6
+ apiConfig;
7
+ apiService;
8
+ constructor(signer, apiConfig, sdkOptions) {
9
+ this.signer = signer;
10
+ this.apiConfig = apiConfig;
11
+ this.apiService = new ZebecCardAPIService(apiConfig, sdkOptions?.sandbox || false);
12
+ }
13
+ /**
14
+ * Fetches a quote for Bitcoin transfer.
15
+ *
16
+ * @returns {Promise<Quote>} A promise that resolves to a Quote object.
17
+ */
18
+ async fetchQuote(symbol) {
19
+ const res = await this.apiService.fetchQuote(symbol);
20
+ return res;
21
+ }
22
+ /**
23
+ * Fetches the Bitcoin vault address.
24
+ *
25
+ * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
26
+ */
27
+ async fetchVault(symbol) {
28
+ const data = await this.apiService.fetchVault(symbol);
29
+ return data;
30
+ }
31
+ async transferQuai(params) {
32
+ const parsedAmount = parseQuai(params.amount.toString());
33
+ const vault = await this.fetchVault("QUAI");
34
+ const recipientAddress = vault.address;
35
+ const request = {
36
+ ...params.overrides,
37
+ gasLimit: params.overrides?.gasLimit ?? DEFAULT_QUAI_GAS_LIMIT,
38
+ // gasPrice: params.overrides?.gasPrice ?? DEFAULT_QUAI_GAS_PRICE,
39
+ from: this.signer.address,
40
+ to: recipientAddress,
41
+ value: parsedAmount,
42
+ };
43
+ const hash = await this.signer.signAndSendTransaction(request);
44
+ return hash;
45
+ }
46
+ }
package/dist/types.d.ts CHANGED
@@ -4,3 +4,4 @@ export type Quote = {
4
4
  token: string;
5
5
  };
6
6
  export type BobaChainId = 288 | 28882;
7
+ export type QuaiChainId = 9 | 15000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/exchange-card-sdk",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "An sdk for purchasing silver card in zebec",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "gen:typechain": "typechain --target ethers-v6 --out-dir \"src/artifacts/typechain-types\" \"src/artifacts/abi/*.json\""
18
18
  },
19
19
  "devDependencies": {
20
+ "@algorandfoundation/algokit-utils": "^9.1.2",
20
21
  "@near-js/accounts": "^2.3.0",
21
22
  "@near-js/keystores": "^2.3.0",
22
23
  "@near-js/signers": "^2.3.0",
@@ -33,7 +34,6 @@
33
34
  "typescript": "^5.9.2"
34
35
  },
35
36
  "dependencies": {
36
- "@algorandfoundation/algokit-utils": "^9.1.2",
37
37
  "@near-js/crypto": "^2.3.0",
38
38
  "@near-js/providers": "^2.3.0",
39
39
  "@near-js/transactions": "^2.3.0",
@@ -45,6 +45,7 @@
45
45
  "bignumber.js": "^9.3.1",
46
46
  "bitcoinjs-lib": "^6.1.7",
47
47
  "ethers": "^6.15.0",
48
+ "quais": "^1.0.0-alpha.52",
48
49
  "xrpl": "^4.4.1"
49
50
  },
50
51
  "repository": {