@frontiertower/frontier-sdk 0.2.0 → 0.3.0

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
@@ -57,11 +57,13 @@ Your app must declare required permissions in the Frontier app registry:
57
57
  - `storage:set` - Write to storage
58
58
  - `storage:remove` - Remove from storage
59
59
  - `storage:clear` - Clear all storage
60
- - `storage:*` - Full storage access (wildcard for all storage methods)
61
60
 
62
61
  ### User Permissions
63
62
  - `user:getDetails` - Access current user details
64
- - `user:getProfile` - Access user profile information
63
+ - `user:getProfile` - Access current user profile information
64
+ - `user:getReferralOverview` - Access referral statistics
65
+ - `user:getReferralDetails` - Access detailed referral information
66
+ - `user:addUserContact` - Add user contact information
65
67
 
66
68
  ### Chain Permissions
67
69
  - `chain:getCurrentNetwork` - Get current network name
package/dist/index.d.mts CHANGED
@@ -246,18 +246,14 @@ declare class WalletAccess {
246
246
  *
247
247
  * @example
248
248
  * ```typescript
249
- * const receipt = await sdk.getWallet().transferFrontierDollar({
250
- * to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
251
- * amount: '10.5' // 10.5 Frontier Dollars
252
- * });
249
+ * const receipt = await sdk.getWallet().transferFrontierDollar(
250
+ * '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
251
+ * '10.5' // 10.5 Frontier Dollars
252
+ * );
253
253
  * console.log('Transaction:', receipt.transactionHash);
254
254
  * ```
255
255
  */
256
- transferFrontierDollar(payload: {
257
- to: string;
258
- amount: string;
259
- overrides?: GasOverrides;
260
- }): Promise<UserOperationReceipt>;
256
+ transferFrontierDollar(to: string, amount: string, overrides?: GasOverrides): Promise<UserOperationReceipt>;
261
257
  }
262
258
 
263
259
  /**
@@ -465,12 +461,60 @@ interface UserProfile {
465
461
  /** Whether user has a usable password */
466
462
  hasUsablePassword: string;
467
463
  }
464
+ /**
465
+ * Paginated response wrapper
466
+ */
467
+ interface PaginatedResponse<T> {
468
+ /** Total count of items */
469
+ count: number;
470
+ /** Array of results */
471
+ results: T[];
472
+ }
473
+ /**
474
+ * Referral overview statistics
475
+ */
476
+ interface ReferralOverview {
477
+ /** Total number of referrals */
478
+ totalReferrals: number;
479
+ /** Number of active referrals */
480
+ activeReferrals: number;
481
+ /** Total rewards earned */
482
+ totalRewards: number;
483
+ }
484
+ /**
485
+ * Detailed referral information
486
+ */
487
+ interface ReferralDetails {
488
+ /** Referral ID */
489
+ id: string;
490
+ /** Referred user email */
491
+ email: string;
492
+ /** Referral status */
493
+ status: string;
494
+ /** Date of referral */
495
+ createdAt: string;
496
+ /** Reward amount */
497
+ reward?: number;
498
+ }
499
+ /**
500
+ * User contact information payload
501
+ */
502
+ interface UserContactPayload {
503
+ /** Contact email */
504
+ email?: string;
505
+ /** Contact phone number */
506
+ phoneNumber?: string;
507
+ /** Additional contact information */
508
+ [key: string]: any;
509
+ }
468
510
  /**
469
511
  * User access class for interacting with user information
470
512
  *
471
513
  * This class provides methods to:
472
514
  * - Get current user details
473
515
  * - Get detailed user profiles
516
+ * - Access referral information
517
+ * - Add user contact information
474
518
  *
475
519
  * All methods require appropriate permissions and authentication.
476
520
  */
