@oumla/sdk 0.0.2 → 0.0.4

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
@@ -7,9 +7,9 @@ an example on how to create a wallet
7
7
  ```ts
8
8
  import { Oumla } from '@oumla/sdk';
9
9
 
10
- const wallet = client.generateWallet({
10
+ const wallet = client.wallets.generate({
11
11
  reference: '0d2fcf49-36ce-4160-bbea-ead3887e1b26',
12
- network: 'BTC',
12
+ network: 'ETH',
13
13
  });
14
14
  ```
15
15
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const NetworkSchema: z.ZodEnum<["BTC", "ETH"]>;
3
+ declare const NetworkSchema: z.ZodEnum<["BTC", "ETH", "tBTC", "tETH"]>;
4
4
  declare const ProfileTypeSchema: z.ZodEnum<["User", "Department", "Merchant"]>;
5
5
  declare const GetWalletsSchema: z.ZodObject<{
6
6
  reference: z.ZodString;
@@ -17,14 +17,14 @@ declare const GetProfileWalletsSchema: z.ZodObject<{
17
17
  reference: string;
18
18
  }>;
19
19
  declare const GenerateWalletSchema: z.ZodObject<{
20
- network: z.ZodEnum<["BTC", "ETH"]>;
20
+ network: z.ZodEnum<["BTC", "ETH", "tBTC", "tETH"]>;
21
21
  reference: z.ZodString;
22
22
  }, "strip", z.ZodTypeAny, {
23
23
  reference: string;
24
- network: "BTC" | "ETH";
24
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
25
25
  }, {
26
26
  reference: string;
27
- network: "BTC" | "ETH";
27
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
28
28
  }>;
29
29
  declare const GetTransactionsByAddressSchema: z.ZodObject<{
30
30
  baseUrl: z.ZodString;
@@ -79,14 +79,17 @@ declare const GetTransactionsSchema: z.ZodObject<{
79
79
  reference?: string | undefined;
80
80
  }>;
81
81
  declare const GenerateAddressSchema: z.ZodObject<{
82
- network: z.ZodEnum<["BTC", "ETH"]>;
82
+ network: z.ZodEnum<["BTC", "ETH", "tBTC", "tETH"]>;
83
83
  reference: z.ZodString;
84
+ clientShare: z.ZodString;
84
85
  }, "strip", z.ZodTypeAny, {
85
86
  reference: string;
86
- network: "BTC" | "ETH";
87
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
88
+ clientShare: string;
87
89
  }, {
88
90
  reference: string;
89
- network: "BTC" | "ETH";
91
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
92
+ clientShare: string;
90
93
  }>;
91
94
  declare const GetAddressesSchema: z.ZodObject<{
92
95
  baseUrl: z.ZodString;
@@ -156,14 +159,17 @@ declare const CreateTransactionSchema: z.ZodObject<{
156
159
  to: z.ZodString;
157
160
  amount: z.ZodNumber;
158
161
  from: z.ZodArray<z.ZodString, "many">;
159
- network: z.ZodEnum<["BTC", "ETH"]>;
162
+ network: z.ZodEnum<["BTC", "ETH", "tBTC", "tETH"]>;
163
+ clientShare: z.ZodString;
160
164
  }, "strip", z.ZodTypeAny, {
161
- network: "BTC" | "ETH";
165
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
166
+ clientShare: string;
162
167
  to: string;
163
168
  amount: number;
164
169
  from: string[];
165
170
  }, {
166
- network: "BTC" | "ETH";
171
+ network: "BTC" | "ETH" | "tBTC" | "tETH";
172
+ clientShare: string;
167
173
  to: string;
168
174
  amount: number;
169
175
  from: string[];
@@ -200,6 +206,7 @@ type THttpRequestArgs = {
200
206
  body?: Record<string, unknown>;
201
207
  schema?: z.Schema<unknown>;
202
208
  pagination?: TPagination;
209
+ headers?: Record<string, string>;
203
210
  };
204
211
  type TPagination = {
205
212
  totalElements?: number;
@@ -289,34 +296,16 @@ type VolumeByDay = {
289
296
  insightsId?: string;
290
297
  };
291
298
  type TGetWalletsResponse = {
292
- wallets: {
293
- type: z.infer<typeof ProfileTypeSchema>;
294
- date: Date;
295
- reference: string;
296
- organizationId: string;
297
- WalletCoinType: z.infer<typeof NetworkSchema>;
298
- currentDeepIndex: number;
299
- index: number;
300
- label: string | null;
301
- profile: {
302
- createdAt: Date;
303
- updated_at: Date;
304
- isActive: boolean;
305
- reference: string;
306
- userIndex: number;
307
- currentIndex: number;
308
- organizationId: string;
309
- bitcoin_balance: {
310
- id: string;
311
- balance: number;
312
- organizationId: string;
313
- reference: string;
314
- createdAt: Date;
315
- updatedAt: Date;
316
- };
317
- };
318
- }[];
319
- } & TPagination;
299
+ createdAt: Date;
300
+ updated_at: Date;
301
+ isActive: boolean;
302
+ isVerified: boolean;
303
+ reference: string;
304
+ currentIndex: number;
305
+ type: ProfileType;
306
+ label: string | null;
307
+ miniWallets: MiniWallet[];
308
+ }[];
320
309
  type Wallet = {
321
310
  id: string;
322
311
  date: Date;
@@ -333,53 +322,50 @@ type TGetProfileWalletsResponse = {
333
322
  reference: string;
334
323
  };
335
324
  type TGenerateAddressResponse = {
336
- address?: string;
325
+ data: string;
337
326
  message: string;
327
+ success: boolean;
328
+ status: number;
338
329
  };
339
330
  type TGetAddressesResponse = {
340
- addresses: {
341
- id: string;
342
- date: Date;
343
- address: string;
344
- label: string | null;
345
- network: z.infer<typeof NetworkSchema>;
346
- balance: number;
347
- }[];
348
- } & TPagination;
331
+ address: string;
332
+ date: Date;
333
+ label: string | null;
334
+ sub: string;
335
+ network: Network;
336
+ balance: number;
337
+ reference: string;
338
+ }[];
349
339
  type TGetOrganizationResponse = {
350
340
  id: string;
351
341
  name: string;
352
342
  email: string;
353
343
  };
344
+ type TGetOumlaResponse<T> = {
345
+ data: T;
346
+ success: boolean;
347
+ status: number;
348
+ pagination: TPagination;
349
+ };
354
350
  type TCreateProfileResponse = {
355
351
  message: string;
356
- profile: {
352
+ data: {
357
353
  reference: string;
358
354
  type: string;
359
355
  };
356
+ success: boolean;
357
+ status: number;
360
358
  };
361
359
  type TGetProfilesResponse = {
362
- profiles: {
363
- organizationId: string;
364
- reference: string;
365
- type: z.infer<typeof ProfileTypeSchema>;
366
- createdAt: Date;
367
- updated_at: Date;
368
- label: string | null;
369
- bitcoin_balance: {
370
- balance: number;
371
- } | null;
372
- miniWallets: {
373
- date: Date;
374
- organizationId: string;
375
- reference: string;
376
- type: z.infer<typeof ProfileTypeSchema>;
377
- WalletCoinType: z.infer<typeof NetworkSchema>;
378
- currentDeepIndex: number;
379
- index: number;
380
- }[];
381
- }[];
382
- } & TPagination;
360
+ createdAt: Date;
361
+ updated_at: Date;
362
+ organizationId: string;
363
+ type: ProfileType;
364
+ label: string | null;
365
+ reference: string;
366
+ miniWallets: MiniWallet[];
367
+ addressesCount: number;
368
+ }[];
383
369
  type TGetVolumeResponse = {
384
370
  createdAt: Date;
385
371
  updatedAt: Date;
@@ -405,22 +391,16 @@ type TGetTransactionsResponse = {
405
391
  addressFrom: string | null;
406
392
  isSpent: boolean;
407
393
  isMempool: boolean;
408
- }[] & TPagination;
394
+ }[];
409
395
  type TTransferResponse = {
410
396
  id: string;
411
397
  status: string;
412
398
  };
413
399
  type TGenerateWalletResponse = {
414
- id: string;
415
- date: Date;
416
- organizationId: string;
417
400
  reference: string;
418
- index: number;
419
- currentDeepIndex: number;
420
- type: z.infer<typeof ProfileTypeSchema>;
421
- WalletCoinType: z.infer<typeof NetworkSchema>;
422
- createdAt: Date;
423
- updatedAt: Date;
401
+ network: Network;
402
+ type: ProfileType;
403
+ date: Date;
424
404
  };
425
405
  type TGenerateWalletArgs = z.infer<typeof GenerateWalletSchema>;
426
406
  type TGetProfileWalletsArgs = z.infer<typeof GetProfileWalletsSchema>;
@@ -447,244 +427,45 @@ declare abstract class Base {
447
427
  protected baseUrl: string;
448
428
  protected env: string;
449
429
  constructor(configs: TBaseConfigs);
450
- /**
451
- *
452
- * A generic method to make requests to the Oumla API.
453
- * Keep it simple for now, could be enhanced later.
454
- *
455
- */
430
+ protected getCustomHeaders(): Record<string, string>;
456
431
  protected httpRequest<T>(args: THttpRequestArgs): Promise<T>;
457
432
  private parseInput;
458
433
  }
459
434
 
460
- /**
461
- * Oumla SDK
462
- * @param apiKey - Your API key
463
- * @param baseUrl - The base URL of the API
464
- * @param env - The environment of the API
465
- * @example
466
- * ```ts
467
- *
468
- * const client = new Oumla({
469
- * apiKey: 'YOUR_API_KEY',
470
- * baseUrl: 'https://sandbox.oumla.com',
471
- * env: 'testnet',
472
- * })
473
- * ```
474
- */
435
+ type OumlaOptions = {
436
+ apiKey: string;
437
+ baseUrl?: string;
438
+ env?: 'testnet' | 'mainnet';
439
+ };
475
440
  declare class Oumla extends Base {
476
- constructor(configs: TBaseConfigs);
477
- /**
478
- *
479
- * Generate a wallet for a profile
480
- *
481
- * @param {string} args.reference - The reference of the profile
482
- * @param {string} args.network - The network to generate a wallet for
483
- *
484
- * @example
485
- * ``` ts
486
- *
487
- * const wallet = await client.generateWallet({
488
- * reference: 'PROFILE_REFERENCE',
489
- * network: 'BTC',
490
- * });
491
- *
492
- * ```
493
- *
494
- * @returns {Types.TGenerateWalletResponse} - The generated wallet or an error
495
- *
496
- */
497
- generateWallet(args: TGenerateWalletArgs): Promise<TGenerateWalletResponse>;
498
- /**
499
- *
500
- * Get wallets for an organization
501
- *
502
- * @param {string} args.reference - The reference of the profile
503
- * @param {Types.TPagination} [pagination] - Pagination options
504
- *
505
- * @example
506
- * ``` ts
507
- *
508
- * const wallets = await client.getWallets({
509
- * skip: 0,
510
- * take: 3,
511
- * });
512
- *
513
- * ```
514
- *
515
- * @returns {Types.TGetWalletsResponse} - The wallets for the organization
516
- *
517
- */
518
- getWallets(args?: TGetWallets, pagination?: TPagination): Promise<TGetWalletsResponse>;
519
- /**
520
- *
521
- * Generate an address for a profile
522
- *
523
- * @param {string} args.reference - The reference of the profile
524
- * @param {string} args.network - The network to generate an address for
525
- *
526
- * @example
527
- * ``` ts
528
- *
529
- * const address = await client.generateAddress({
530
- * reference: 'PROFILE_REFERENCE',
531
- * network: 'BTC',
532
- * });
533
- *
534
- * ```
535
- *
536
- * @returns {Types.TGenerateAddressResponse} - The generated address
537
- */
538
- generateAddress(args: TGenerateAddressArgs): Promise<TGenerateAddressResponse>;
539
- /**
540
- *
541
- * Get addresses
542
- *
543
- * @param {string} args.reference - The reference of the profile, Optional
544
- * @param {Types.TPagination} [pagination] - Pagination options
545
- * @example
546
- * ``` ts
547
- *
548
- * const addresses = await client.getAddresses({
549
- * reference: 'PROFILE_REFERENCE',
550
- * },
551
- * {
552
- * skip: 0,
553
- * take: 3,
554
- * }
555
- * );
556
- *
557
- * ```
558
- *
559
- * @returns {Types.TGetProfileAddressesResponse} - The addresses for the profile
560
- */
561
- getAddresses(args?: TGetAddresses, pagination?: TPagination): Promise<TGetAddressesResponse>;
562
- /**
563
- *
564
- * Get the organization's information
565
- *
566
- * @example
567
- * ``` ts
568
- *
569
- * const organization = await client.getOrganization();
570
- *
571
- * ```
572
- *
573
- * @returns {Types.TGetOrganizationResponse} - The organization's information
574
- */
575
- getOrganization(): Promise<TGetOrganizationResponse>;
576
- /**
577
- *
578
- * Create a profile
579
- *
580
- * @param {string} args.reference - The reference of the profile
581
- * @param {Types.TCreateProfileArgs['type']} args.type - The type of the profile
582
- *
583
- * @example
584
- * ``` ts
585
- *
586
- * const profile = await client.createProfile({
587
- * reference: 'PROFILE_REFERENCE',
588
- * type: 'User',
589
- * });
590
- *
591
- * ```
592
- *
593
- * @returns {Types.TCreateProfileResponse} - The created profile
594
- */
595
- createProfile(args: TCreateProfileArgs): Promise<TCreateProfileResponse>;
596
- /**
597
- *
598
- * Get the profiles for an organization
599
- *
600
- * @param {Types.TPagination} [pagination] - Pagination options
601
- *
602
- * @example
603
- * ``` ts
604
- *
605
- * const profiles = await client.getProfiles({
606
- * skip: 0,
607
- * take: 3,
608
- * });
609
- *
610
- * ```
611
- *
612
- * @returns {Types.TGetProfilesResponse} - The profiles for the organization
613
- */
614
- getProfiles(pagination?: TPagination): Promise<TGetProfilesResponse>;
615
- /**
616
- *
617
- * Get the volume for an organization
618
- *
619
- * @example
620
- * ``` ts
621
- *
622
- * const volume = await client.getVolume();
623
- *
624
- * ```
625
- *
626
- * @returns {Types.TGetVolumeResponse} - The volume of the organization
627
- */
628
- getVolume(): Promise<TGetVolumeResponse>;
629
- /**
630
- *
631
- * Get the insights for an organization
632
- *
633
- * @example
634
- * ``` ts
635
- *
636
- * const insights = await client.getInsights();
637
- *
638
- * ```
639
- *
640
- * @returns {Types.TGetInsightsResponse} - The insights of the organization
641
- */
642
- getInsights(): Promise<TGetInsightsResponse>;
643
- /**
644
- *
645
- * Get the all the transactions or transactions for an address, wallet or reference
646
- *
647
- * By providing more than one option, only one will be used.
648
- *
649
- * @param {string} [args.address] - The address to get transactions for
650
- * @param {string} [args.wallet] - The wallet to get transactions for
651
- * @param {string} [args.reference] - The reference to get transactions for
652
- * @param {Types.TPagination} [pagination] - Pagination options
653
- *
654
- * @example
655
- * ``` ts
656
- *
657
- * const transactionsByAddress = await client.getTransactions({
658
- * address: 'ADDRESS',
659
- * });
660
- *
661
- * ```
662
- *
663
- * @returns {Types.TGetTransactionsResponse} - The transactions
664
- *
665
- */
666
- getTransactions(args?: TGetTransactionsArgs, pagination?: TPagination): Promise<TGetTransactionsResponse>;
667
- /**
668
- * create transaction
669
- *
670
- * @param args.from - the address or addresses to transfer from
671
- * @param args.to - The desired address to transfer to
672
- * @param args.amount - The amount to transfer
673
- *
674
- * @example
675
- *
676
- * ``` ts
677
- *
678
- * const transfer = await client.transfer({
679
- * from: '0x...',
680
- * to: '0x...',
681
- * reference: '0x...',
682
- * amount: 100,
683
- * });
684
- *
685
- * ```
686
- */
687
- createTransaction(args: TCreateTransactionArgs): Promise<TTransferResponse>;
441
+ private static readonly CURRENT_VERSION;
442
+ private lastUpdateCheck;
443
+ private readonly UPDATE_CHECK_INTERVAL;
444
+ constructor(opts: OumlaOptions);
445
+ private initialize;
446
+ protected getCustomHeaders(): Record<string, string>;
447
+ private checkForUpdates;
448
+ wallets: {
449
+ generate: (args: TGenerateWalletArgs) => Promise<TGetOumlaResponse<TGenerateWalletResponse>>;
450
+ get: (args?: TGetWallets, pagination?: TPagination) => Promise<TGetOumlaResponse<TGetWalletsResponse>>;
451
+ };
452
+ addresses: {
453
+ generate: (args: TGenerateAddressArgs) => Promise<TGenerateAddressResponse>;
454
+ get: (args?: TGetAddresses, pagination?: TPagination) => Promise<TGetOumlaResponse<TGetAddressesResponse>>;
455
+ };
456
+ profiles: {
457
+ create: (args: TCreateProfileArgs) => Promise<TCreateProfileResponse>;
458
+ get: (pagination?: TPagination) => Promise<TGetOumlaResponse<TGetProfilesResponse>>;
459
+ };
460
+ organization: {
461
+ get: () => Promise<TGetOumlaResponse<TGetOrganizationResponse>>;
462
+ volume: () => Promise<TGetOumlaResponse<TGetVolumeResponse>>;
463
+ insights: () => Promise<TGetOumlaResponse<TGetInsightsResponse>>;
464
+ };
465
+ transactions: {
466
+ create: (args: TCreateTransactionArgs) => Promise<TTransferResponse>;
467
+ get: (args?: TGetTransactionsArgs, pagination?: TPagination) => Promise<TGetOumlaResponse<TGetTransactionsResponse>>;
468
+ };
688
469
  }
689
470
 
690
- export { Address, AssetType, EnvType, Insights, MiniWallet, Network, Organization, Oumla, PaymentStatus, PaymentType, Profile, ProfileType, TBaseConfigs, TCreateProfileArgs, TCreateProfileResponse, TCreateTransactionArgs, TGenerateAddressArgs, TGenerateAddressResponse, TGenerateWalletArgs, TGenerateWalletResponse, TGetAddresses, TGetAddressesArgs, TGetAddressesResponse, TGetInsightsArgs, TGetInsightsResponse, TGetOrganizationArgs, TGetOrganizationDashboardArgs, TGetOrganizationResponse, TGetProfileAddressesArgs, TGetProfileWalletsArgs, TGetProfileWalletsResponse, TGetProfilesArgs, TGetProfilesResponse, TGetTransactionsArgs, TGetTransactionsByAddressArgs, TGetTransactionsByReferenceArgs, TGetTransactionsByWalletArgs, TGetTransactionsResponse, TGetVolumeArgs, TGetVolumeResponse, TGetWallets, TGetWalletsResponse, THttpError, THttpRequestArgs, TPagination, TTransferResponse, Tags, Transaction, TransactionStatus, TransactionType, VolumeByDay, Wallet };
471
+ export { Address, AssetType, EnvType, Insights, MiniWallet, Network, Organization, Oumla, OumlaOptions, PaymentStatus, PaymentType, Profile, ProfileType, TBaseConfigs, TCreateProfileArgs, TCreateProfileResponse, TCreateTransactionArgs, TGenerateAddressArgs, TGenerateAddressResponse, TGenerateWalletArgs, TGenerateWalletResponse, TGetAddresses, TGetAddressesArgs, TGetAddressesResponse, TGetInsightsArgs, TGetInsightsResponse, TGetOrganizationArgs, TGetOrganizationDashboardArgs, TGetOrganizationResponse, TGetOumlaResponse, TGetProfileAddressesArgs, TGetProfileWalletsArgs, TGetProfileWalletsResponse, TGetProfilesArgs, TGetProfilesResponse, TGetTransactionsArgs, TGetTransactionsByAddressArgs, TGetTransactionsByReferenceArgs, TGetTransactionsByWalletArgs, TGetTransactionsResponse, TGetVolumeArgs, TGetVolumeResponse, TGetWallets, TGetWalletsResponse, THttpError, THttpRequestArgs, TPagination, TTransferResponse, Tags, Transaction, TransactionStatus, TransactionType, VolumeByDay, Wallet };