@morambacrypto/connect 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -35,6 +35,49 @@ const response = await client.auth.createJwtToken({ userid: "test@gmail.com" });
35
35
  console.log(response.data.token);
36
36
  ```
37
37
 
38
+ ### Creating a Company
39
+
40
+ ``` javascript
41
+ import { MorambaClient } from "@morambacrypto/connect";
42
+
43
+ const client = new MorambaClient({
44
+ baseURL: "https://crypto.moramba.io",
45
+ apiKey: process.env.API_KEY!,
46
+ partnerId: process.env.PARTNER_ID!,
47
+ });
48
+
49
+ // STEP 1 — Get JWT token
50
+ const jwt = await client.auth.createJwtToken({ userid: "admin@moramba.xyz" });
51
+ const token = jwt.data.token;
52
+
53
+ // STEP 2 — Create company
54
+ const company = await client.company.createCompany(
55
+ {
56
+ payment_method: {
57
+ network: "monad",
58
+ token: "moramba",
59
+ address: "0x62F6c82114809C00a1293be02A43C05a3F917202"
60
+ },
61
+ name: "Aeropres",
62
+ email: "admin@moramba.xyz",
63
+ },
64
+ token
65
+ );
66
+
67
+ console.log(company);
68
+
69
+
70
+ ```
71
+
72
+ ## signature process
73
+ ```javascript
74
+ await monadApprove({
75
+ privateKey: "0xYOUR_PRIVATE_KEY",
76
+ unlimited: false,
77
+ amount: "2500",
78
+ });
79
+ ```
80
+
38
81
  ## API Reference
39
82
 
40
83
  ### MorambaClient
@@ -1,4 +1,5 @@
1
1
  import { AuthAPI } from "./apis/auth.api";
2
+ import { CompanyAPI } from "./apis/company.api";
2
3
  export interface MorambaClientConfig {
3
4
  baseURL: string;
4
5
  apiKey: string;
@@ -7,5 +8,6 @@ export interface MorambaClientConfig {
7
8
  export declare class MorambaClient {
8
9
  auth: AuthAPI;
9
10
  private http;
11
+ company: CompanyAPI;
10
12
  constructor(config: MorambaClientConfig);
11
13
  }
@@ -1,10 +1,12 @@
1
1
  import { HttpClient } from "./client/HttpClient";
2
2
  import { AuthAPI } from "./apis/auth.api";
3
+ import { CompanyAPI } from "./apis/company.api";
3
4
  export class MorambaClient {
4
5
  constructor(config) {
5
6
  this.http = new HttpClient(config.baseURL, {
6
7
  "Content-Type": "application/json",
7
8
  });
8
9
  this.auth = new AuthAPI(this.http, config.partnerId, config.apiKey);
10
+ this.company = new CompanyAPI(this.http, config.partnerId, config.apiKey);
9
11
  }
10
12
  }
@@ -0,0 +1,9 @@
1
+ import { HttpClient } from "../client/HttpClient";
2
+ import { CreateCompanyPayload, CreateCompanyResponse } from "../types/company.types";
3
+ export declare class CompanyAPI {
4
+ private http;
5
+ private partnerId;
6
+ private apiKey;
7
+ constructor(http: HttpClient, partnerId: string, apiKey: string);
8
+ createCompany(payload: CreateCompanyPayload, jwtToken: string): Promise<CreateCompanyResponse>;
9
+ }
@@ -0,0 +1,17 @@
1
+ export class CompanyAPI {
2
+ constructor(http, partnerId, apiKey) {
3
+ this.http = http;
4
+ this.partnerId = partnerId;
5
+ this.apiKey = apiKey;
6
+ }
7
+ createCompany(payload, jwtToken) {
8
+ const fullBody = {
9
+ ...payload,
10
+ partner_id: this.partnerId,
11
+ api_key: this.apiKey,
12
+ };
13
+ return this.http.post("/api/v1/morambacypto/create/company", fullBody, {
14
+ Authorization: `Bearer ${jwtToken}`,
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./auth.api";
2
+ export * from "./company.api";
@@ -1 +1,2 @@
1
- "use strict";
1
+ export * from "./auth.api";
2
+ export * from "./company.api";
@@ -7,6 +7,6 @@ export declare class HttpClient {
7
7
  retryDelay?: number);
8
8
  get axiosInstance(): AxiosInstance;
9
9
  private setupRetryInterceptor;
10
- post<T = any>(url: string, data: any): Promise<T>;
10
+ post<T = any>(url: string, data: any, extraHeaders?: Record<string, string>): Promise<T>;
11
11
  get<T = any>(url: string): Promise<T>;
12
12
  }
@@ -34,8 +34,10 @@ export class HttpClient {
34
34
  return this.client(config);
35
35
  });
36
36
  }
37
- post(url, data) {
38
- return this.client.post(url, data).then((res) => res.data);
37
+ post(url, data, extraHeaders = {}) {
38
+ return this.client
39
+ .post(url, data, { headers: extraHeaders })
40
+ .then((res) => res.data);
39
41
  }
40
42
  get(url) {
41
43
  return this.client.get(url).then((res) => res.data);
@@ -0,0 +1,2 @@
1
+ export * from "./monad.approve";
2
+ export * from "./sepolia.approve";
@@ -0,0 +1,2 @@
1
+ export * from "./monad.approve";
2
+ export * from "./sepolia.approve";
@@ -0,0 +1,10 @@
1
+ export interface MonadApproveOptions {
2
+ privateKey: string;
3
+ unlimited?: boolean;
4
+ amount?: string;
5
+ decimalsOverride?: number;
6
+ }
7
+ export declare function monadApprove(options: MonadApproveOptions): Promise<{
8
+ hash: any;
9
+ receipt: any;
10
+ }>;
@@ -0,0 +1,29 @@
1
+ import { ethers } from "ethers";
2
+ import { MONAD_CONFIG } from "../utils/networks";
3
+ export async function monadApprove(options) {
4
+ const { privateKey, unlimited = true, amount, decimalsOverride, } = options;
5
+ const cfg = MONAD_CONFIG;
6
+ const provider = new ethers.JsonRpcProvider(cfg.rpc);
7
+ const wallet = new ethers.Wallet(privateKey, provider);
8
+ const abi = [
9
+ "function approve(address spender, uint256 value) external returns (bool)"
10
+ ];
11
+ const contract = new ethers.Contract(cfg.token, abi, wallet);
12
+ const decimals = decimalsOverride !== null && decimalsOverride !== void 0 ? decimalsOverride : cfg.decimals;
13
+ const humanAmount = amount !== null && amount !== void 0 ? amount : cfg.defaultAmount;
14
+ const value = unlimited
15
+ ? ethers.MaxUint256
16
+ : ethers.parseUnits(humanAmount, decimals);
17
+ console.log("⚡ Monad approve()");
18
+ console.log("RPC:", cfg.rpc);
19
+ console.log("Token:", cfg.token);
20
+ console.log("Spender:", cfg.spender);
21
+ console.log("Decimals:", decimals);
22
+ console.log("Amount:", unlimited ? "UNLIMITED" : humanAmount);
23
+ console.log("From:", await wallet.getAddress());
24
+ const tx = await contract.approve(cfg.spender, value);
25
+ console.log("📤 TX:", tx.hash);
26
+ const receipt = await tx.wait();
27
+ console.log("✅ Block:", receipt.blockNumber);
28
+ return { hash: tx.hash, receipt };
29
+ }
@@ -0,0 +1,10 @@
1
+ export interface SepoliaApproveOptions {
2
+ privateKey: string;
3
+ unlimited?: boolean;
4
+ amount?: string;
5
+ decimalsOverride?: number;
6
+ }
7
+ export declare function sepoliaApprove(options: SepoliaApproveOptions): Promise<{
8
+ hash: any;
9
+ receipt: any;
10
+ }>;
@@ -0,0 +1,29 @@
1
+ import { ethers } from "ethers";
2
+ import { SEPOLIA_CONFIG } from "../utils/networks";
3
+ export async function sepoliaApprove(options) {
4
+ const { privateKey, unlimited = true, amount, decimalsOverride, } = options;
5
+ const cfg = SEPOLIA_CONFIG;
6
+ const provider = new ethers.JsonRpcProvider(cfg.rpc);
7
+ const wallet = new ethers.Wallet(privateKey, provider);
8
+ const abi = [
9
+ "function approve(address spender, uint256 value) external returns (bool)"
10
+ ];
11
+ const contract = new ethers.Contract(cfg.token, abi, wallet);
12
+ const decimals = decimalsOverride !== null && decimalsOverride !== void 0 ? decimalsOverride : cfg.decimals;
13
+ const humanAmount = amount !== null && amount !== void 0 ? amount : cfg.defaultAmount;
14
+ const value = unlimited
15
+ ? ethers.MaxUint256
16
+ : ethers.parseUnits(humanAmount, decimals);
17
+ console.log("⚡ Sepolia approve()");
18
+ console.log("RPC:", cfg.rpc);
19
+ console.log("Token:", cfg.token);
20
+ console.log("Spender:", cfg.spender);
21
+ console.log("Decimals:", decimals);
22
+ console.log("Amount:", unlimited ? "UNLIMITED" : humanAmount);
23
+ console.log("From:", await wallet.getAddress());
24
+ const tx = await contract.approve(cfg.spender, value);
25
+ console.log("📤 TX:", tx.hash);
26
+ const receipt = await tx.wait();
27
+ console.log("✅ Block:", receipt.blockNumber);
28
+ return { hash: tx.hash, receipt };
29
+ }
@@ -0,0 +1,23 @@
1
+ export interface PaymentMethod {
2
+ network: string;
3
+ token: string;
4
+ address: string;
5
+ }
6
+ export interface CreateCompanyPayload {
7
+ payment_method: PaymentMethod;
8
+ name: string;
9
+ email: string;
10
+ }
11
+ export interface CompanyData {
12
+ id: string;
13
+ name: string;
14
+ email: string;
15
+ partner_id: string;
16
+ created_at: string;
17
+ updated_at: string;
18
+ }
19
+ export interface CreateCompanyResponse {
20
+ success: boolean;
21
+ message: string;
22
+ data: CompanyData | null;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
1
  export * from "./auth.types";
2
+ export * from "./company.types";
@@ -1 +1,2 @@
1
1
  export * from "./auth.types";
2
+ export * from "./company.types";
@@ -0,0 +1,9 @@
1
+ export interface TokenNetworkConfig {
2
+ rpc: string;
3
+ spender: string;
4
+ token: string;
5
+ decimals: number;
6
+ defaultAmount: string;
7
+ }
8
+ export declare const MONAD_CONFIG: TokenNetworkConfig;
9
+ export declare const SEPOLIA_CONFIG: TokenNetworkConfig;
@@ -0,0 +1,16 @@
1
+ // ▶️ MORAMBA Token (Monad)
2
+ export const MONAD_CONFIG = {
3
+ rpc: "https://testnet-rpc.monad.xyz",
4
+ spender: "0xbAcEa624831C5f294a5E7FeC519232AA37ec0a8C",
5
+ token: "0x62F6c82114809C00a1293be02A43C05a3F917202",
6
+ decimals: 18,
7
+ defaultAmount: "1000",
8
+ };
9
+ // ▶️ Sepolia
10
+ export const SEPOLIA_CONFIG = {
11
+ rpc: "https://rpc.sepolia.org",
12
+ spender: "0x6E2024Da220C081059f606D9EEAe670c84Ead9Ab",
13
+ token: "0xbAcEa624831C5f294a5E7FeC519232AA37ec0a8C",
14
+ decimals: 18,
15
+ defaultAmount: "1000",
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morambacrypto/connect",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "This library use for interact with moramba-crypto project",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -22,7 +22,8 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "axios": "^1.13.2",
25
- "dotenv": "^17.2.3"
25
+ "dotenv": "^17.2.3",
26
+ "ethers": "^6.15.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/jest": "^30.0.0",