@@ -495,24 +539,82 @@ declare class UserAccess {
495
539
  */
496
540
  getDetails(): Promise<User>;
497
541
  /**
498
- * Get user profile by ID
542
+ * Get current user profile
499
543
  *
500
- * Returns detailed profile information for a specific user,
544
+ * Returns detailed profile information for the currently authenticated user,
501
545
  * including social media handles, preferences, and community information.
502
546
  *
503
- * @param id - The profile ID to fetch
504
547
  * @returns UserProfile object with detailed information
505
- * @throws {Error} If profile is not found or access is denied
548
+ * @throws {Error} If user is not authenticated or profile is not found
506
549
  *
507
550
  * @example
508
551
  * ```typescript
509
- * const profile = await sdk.getUser().getProfile(123);
552
+ * const profile = await sdk.getUser().getProfile();
510
553
  * console.log('Nickname:', profile.nickname);
511
554
  * console.log('GitHub:', profile.githubHandle);
512
555
  * console.log('Community:', profile.communityName);
513
556
  * ```
514
557
  */
515
- getProfile(id: number): Promise<UserProfile>;
558
+ getProfile(): Promise<UserProfile>;
559
+ /**
560
+ * Get referral overview for current user
561
+ *
562
+ * Returns statistics about the user's referrals, including total count,
563
+ * active referrals, and total rewards earned.
564
+ *
565
+ * @returns ReferralOverview object with referral statistics
566
+ * @throws {Error} If user is not authenticated
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const overview = await sdk.getUser().getReferralOverview();
571
+ * console.log('Total referrals:', overview.totalReferrals);
572
+ * console.log('Total rewards:', overview.totalRewards);
573
+ * ```
574
+ */
575
+ getReferralOverview(): Promise<ReferralOverview>;
576
+ /**
577
+ * Get referral details for current user with optional pagination
578
+ *
579
+ * Returns detailed information about each referral, including status,
580
+ * date, and rewards. Supports pagination for large result sets.
581
+ *
582
+ * @param page - Optional page number for pagination (1-indexed)
583
+ * @returns Paginated response with referral details
584
+ * @throws {Error} If user is not authenticated
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * const details = await sdk.getUser().getReferralDetails();
589
+ * console.log('Total referrals:', details.count);
590
+ * details.results.forEach(ref => {
591
+ * console.log(`${ref.email} - ${ref.status}`);
592
+ * });
593
+ *
594
+ * // With pagination
595
+ * const page2 = await sdk.getUser().getReferralDetails(2);
596
+ * ```
597
+ */
598
+ getReferralDetails(page?: number): Promise<PaginatedResponse<ReferralDetails>>;
599
+ /**
600
+ * Add user contact information
601
+ *
602
+ * Submits contact information for the current user. This can include
603
+ * email, phone number, or other contact details.
604
+ *
605
+ * @param data - Contact information payload
606
+ * @returns Promise that resolves when contact is added
607
+ * @throws {Error} If user is not authenticated or data is invalid
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * await sdk.getUser().addUserContact({
612
+ * email: 'contact@example.com',
613
+ * phoneNumber: '+1234567890'
614
+ * });
615
+ * ```
616
+ */
617
+ addUserContact(data: UserContactPayload): Promise<void>;
516
618
  }
517
619
 
518
620
  declare class FrontierSDK {
package/dist/index.d.ts CHANGED
@@ -246,18 +246,14 @@ declare class WalletAccess {
246
246
  *
247
247
  * @example
248
248
  * ```typescript
249
- * const receipt = await sdk.getWallet().transferFrontierDollar({
250
- * to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
251
- * amount: '10.5' // 10.5 Frontier Dollars
252
- * });
249
+ * const receipt = await sdk.getWallet().transferFrontierDollar(
250
+ * '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
251
+ * '10.5' // 10.5 Frontier Dollars
252
+ * );
253
253
  * console.log('Transaction:', receipt.transactionHash);
254
254
  * ```
255
255
  */
256
- transferFrontierDollar(payload: {
257
- to: string;
258
- amount: string;
259
- overrides?: GasOverrides;
260
- }): Promise<UserOperationReceipt>;
256
+ transferFrontierDollar(to: string, amount: string, overrides?: GasOverrides): Promise<UserOperationReceipt>;
261
257
  }
262
258
 
263
259
  /**
@@ -465,12 +461,60 @@ interface UserProfile {
465
461
  /** Whether user has a usable password */
466
462
  hasUsablePassword: string;
467
463
  }
