Skip to content

Commit 739ac1c

Browse files
authored
Add signup and login methods to API client (#1)
- Updated Identity interface with new wallet structure (object with primary, ubi, savings) - Added WalletInfo interface for detailed wallet information - Implemented signup() method with SignupRequest/SignupResponse types - Implemented login() method with LoginRequest/LoginResponse types - Added response mappers to convert API responses to Identity objects - Updated exports to include new types
1 parent 3fa76c6 commit 739ac1c

File tree

12 files changed

+399
-104
lines changed

12 files changed

+399
-104
lines changed

dist/core/types.d.ts

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ export interface Identity {
1111
citizenship?: boolean;
1212
publicKey?: string;
1313
biometricHash?: string;
14-
wallets?: Wallet[];
14+
wallets?: {
15+
primary: WalletInfo;
16+
ubi: WalletInfo;
17+
savings: WalletInfo;
18+
};
19+
daoMembership?: {
20+
votingPower: number;
21+
soulboundNftIssued: boolean;
22+
};
23+
seedPhrases?: {
24+
primary: string[];
25+
ubi: string[];
26+
savings: string[];
27+
};
1528
votingPower?: number;
1629
ubiEarned?: number;
1730
}
@@ -21,6 +34,14 @@ export interface Wallet {
2134
balance: number;
2235
address: string;
2336
}
37+
export interface WalletInfo {
38+
id: string;
39+
wallet_type: string;
40+
name: string;
41+
balance: number;
42+
staked_balance: number;
43+
pending_rewards: number;
44+
}
2445
export interface NetworkStatus {
2546
peers: number;
2647
meshConnected: boolean;
@@ -165,4 +186,66 @@ export interface Proof {
165186
timestamp: string;
166187
signature?: string;
167188
}
189+
export interface SignupRequest {
190+
display_name: string;
191+
identity_type?: string;
192+
recovery_options?: string[];
193+
password: string;
194+
}
195+
export interface LoginRequest {
196+
identity_id: string;
197+
password: string;
198+
}
199+
export interface SignupResponse {
200+
status: string;
201+
identity_id: string;
202+
identity_type: string;
203+
access_level: string;
204+
created_at: number;
205+
citizenship_result?: CitizenshipResult;
206+
}
207+
export interface LoginResponse {
208+
status: string;
209+
identity_id: string;
210+
display_name: string;
211+
identity_type: string;
212+
access_level: string;
213+
wallets: {
214+
primary: WalletInfo;
215+
ubi: WalletInfo;
216+
savings: WalletInfo;
217+
};
218+
}
219+
export interface CitizenshipResult {
220+
identity_id: string;
221+
primary_wallet_id: string;
222+
ubi_wallet_id: string;
223+
savings_wallet_id: string;
224+
wallet_seed_phrases: {
225+
primary_wallet_seeds: {
226+
words: string[];
227+
};
228+
ubi_wallet_seeds: {
229+
words: string[];
230+
};
231+
savings_wallet_seeds: {
232+
words: string[];
233+
};
234+
};
235+
dao_registration: {
236+
voting_power: number;
237+
soulbound_nft_issued: boolean;
238+
registered_at: number;
239+
};
240+
ubi_registration: {
241+
ubi_wallet_id: string;
242+
ubi_enabled: boolean;
243+
};
244+
web4_access: {
245+
web4_enabled: boolean;
246+
};
247+
welcome_bonus: {
248+
bonus_amount: number;
249+
};
250+
}
168251
//# sourceMappingURL=types.d.ts.map

dist/core/types.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/zhtp-api-methods.d.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
* All API method implementations for various operations
44
*/
55
import { ZhtpApiCore } from './zhtp-api-core';
6-
import { Identity, Wallet, NetworkStatus, DaoProposal, DaoStats, Transaction, Delegate, ProposalDetails, TreasuryRecord, DApp, SmartContract, ContractDeploymentResult, ContractExecutionResult, Asset, NodeStatus, Proof } from './types';
6+
import { Identity, Wallet, NetworkStatus, DaoProposal, DaoStats, Transaction, Delegate, ProposalDetails, TreasuryRecord, DApp, SmartContract, ContractDeploymentResult, ContractExecutionResult, Asset, NodeStatus, Proof, SignupRequest, LoginRequest } from './types';
77
export declare abstract class ZhtpApiMethods extends ZhtpApiCore {
88
signIn(did: string, passphrase: string): Promise<Identity>;
99
createIdentity(data: any): Promise<Identity>;
10+
/**
11+
* Sign up a new citizen identity with 3 wallets, DAO membership, and welcome bonus
12+
*/
13+
signup(request: SignupRequest): Promise<Identity>;
14+
/**
15+
* Login with existing identity
16+
*/
17+
login(request: LoginRequest): Promise<Identity>;
18+
/**
19+
* Map signup response from backend to Identity interface
20+
*/
21+
private mapSignupResponseToIdentity;
22+
/**
23+
* Map login response from backend to Identity interface
24+
*/
25+
private mapLoginResponseToIdentity;
1026
recoverIdentity(method: 'seed' | 'backup' | 'social', data: string): Promise<Identity>;
1127
recoverIdentityFromSeed(recoveryData: Record<string, any>): Promise<Identity>;
1228
restoreIdentityFromBackup(backupData: Record<string, any>): Promise<Identity>;

0 commit comments

Comments
 (0)