@zebec-network/exchange-card-sdk 1.3.1 → 1.4.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,79 +1,3 @@
1
- export declare const ZEBEC_CARD_ABI: ({
2
- inputs: {
3
- internalType: string;
4
- name: string;
5
- type: string;
6
- }[];
7
- name: string;
8
- type: string;
9
- anonymous?: undefined;
10
- outputs?: undefined;
11
- stateMutability?: undefined;
12
- } | {
13
- anonymous: boolean;
14
- inputs: {
15
- indexed: boolean;
16
- internalType: string;
17
- name: string;
18
- type: string;
19
- }[];
20
- name: string;
21
- type: string;
22
- outputs?: undefined;
23
- stateMutability?: undefined;
24
- } | {
25
- inputs: {
26
- internalType: string;
27
- name: string;
28
- type: string;
29
- }[];
30
- name: string;
31
- outputs: {
32
- internalType: string;
33
- name: string;
34
- type: string;
35
- }[];
36
- stateMutability: string;
37
- type: string;
38
- anonymous?: undefined;
39
- } | {
40
- inputs: never[];
41
- name: string;
42
- outputs: {
43
- components: {
44
- internalType: string;
45
- name: string;
46
- type: string;
47
- }[];
48
- internalType: string;
49
- name: string;
50
- type: string;
51
- }[];
52
- stateMutability: string;
53
- type: string;
54
- anonymous?: undefined;
55
- } | {
56
- inputs: ({
57
- components: {
58
- internalType: string;
59
- name: string;
60
- type: string;
61
- }[];
62
- internalType: string;
63
- name: string;
64
- type: string;
65
- } | {
66
- internalType: string;
67
- name: string;
68
- type: string;
69
- components?: undefined;
70
- })[];
71
- name: string;
72
- outputs: never[];
73
- stateMutability: string;
74
- type: string;
75
- anonymous?: undefined;
76
- })[];
77
1
  export declare const ERC20_ABI: ({
78
2
  inputs: never[];
79
3
  stateMutability: string;
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ERC20_ABI = exports.ZEBEC_CARD_ABI = void 0;
6
+ exports.ERC20_ABI = void 0;
7
7
  const ERC20_json_1 = __importDefault(require("./ERC20.json"));
8
- const ZebecCard_json_1 = __importDefault(require("./ZebecCard.json"));
9
- exports.ZEBEC_CARD_ABI = ZebecCard_json_1.default.abi;
10
8
  exports.ERC20_ABI = ERC20_json_1.default.abi;
@@ -1,2 +1 @@
1
1
  export { ERC20__factory } from "./ERC20__factory";
2
- export { ZebecCard__factory } from "./ZebecCard__factory";
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZebecCard__factory = exports.ERC20__factory = void 0;
3
+ exports.ERC20__factory = void 0;
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
  /* tslint:disable */
6
6
  /* eslint-disable */
7
7
  var ERC20__factory_1 = require("./ERC20__factory");
8
8
  Object.defineProperty(exports, "ERC20__factory", { enumerable: true, get: function () { return ERC20__factory_1.ERC20__factory; } });
9
- var ZebecCard__factory_1 = require("./ZebecCard__factory");
10
- Object.defineProperty(exports, "ZebecCard__factory", { enumerable: true, get: function () { return ZebecCard__factory_1.ZebecCard__factory; } });
@@ -1,5 +1,3 @@
1
1
  export type { ERC20 } from "./ERC20";
2
- export type { ZebecCard } from "./ZebecCard";
3
2
  export * as factories from "./factories";
4
3
  export { ERC20__factory } from "./factories/ERC20__factory";
5
- export { ZebecCard__factory } from "./factories/ZebecCard__factory";
@@ -33,9 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ZebecCard__factory = exports.ERC20__factory = exports.factories = void 0;
36
+ exports.ERC20__factory = exports.factories = void 0;
37
37
  exports.factories = __importStar(require("./factories"));
38
38
  var ERC20__factory_1 = require("./factories/ERC20__factory");
39
39
  Object.defineProperty(exports, "ERC20__factory", { enumerable: true, get: function () { return ERC20__factory_1.ERC20__factory; } });
40
- var ZebecCard__factory_1 = require("./factories/ZebecCard__factory");
41
- Object.defineProperty(exports, "ZebecCard__factory", { enumerable: true, get: function () { return ZebecCard__factory_1.ZebecCard__factory; } });
@@ -15,6 +15,7 @@ export declare const BITCOIN_ENDPOINTS: {
15
15
  readonly Sandbox: "https://mempool.space/testnet/api";
16
16
  readonly Production: "https://mempool.space/api";
17
17
  };
18
+ export declare const DEFAULT_EVM_GAS_LIMIT = 3000000;
18
19
  export declare const COUNTRIES_WITH_CCA3: readonly [{
19
20
  readonly name: {
20
21
  readonly common: "South Georgia";
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLATFORM_FEE = exports.COUNTRIES_WITH_CCA3 = exports.BITCOIN_ENDPOINTS = exports.STELLAR_USDC_ISSUER = exports.XDB_NETWORK = exports.XDB_RPC_URL = exports.STELLAR_RPC_URL = exports.XRPL_RPC_URL = exports.NEAR_RPC_URL = exports.CARD_API_URL = void 0;
3
+ exports.PLATFORM_FEE = exports.COUNTRIES_WITH_CCA3 = exports.DEFAULT_EVM_GAS_LIMIT = exports.BITCOIN_ENDPOINTS = exports.STELLAR_USDC_ISSUER = exports.XDB_NETWORK = exports.XDB_RPC_URL = exports.STELLAR_RPC_URL = exports.XRPL_RPC_URL = exports.NEAR_RPC_URL = exports.CARD_API_URL = void 0;
4
4
  exports.CARD_API_URL = {
5
5
  Production: "https://cex.card.zebec.io",
6
6
  Sandbox: "https://cex.card.zebec.io",
@@ -34,6 +34,7 @@ exports.BITCOIN_ENDPOINTS = {
34
34
  Sandbox: "https://mempool.space/testnet/api",
35
35
  Production: "https://mempool.space/api",
36
36
  };
37
+ exports.DEFAULT_EVM_GAS_LIMIT = 3000000;
37
38
  exports.COUNTRIES_WITH_CCA3 = [
38
39
  {
39
40
  name: {
@@ -3,3 +3,4 @@ export * from "./xrplService";
3
3
  export * from "./nearService";
4
4
  export * from "./algorandService";
5
5
  export * from "./xdbService";
6
+ export * from "./octaService";
@@ -20,3 +20,4 @@ __exportStar(require("./xrplService"), exports);
20
20
  __exportStar(require("./nearService"), exports);
21
21
  __exportStar(require("./algorandService"), exports);
22
22
  __exportStar(require("./xdbService"), exports);
23
+ __exportStar(require("./octaService"), exports);
@@ -0,0 +1,31 @@
1
+ import { ethers } from "ethers";
2
+ import { APIConfig } from "../helpers/apiHelpers";
3
+ import { Quote } from "../types";
4
+ export type TransferOctaParams = {
5
+ amount: string | number;
6
+ overrides?: Omit<ethers.Overrides, "from" | "value" | "chainId">;
7
+ };
8
+ export declare class OctaService {
9
+ readonly signer: ethers.Signer;
10
+ readonly apiConfig: APIConfig;
11
+ private apiService;
12
+ constructor(signer: ethers.Signer, apiConfig: APIConfig, sdkOptions?: {
13
+ sandbox?: boolean;
14
+ });
15
+ /**
16
+ * Fetches a quote for Bitcoin transfer.
17
+ *
18
+ * @returns {Promise<Quote>} A promise that resolves to a Quote object.
19
+ */
20
+ fetchQuote(symbol?: string): Promise<Quote>;
21
+ /**
22
+ * Fetches the Bitcoin vault address.
23
+ *
24
+ * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
25
+ */
26
+ fetchVault(symbol?: string): Promise<{
27
+ address: string;
28
+ tag?: string;
29
+ }>;
30
+ transferOcta(params: TransferOctaParams): Promise<ethers.TransactionReceipt | null>;
31
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OctaService = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const constants_1 = require("../constants");
6
+ const apiHelpers_1 = require("../helpers/apiHelpers");
7
+ class OctaService {
8
+ signer;
9
+ apiConfig;
10
+ apiService;
11
+ constructor(signer, apiConfig, sdkOptions) {
12
+ this.signer = signer;
13
+ this.apiConfig = apiConfig;
14
+ this.apiService = new apiHelpers_1.ZebecCardAPIService(apiConfig, sdkOptions?.sandbox || false);
15
+ }
16
+ /**
17
+ * Fetches a quote for Bitcoin transfer.
18
+ *
19
+ * @returns {Promise<Quote>} A promise that resolves to a Quote object.
20
+ */
21
+ async fetchQuote(symbol = "OCTA") {
22
+ const res = await this.apiService.fetchQuote(symbol);
23
+ return res;
24
+ }
25
+ /**
26
+ * Fetches the Bitcoin vault address.
27
+ *
28
+ * @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
29
+ */
30
+ async fetchVault(symbol = "OCTA") {
31
+ const data = await this.apiService.fetchVault(symbol);
32
+ return data;
33
+ }
34
+ async transferOcta(params) {
35
+ const parsedAmount = (0, ethers_1.parseEther)(params.amount.toString());
36
+ const provider = this.signer.provider;
37
+ const vault = await this.fetchVault();
38
+ const recipientAddress = vault.address;
39
+ if (!provider) {
40
+ throw new Error("There is no provider in signer instance.");
41
+ }
42
+ const senderBalance = await provider.getBalance(this.signer);
43
+ if (senderBalance < parsedAmount) {
44
+ throw new Error("Insufficient balance for transaction.");
45
+ }
46
+ const overides = {
47
+ ...params.overrides,
48
+ gasLimit: constants_1.DEFAULT_EVM_GAS_LIMIT,
49
+ };
50
+ const response = await this.signer.sendTransaction({
51
+ ...overides,
52
+ to: recipientAddress,
53
+ value: parsedAmount,
54
+ from: this.signer,
55
+ chainId: 800001,
56
+ });
57
+ console.debug("Octa Transaction Hash:", response.hash);
58
+ const receipt = await response.wait();
59
+ return receipt;
60
+ }
61
+ }
62
+ exports.OctaService = OctaService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/exchange-card-sdk",
3
- "version": "1.3.1",
3
+ "version": "1.4.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",
@@ -47,6 +47,7 @@
47
47
  "axios": "^1.7.7",
48
48
  "bignumber.js": "^9.3.0",
49
49
  "bitcoinjs-lib": "^6.1.7",
50
+ "ethers": "^6.15.0",
50
51
  "xrpl": "^4.2.5"
51
52
  },
52
53
  "repository": {