464
+ /**
465
+ * Paginated response wrapper
466
+ */
467
+ interface PaginatedResponse<T> {
468
+ /** Total count of items */
469
+ count: number;
470
+ /** Array of results */
471
+ results: T[];
472
+ }
473
+ /**
474
+ * Referral overview statistics
475
+ */
476
+ interface ReferralOverview {
477
+ /** Total number of referrals */
478
+ totalReferrals: number;
479
+ /** Number of active referrals */
480
+ activeReferrals: number;
481
+ /** Total rewards earned */
482
+ totalRewards: number;
483
+ }
484
+ /**
485
+ * Detailed referral information
486
+ */
487
+ interface ReferralDetails {
488
+ /** Referral ID */
489
+ id: string;
490
+ /** Referred user email */
491
+ email: string;
492
+ /** Referral status */
493
+ status: string;
494
+ /** Date of referral */
495
+ createdAt: string;
496
+ /** Reward amount */
497
+ reward?: number;
498
+ }
499
+ /**
500
+ * User contact information payload
501
+ */
502
+ interface UserContactPayload {
503
+ /** Contact email */
504
+ email?: string;
505
+ /** Contact phone number */
506
+ phoneNumber?: string;
507
+ /** Additional contact information */
508
+ [key: string]: any;
509
+ }
468
510
  /**
469
511
  * User access class for interacting with user information
470
512
  *
471
513
  * This class provides methods to:
472
514
  * - Get current user details
473
515
  * - Get detailed user profiles
516
+ * - Access referral information
517
+ * - Add user contact information
474
518
  *
475
519
  * All methods require appropriate permissions and authentication.
476
520
  */
@@ -495,24 +539,82 @@ declare class UserAccess {
495
539
  */
496
540
  getDetails(): Promise<User>;
497
541
  /**
498
- * Get user profile by ID
542
+ * Get current user profile
499
543
  *
500
- * Returns detailed profile information for a specific user,
544
+ * Returns detailed profile information for the currently authenticated user,
501
545
  * including social media handles, preferences, and community information.
502
546
  *
503
- * @param id - The profile ID to fetch
504
547
  * @returns UserProfile object with detailed information
505
- * @throws {Error} If profile is not found or access is denied
548
+ * @throws {Error} If user is not authenticated or profile is not found
506
549
  *
507
550
  * @example
508
551
  * ```typescript
509
- * const profile = await sdk.getUser().getProfile(123);
552
+ * const profile = await sdk.getUser().getProfile();
510
553
  * console.log('Nickname:', profile.nickname);
511
554
  * console.log('GitHub:', profile.githubHandle);
512
555
  * console.log('Community:', profile.communityName);
513
556
  * ```
514
557
  */
515
- getProfile(id: number): Promise<UserProfile>;
558
+ getProfile(): Promise<UserProfile>;
559
+ /**
560
+ * Get referral overview for current user
561
+ *
562
+ * Returns statistics about the user's referrals, including total count,
563
+ * active referrals, and total rewards earned.
564
+ *
565
+ * @returns ReferralOverview object with referral statistics
566
+ * @throws {Error} If user is not authenticated
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const overview = await sdk.getUser().getReferralOverview();
571
+ * console.log('Total referrals:', overview.totalReferrals);
572
+ * console.log('Total rewards:', overview.totalRewards);
573
+ * ```
574
+ */
575
+ getReferralOverview(): Promise<ReferralOverview>;
576
+ /**
577
+ * Get referral details for current user with optional pagination
578
+ *
579
+ * Returns detailed information about each referral, including status,
580
+ * date, and rewards. Supports pagination for large result sets.
581
+ *
582
+ * @param page - Optional page number for pagination (1-indexed)
583
+ * @returns Paginated response with referral details
584
+ * @throws {Error} If user is not authenticated
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * const details = await sdk.getUser().getReferralDetails();
589
+ * console.log('Total referrals:', details.count);
590
+ * details.results.forEach(ref => {
591
+ * console.log(`${ref.email} - ${ref.status}`);
592
+ * });
593
+ *
594
+ * // With pagination
595
+ * const page2 = await sdk.getUser().getReferralDetails(2);
596
+ * ```
597
+ */
598
+ getReferralDetails(page?: number): Promise<PaginatedResponse<ReferralDetails>>;
599
+ /**
600
+ * Add user contact information
601
+ *
602
+ * Submits contact information for the current user. This can include
603
+ * email, phone number, or other contact details.
604
+ *
605
+ * @param data - Contact information payload
606
+ * @returns Promise that resolves when contact is added
607
+ * @throws {Error} If user is not authenticated or data is invalid
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * await sdk.getUser().addUserContact({
612
+ * email: 'contact@example.com',
613
+ * phoneNumber: '+1234567890'
614
+ * });
615
+ * ```
616
+ */
617
+ addUserContact(data: UserContactPayload): Promise<void>;
516
618
  }
517
619
 
518
620
  declare class FrontierSDK {
package/dist/index.js CHANGED
@@ -245,15 +245,14 @@ var WalletAccess = class {
245
245
  *
246
246
  * @example
247
247
  * ```typescript
248
- * const receipt = await sdk.getWallet().transferFrontierDollar({
249
- * to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
250
- * amount: '10.5' // 10.5 Frontier Dollars
251
- * });
248
+ * const receipt = await sdk.getWallet().transferFrontierDollar(
249
+ * '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
250
+ * '10.5' // 10.5 Frontier Dollars
251
+ * );
252
252
  * console.log('Transaction:', receipt.transactionHash);
253
253
  * ```
254
254
  */
255
- async transferFrontierDollar(payload) {
256
- const { to, amount, overrides } = payload;
255
+ async transferFrontierDollar(to, amount, overrides) {
257
256
  return this.sdk.request("wallet:transferFrontierDollar", {
258
257
  to,
259
258
  amount,
@@ -398,25 +397,89 @@ var UserAccess = class {
398
397
  return this.sdk.request("user:getDetails");
399
398
  }
400
399
  /**
401
- * Get user profile by ID
400
+ * Get current user profile
402
401
  *
403
- * Returns detailed profile information for a specific user,
402
+ * Returns detailed profile information for the currently authenticated user,
404
403
  * including social media handles, preferences, and community information.
405
404
  *
406
- * @param id - The profile ID to fetch
407
405
  * @returns UserProfile object with detailed information
408
- * @throws {Error} If profile is not found or access is denied
406
+ * @throws {Error} If user is not authenticated or profile is not found
409
407
  *
410
408
  * @example
411
409
  * ```typescript
412
- * const profile = await sdk.getUser().getProfile(123);
410
+ * const profile = await sdk.getUser().getProfile();
413
411
  * console.log('Nickname:', profile.nickname);
414
412
  * console.log('GitHub:', profile.githubHandle);
415
413
  * console.log('Community:', profile.communityName);
416
414
  * ```
417
415
  */
418
- async getProfile(id) {
419
- return this.sdk.request("user:getProfile", { id });
416
+ async getProfile() {
417
+ return this.sdk.request("user:getProfile");
418
+ }
419
+ /**
420
+ * Get referral overview for current user
421
+ *
422
+ * Returns statistics about the user's referrals, including total count,
423
+ * active referrals, and total rewards earned.
424
+ *
425
+ * @returns ReferralOverview object with referral statistics
426
+ * @throws {Error} If user is not authenticated
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * const overview = await sdk.getUser().getReferralOverview();
431
+ * console.log('Total referrals:', overview.totalReferrals);
432
+ * console.log('Total rewards:', overview.totalRewards);
433
+ * ```
434
+ */
435
+ async getReferralOverview() {
436
+ return this.sdk.request("user:getReferralOverview");
437
+ }
438
+ /**
439
+ * Get referral details for current user with optional pagination
440
+ *
441
+ * Returns detailed information about each referral, including status,
442
+ * date, and rewards. Supports pagination for large result sets.
443
+ *
444
+ * @param page - Optional page number for pagination (1-indexed)
445
+ * @returns Paginated response with referral details
446
+ * @throws {Error} If user is not authenticated
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * const details = await sdk.getUser().getReferralDetails();
451
+ * console.log('Total referrals:', details.count);
452
+ * details.results.forEach(ref => {
453
+ * console.log(`${ref.email} - ${ref.status}`);
454
+ * });
455
+ *
456
+ * // With pagination
457
+ * const page2 = await sdk.getUser().getReferralDetails(2);
458
+ * ```
459
+ */
460
+ async getReferralDetails(page) {
461
+ return this.sdk.request("user:getReferralDetails", page ? { page } : void 0);
462
+ }
463
+ /**
464
+ * Add user contact information
465
+ *
466
+ * Submits contact information for the current user. This can include
467
+ * email, phone number, or other contact details.
468
+ *
469
+ * @param data - Contact information payload
470
+ * @returns Promise that resolves when contact is added
471
+ * @throws {Error} If user is not authenticated or data is invalid
472
+ *
473
+ * @example
474
+ * ```typescript
475
+ * await sdk.getUser().addUserContact({
476
+ * email: 'contact@example.com',
477
+ * phoneNumber: '+1234567890'
478
+ * });
479
+ * ```
480
+ */
481
+ async addUserContact(data) {
482
+ return this.sdk.request("user:addUserContact", data);
420
483
  }
421
484
  };
422
485
 
package/dist/index.mjs CHANGED
@@ -215,15 +215,14 @@ var WalletAccess = class {
215
215
  *
216
216
  * @example
217
217
  * ```typescript
218
- * const receipt = await sdk.getWallet().transferFrontierDollar({
219
- * to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
220
- * amount: '10.5' // 10.5 Frontier Dollars
221
- * });
218
+ * const receipt = await sdk.getWallet().transferFrontierDollar(
219
+ * '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
220
+ * '10.5' // 10.5 Frontier Dollars
221
+ * );
222
222
  * console.log('Transaction:', receipt.transactionHash);
223
223
  * ```
224
224
  */
225
- async transferFrontierDollar(payload) {
226
- const { to, amount, overrides } = payload;
225
+ async transferFrontierDollar(to, amount, overrides) {
227
226
  return this.sdk.request("wallet:transferFrontierDollar", {
228
227
  to,
229
228
  amount,
@@ -368,25 +367,89 @@ var UserAccess = class {
368
367
  return this.sdk.request("user:getDetails");
369
368
  }
370
369
  /**
371
- * Get user profile by ID
370
+ * Get current user profile
372
371
  *
373
- * Returns detailed profile information for a specific user,
372
+ * Returns detailed profile information for the currently authenticated user,
374
373
  * including social media handles, preferences, and community information.
375
374
  *
376
- * @param id - The profile ID to fetch
377
375
  * @returns UserProfile object with detailed information
378
- * @throws {Error} If profile is not found or access is denied
376
+ * @throws {Error} If user is not authenticated or profile is not found
379
377
  *
380
378
  * @example
381
379
  * ```typescript
382
- * const profile = await sdk.getUser().getProfile(123);
380
+ * const profile = await sdk.getUser().getProfile();
383
381
  * console.log('Nickname:', profile.nickname);
384
382
  * console.log('GitHub:', profile.githubHandle);
385
383
  * console.log('Community:', profile.communityName);
386
384
  * ```
387
385
  */
388
- async getProfile(id) {
389
- return this.sdk.request("user:getProfile", { id });
386
+ async getProfile() {
387
+ return this.sdk.request("user:getProfile");
388
+ }
389
+ /**
390
+ * Get referral overview for current user
391
+ *
392
+ * Returns statistics about the user's referrals, including total count,
393
+ * active referrals, and total rewards earned.
394
+ *
395
+ * @returns ReferralOverview object with referral statistics
396
+ * @throws {Error} If user is not authenticated
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const overview = await sdk.getUser().getReferralOverview();
401
+ * console.log('Total referrals:', overview.totalReferrals);
402
+ * console.log('Total rewards:', overview.totalRewards);
403
+ * ```
404
+ */
405
+ async getReferralOverview() {
406
+ return this.sdk.request("user:getReferralOverview");
407
+ }
408
+ /**
409
+ * Get referral details for current user with optional pagination
410
+ *
411
+ * Returns detailed information about each referral, including status,
412
+ * date, and rewards. Supports pagination for large result sets.
413
+ *
414
+ * @param page - Optional page number for pagination (1-indexed)
415
+ * @returns Paginated response with referral details
416
+ * @throws {Error} If user is not authenticated
417
+ *
418
+ * @example
419
+ * ```typescript
420
+ * const details = await sdk.getUser().getReferralDetails();
421
+ * console.log('Total referrals:', details.count);
422
+ * details.results.forEach(ref => {
423
+ * console.log(`${ref.email} - ${ref.status}`);
424
+ * });
425
+ *
426
+ * // With pagination
427
+ * const page2 = await sdk.getUser().getReferralDetails(2);
428
+ * ```
429
+ */
430
+ async getReferralDetails(page) {
431
+ return this.sdk.request("user:getReferralDetails", page ? { page } : void 0);
432
+ }
433
+ /**
434
+ * Add user contact information
435
+ *
436
+ * Submits contact information for the current user. This can include
437
+ * email, phone number, or other contact details.
438
+ *
439
+ * @param data - Contact information payload
440
+ * @returns Promise that resolves when contact is added
441
+ * @throws {Error} If user is not authenticated or data is invalid
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * await sdk.getUser().addUserContact({
446
+ * email: 'contact@example.com',
447
+ * phoneNumber: '+1234567890'
448
+ * });
449
+ * ```
450
+ */
451
+ async addUserContact(data) {
452
+ return this.sdk.request("user:addUserContact", data);
390
453
  }
391
454
  };
392
455
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontiertower/frontier-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "SDK for building apps on Frontier Wallet",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",