@kingdomchain/wallet-client 0.4.1 → 0.5.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
@@ -6,6 +6,7 @@ Self-contained TypeScript package for constructing, signing, and broadcasting Ki
6
6
 
7
7
  - **MsgSubmitApplication** (citizenship application)
8
8
  - **MsgSubmitRecoveryAttestation** (wallet recovery attestation)
9
+ - **MsgClaimReward** + citizen wallet helpers (v0.5.0) — balance query, unclaimed rewards, send/claim tx builders, feegrant granter lookup, `broadcastAndConfirmTx`
9
10
  - **Browser wallet connector** (`src/browserSigner.ts`) — Keplr / Leap / Cosmostation via `experimentalSuggestChain` + `OfflineDirectSigner`
10
11
  - **WalletConnect mobile signer** (`src/walletConnectSigner.ts`) — WalletConnect v2 `OfflineDirectSigner` adapter
11
12
  - **Embedded passkey wallet** (`src/embeddedWallet/`) — WebAuthn PRF + PBKDF2 fallback, IndexedDB vault, mandatory backup gate
@@ -82,9 +83,9 @@ Optional Vite env overrides (prefix `VITE_`):
82
83
 
83
84
  The demo signs the provider attestation off-chain (devnet seed) and broadcasts `MsgSubmitApplication` using your connected wallet as the on-chain tx signer.
84
85
 
85
- ## Kingdom OS / Base44 reference wiring
86
+ ## Kingdom OS / Vercel reference wiring
86
87
 
87
- Copy-paste React integration lives in `clients/kingdom-os-reference/`:
88
+ Copy-paste React integration lives in `clients/kingdom-os-reference/` (for the **kingdom-os** Vercel app — Base44 is superseded):
88
89
 
89
90
  - `useKingdomWallet.js` — unified hook for Keplr, Leap, Cosmostation, WalletConnect, embedded passkey
90
91
  - `WalletStep.jsx` — onboarding UI with side-by-side connect buttons
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Registry, OfflineDirectSigner, DirectSecp256k1Wallet, EncodeObject } from '@cosmjs/proto-signing';
2
- import { SigningStargateClient } from '@cosmjs/stargate';
2
+ import { SigningStargateClient, DeliverTxResponse, IndexedTx, StdFee } from '@cosmjs/stargate';
3
3
  import SignClient from '@walletconnect/sign-client';
4
4
  import { SessionTypes, ProposalTypes } from '@walletconnect/types';
5
5
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
@@ -46,7 +46,7 @@ interface MsgSubmitApplication {
46
46
  expires_at?: Date | undefined;
47
47
  signature: string;
48
48
  }
49
- declare const MsgSubmitApplication: MessageFns<MsgSubmitApplication>;
49
+ declare const MsgSubmitApplication: MessageFns$2<MsgSubmitApplication>;
50
50
  interface MsgSubmitRecoveryAttestation {
51
51
  applicant_wallet: string;
52
52
  recovery_case_id: string;
@@ -64,16 +64,16 @@ interface MsgSubmitRecoveryAttestation {
64
64
  expires_at?: Date | undefined;
65
65
  signature: string;
66
66
  }
67
- declare const MsgSubmitRecoveryAttestation: MessageFns<MsgSubmitRecoveryAttestation>;
68
- type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
69
- type DeepPartial<T> = T extends bigint ? string | number | bigint : T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
70
- [K in keyof T]?: DeepPartial<T[K]>;
67
+ declare const MsgSubmitRecoveryAttestation: MessageFns$2<MsgSubmitRecoveryAttestation>;
68
+ type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
69
+ type DeepPartial$2<T> = T extends bigint ? string | number | bigint : T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {} ? {
70
+ [K in keyof T]?: DeepPartial$2<T[K]>;
71
71
  } : Partial<T>;
72
- interface MessageFns<T> {
72
+ interface MessageFns$2<T> {
73
73
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
74
74
  decode(input: BinaryReader | Uint8Array, length?: number): T;
75
- create(base?: DeepPartial<T>): T;
76
- fromPartial(object: DeepPartial<T>): T;
75
+ create(base?: DeepPartial$2<T>): T;
76
+ fromPartial(object: DeepPartial$2<T>): T;
77
77
  }
78
78
 
79
79
  declare enum ApplicationStatus {
@@ -93,7 +93,7 @@ declare enum RecoveryAttestationStatus {
93
93
  UNRECOGNIZED = -1
94
94
  }
95
95
 
96
- /** CosmJS registry: standard Cosmos SDK types + Kingdom Chain citizen/compliance messages. */
96
+ /** CosmJS registry: standard Cosmos SDK types + Kingdom Chain citizen/compliance/rewards messages. */
97
97
  declare function createKingdomChainRegistry(): Registry;
98
98
 
99
99
  /** Keplr/Leap-compatible currency entry. */
@@ -301,6 +301,11 @@ declare class EmbeddedWalletBackupRequiredError extends Error {
301
301
  declare class EmbeddedWalletVaultError extends Error {
302
302
  constructor(message: string, cause?: unknown);
303
303
  }
304
+ /** Thrown when AES-GCM decryption fails (wrong KEK or tampered ciphertext). */
305
+ declare class EmbeddedWalletDecryptError extends EmbeddedWalletVaultError {
306
+ readonly code: "decrypt_failed";
307
+ constructor(cause?: unknown);
308
+ }
304
309
  type PasscodeStrengthLabel = "weak" | "fair" | "good" | "strong";
305
310
  type PasscodeBlockReason = "denylist" | "too_weak" | "numeric_short";
306
311
  /** Thrown when too many failed passcode unlock attempts trigger a timed lockout. */
@@ -402,14 +407,21 @@ declare function decodeCredentialId(encoded: string): Uint8Array;
402
407
  declare function embeddedPlaintextToSigner(plaintext: EmbeddedWalletPlaintext, prefix?: string): Promise<DirectSecp256k1Wallet>;
403
408
  declare function defaultEmbeddedHdPath(): string;
404
409
 
410
+ /** Legacy unscoped vault key used before per-account scoping shipped. */
411
+ declare const VAULT_LEGACY_KEY = "primary";
412
+ interface VaultStorageOptions {
413
+ /** When set, vault is stored under this account-scoped key instead of {@link VAULT_LEGACY_KEY}. */
414
+ scopeId?: string;
415
+ }
405
416
  interface PasscodeLockoutRecord {
406
417
  failedAttempts: number;
407
418
  lockoutTier: number;
408
419
  lockedUntil: string | null;
409
420
  }
410
- declare function saveVaultToIndexedDb(vault: EmbeddedWalletVaultV1): Promise<void>;
411
- declare function loadVaultFromIndexedDb(): Promise<EmbeddedWalletVaultV1 | null>;
412
- declare function clearVaultFromIndexedDb(): Promise<void>;
421
+ declare function resolveVaultStorageKey(scopeId?: string): string;
422
+ declare function saveVaultToIndexedDb(vault: EmbeddedWalletVaultV1, options?: VaultStorageOptions): Promise<void>;
423
+ declare function loadVaultFromIndexedDb(options?: VaultStorageOptions): Promise<EmbeddedWalletVaultV1 | null>;
424
+ declare function clearVaultFromIndexedDb(options?: VaultStorageOptions): Promise<void>;
413
425
  declare function loadPasscodeLockoutRecord(publicAddress: string): Promise<PasscodeLockoutRecord | null>;
414
426
  declare function savePasscodeLockoutRecord(publicAddress: string, record: PasscodeLockoutRecord): Promise<void>;
415
427
  declare function clearPasscodeLockoutRecord(publicAddress: string): Promise<void>;
@@ -420,6 +432,8 @@ declare const PASSCODE_LOCKOUT_FAILURE_THRESHOLD = 5;
420
432
  declare const PASSCODE_LOCKOUT_INITIAL_MS = 30000;
421
433
  /** Maximum lockout duration (15 minutes). */
422
434
  declare const PASSCODE_LOCKOUT_MAX_MS = 900000;
435
+ /** Pure lockout duration for a tier (exported for property tests). */
436
+ declare function computePasscodeLockoutDurationMs(tier: number): number;
423
437
  /** Throws when the vault is temporarily locked after too many failed unlock attempts. */
424
438
  declare function assertPasscodeUnlockAllowed(publicAddress: string): Promise<void>;
425
439
  /** Record a failed passcode unlock attempt; triggers lockout at threshold. */
@@ -429,8 +443,6 @@ declare function recordPasscodeUnlockSuccess(publicAddress: string): Promise<voi
429
443
  declare function getPasscodeLockoutState(publicAddress: string): Promise<PasscodeLockoutRecord & {
430
444
  retryAfterMs: number;
431
445
  }>;
432
- /** @internal Test helper — reset lockout without clearing vault. */
433
- declare function clearPasscodeLockoutForTests(publicAddress: string): Promise<void>;
434
446
 
435
447
  interface PasscodeStrengthResult {
436
448
  score: 0 | 1 | 2 | 3 | 4;
@@ -453,8 +465,8 @@ declare const EMBEDDED_WALLET_PASSCODE_MAX_LENGTH = 128;
453
465
  * Uses native Web Crypto — no WASM bundle required.
454
466
  */
455
467
  declare const EMBEDDED_WALLET_PIN_PBKDF2_ITERATIONS = 600000;
456
- /** Legacy passkey PBKDF2 fallback iteration count (pre-PIN vaults). */
457
- declare const EMBEDDED_WALLET_PASSKEY_PBKDF2_ITERATIONS = 310000;
468
+ /** Passkey PBKDF2 fallback iteration count (matches PIN path; OWASP 2023 guidance). */
469
+ declare const EMBEDDED_WALLET_PASSKEY_PBKDF2_ITERATIONS = 600000;
458
470
  declare function normalizePasscode(passcode: string): string;
459
471
  /** Validate citizen-chosen passcode before KDF. */
460
472
  declare function assertValidPasscode(passcode: string): void;
@@ -479,16 +491,20 @@ declare function recoveryMnemonicAddress(mnemonic: string, keyType: EmbeddedWall
479
491
  /** Build the recovery phrase for an unlocked plaintext payload. */
480
492
  declare function recoveryMnemonicFromPlaintext(plaintext: EmbeddedWalletPlaintext): string;
481
493
 
482
- interface CreateEmbeddedWalletOptions {
494
+ interface EmbeddedWalletScopeOptions {
495
+ /** Supabase user id or other account key — scopes IndexedDB vault storage per account. */
496
+ scopeId?: string;
497
+ }
498
+ interface CreateEmbeddedWalletOptions extends EmbeddedWalletScopeOptions {
483
499
  passcode: string;
484
500
  }
485
- interface UnlockEmbeddedWalletOptions {
501
+ interface UnlockEmbeddedWalletOptions extends EmbeddedWalletScopeOptions {
486
502
  passcode?: string;
487
503
  }
488
- interface RevealEmbeddedRecoveryPhraseOptions {
504
+ interface RevealEmbeddedRecoveryPhraseOptions extends EmbeddedWalletScopeOptions {
489
505
  passcode?: string;
490
506
  }
491
- interface RecoverEmbeddedWalletOptions {
507
+ interface RecoverEmbeddedWalletOptions extends EmbeddedWalletScopeOptions {
492
508
  passcode: string;
493
509
  mnemonic: string;
494
510
  /** When omitted, inferred from expectedAddress or defaults to hd-derived. */
@@ -499,13 +515,25 @@ interface RecoverEmbeddedWalletOptions {
499
515
  /** When true, replaces an existing vault on this device (e.g. after device loss). */
500
516
  replaceExisting?: boolean;
501
517
  }
502
- interface EnableEmbeddedPasskeyUnlockOptions {
518
+ interface EnableEmbeddedPasskeyUnlockOptions extends EmbeddedWalletScopeOptions {
503
519
  passcode: string;
504
520
  userId: Uint8Array;
505
521
  userName: string;
506
522
  displayName: string;
507
523
  rpId?: string;
508
524
  }
525
+ interface MigrateLegacyEmbeddedWalletOptions extends EmbeddedWalletScopeOptions {
526
+ scopeId: string;
527
+ passcode?: string;
528
+ }
529
+ interface ImportEmbeddedBackupOptions extends EmbeddedWalletScopeOptions {
530
+ /** When true, replaces an existing vault on this device (e.g. intentional restore). */
531
+ replaceExisting?: boolean;
532
+ }
533
+ interface ClearEmbeddedWalletOptions extends EmbeddedWalletScopeOptions {
534
+ }
535
+ interface AcknowledgeEmbeddedBackupOptions extends EmbeddedWalletScopeOptions {
536
+ }
509
537
  interface EmbeddedWalletSession {
510
538
  address: string;
511
539
  vault: EmbeddedWalletVaultV1;
@@ -513,8 +541,15 @@ interface EmbeddedWalletSession {
513
541
  }
514
542
  declare function vaultUsesPasskeyUnlock(vault: EmbeddedWalletVaultV1): boolean;
515
543
  declare function vaultUsesPasscodeUnlock(vault: EmbeddedWalletVaultV1): boolean;
516
- /** Returns true if an encrypted vault exists in IndexedDB. */
517
- declare function hasEmbeddedWallet(): Promise<boolean>;
544
+ /** Returns true if an encrypted vault exists under the given scope (not the legacy key). */
545
+ declare function hasEmbeddedWallet(options?: EmbeddedWalletScopeOptions): Promise<boolean>;
546
+ /** Returns true if an unscoped legacy vault still exists under the "primary" key. */
547
+ declare function hasLegacyEmbeddedWallet(): Promise<boolean>;
548
+ /**
549
+ * Verify ownership of a legacy "primary" vault, copy it to a scoped key, and remove the legacy entry.
550
+ * Does not run automatically — callers must confirm with the user first.
551
+ */
552
+ declare function migrateLegacyEmbeddedWallet(options: MigrateLegacyEmbeddedWalletOptions): Promise<EmbeddedWalletSession>;
518
553
  /** Create passcode-protected encrypted vault; does not unlock signer until backup is acknowledged. */
519
554
  declare function createEmbeddedWallet(options: CreateEmbeddedWalletOptions): Promise<{
520
555
  address: string;
@@ -551,11 +586,11 @@ declare function getEmbeddedWalletSession(): EmbeddedWalletSession | null;
551
586
  /** Offline signer for CosmJS; enforces backup gate before signing. */
552
587
  declare function getEmbeddedOfflineSigner(): OfflineDirectSigner;
553
588
  /** Mark backup downloaded/acknowledged and persist. Returns backup file payload. */
554
- declare function acknowledgeEmbeddedBackup(): Promise<EmbeddedWalletBackupFileV1>;
589
+ declare function acknowledgeEmbeddedBackup(options?: AcknowledgeEmbeddedBackupOptions): Promise<EmbeddedWalletBackupFileV1>;
555
590
  declare function downloadEmbeddedBackupFile(backup: EmbeddedWalletBackupFileV1, filename?: string): void;
556
591
  /** Restore vault from user-held backup file (requires passcode or passkey to decrypt). */
557
- declare function importEmbeddedBackup(json: string): Promise<EmbeddedWalletVaultV1>;
558
- declare function clearEmbeddedWallet(): Promise<void>;
592
+ declare function importEmbeddedBackup(json: string, options?: ImportEmbeddedBackupOptions): Promise<EmbeddedWalletVaultV1>;
593
+ declare function clearEmbeddedWallet(options?: ClearEmbeddedWalletOptions): Promise<void>;
559
594
 
560
595
  /**
561
596
  * Kingdom Chain on-chain denom and display metadata.
@@ -599,4 +634,109 @@ declare function signCitizenshipAttestation(params: SubmitApplicationParams): Pr
599
634
  input: AttestationPayloadInput;
600
635
  }>;
601
636
 
602
- export { ATTESTATION_TYPE_CITIZENSHIP_APPLICATION, ATTESTATION_TYPE_RECOVERY, ApplicationStatus, type AttestationPayloadInput, BECH32_PREFIX, type BrowserWalletApi, CHAIN_COIN_TYPE, type ChainCurrency, type ChainInfo, type CosmostationWindowApi, type CreateEmbeddedWalletOptions, DEFAULT_CHAIN_ID, DEFAULT_REST_URL, DEFAULT_RPC_URL, EMBEDDED_WALLET_KDF_PBKDF2, EMBEDDED_WALLET_KDF_PIN, EMBEDDED_WALLET_KDF_PRF, EMBEDDED_WALLET_KEY_DIRECT_ENTROPY, EMBEDDED_WALLET_KEY_HD_DERIVED, EMBEDDED_WALLET_PASSCODE_MAX_LENGTH, EMBEDDED_WALLET_PASSCODE_MIN_LENGTH, EMBEDDED_WALLET_PASSKEY_PBKDF2_ITERATIONS, EMBEDDED_WALLET_PIN_PBKDF2_ITERATIONS, EMBEDDED_WALLET_RECOVERY_PHRASE_DIRECT_ENTROPY_WARNING, EMBEDDED_WALLET_RECOVERY_PHRASE_GENERAL_WARNING, EMBEDDED_WALLET_VAULT_VERSION, type EmbeddedWalletBackupFileV1, EmbeddedWalletBackupRequiredError, type EmbeddedWalletKdf, type EmbeddedWalletKeyType, EmbeddedWalletLockoutError, type EmbeddedWalletPlaintext, type EmbeddedWalletRecoveryPhraseReveal, type EmbeddedWalletRecoveryPhraseWarning, type EmbeddedWalletSession, EmbeddedWalletVaultError, type EmbeddedWalletVaultV1, EmbeddedWalletWeakPasscodeError, type EnableEmbeddedPasskeyUnlockOptions, type EncryptWalletOptions, InvalidChainConfigError, MsgSubmitApplication, MsgSubmitRecoveryAttestation, PASSCODE_LOCKOUT_FAILURE_THRESHOLD, PASSCODE_LOCKOUT_INITIAL_MS, PASSCODE_LOCKOUT_MAX_MS, type PasscodeBlockReason, type PasscodeLockoutRecord, type PasscodeStrengthLabel, type PasscodeStrengthResult, type PasskeyAssertionResult, type PasskeyRegistrationResult, type RecoverEmbeddedWalletOptions, RecoveryAttestationStatus, type RevealEmbeddedRecoveryPhraseOptions, RpcConnectionError, type SubmitApplicationParams, UKDR_DECIMALS, UKDR_DISPLAY_DENOM, UKDR_MINIMAL_DENOM, type UnlockEmbeddedWalletOptions, WALLETCONNECT_COSMOS_METHODS, WALLETCONNECT_COSMOS_NAMESPACE, WEBAUTHN_RP_NAME, WalletAccountError, type WalletConnectChainConfig, type WalletConnectConnectResult, type WalletConnectMetadata, WalletConnectNotInitializedError, WalletConnectSessionError, WalletConnectSigningError, WalletConnectionError, WalletConnectionRejectedError, WalletNotInstalledError, type WebAuthnPrfCapabilities, WebAuthnUnavailableError, WebAuthnUserCancelledError, acknowledgeEmbeddedBackup, addressFromHdMnemonic, addressFromPrivateKey, assertPasscodeAllowedForCreation, assertPasscodeUnlockAllowed, assertPasskey, assertValidPasscode, assertValidRecoveryMnemonic, assertVaultPermitsTransaction, attestationSignPayload, buildKingdomChainInfo, buildRequiredCosmosNamespaces, buildSubmitApplicationMsg, clearEmbeddedWallet, clearPasscodeLockoutForTests, clearPasscodeLockoutRecord, clearVaultFromIndexedDb, connectCosmostation, connectKeplr, connectLeap, connectWalletConnect, createBrowserSigningClient, createEmbeddedWallet, createHdDerivedPlaintext, createKingdomChainRegistry, createPasskeyMaterialFromAssertion, createPbkdf2Salt, createWalletConnectOfflineSigner, decodeCredentialId, decodeDirectEntropyMnemonic, decryptWalletPayload, defaultEmbeddedHdPath, deriveKekFromPasscode, deriveKekFromPbkdf2, deriveKekFromPrf, derivePrivateKeyFromHdMnemonic, detectRecoveryMnemonicKeyType, detectWebAuthnPrfCapabilities, disconnectWalletConnect, downloadEmbeddedBackupFile, embeddedPlaintextToSigner, enableEmbeddedPasskeyUnlock, encodeCredentialId, encodeDirectEntropyMnemonic, encryptWalletPayload, evaluatePasscodeStrength, exportEncryptedBackup, getCosmostationKeplrApi, getEmbeddedOfflineSigner, getEmbeddedWalletSession, getPasscodeLockoutState, hasEmbeddedWallet, hasMixedCharacterClasses, importEmbeddedBackup, initWalletConnectClient, isCosmostationAvailable, isKeplrAvailable, isLeapAvailable, loadPasscodeLockoutRecord, loadVaultFromIndexedDb, lockEmbeddedWallet, markVaultBackupAcknowledged, normalizePasscode, normalizeRecoveryMnemonic, parseEncryptedBackup, parseWalletConnectAccount, plaintextFromRecoveryMnemonic, providerSeedFromHex, publicKeyFromPrivateSeed, readPrfOutput, recordPasscodeUnlockFailure, recordPasscodeUnlockSuccess, recoverEmbeddedWalletFromMnemonic, recoveryMnemonicAddress, recoveryMnemonicFromPlaintext, registerPasskey, resolvePlaintextKeyType, restoreWalletConnectSession, revealEmbeddedRecoveryPhrase, savePasscodeLockoutRecord, saveVaultToIndexedDb, selectEmbeddedWalletKdf, serializeBackupFile, signAttestationPayload, signCitizenshipAttestation, suggestAndConnect, toWalletConnectCosmosChainId, unlockEmbeddedWallet, validateChainConfig, vaultUsesPasscodeUnlock, vaultUsesPasskeyUnlock };
637
+ /** Parse a human KDR amount (e.g. "2" or "2.5") into ukdr base units string. */
638
+ declare function parseKdrToUkdr(amountKdr: string): string;
639
+ /** Format ukdr base units as KDR with up to 6 decimal places (trailing zeros trimmed). */
640
+ declare function formatUkdrAsKdr(amountUkdr: string | bigint): string;
641
+ declare function ukdrCoin(amountUkdr: string | bigint): {
642
+ denom: string;
643
+ amount: string;
644
+ };
645
+
646
+ /** FinalizedReward is a server-computed claimable reward for one citizen-day. */
647
+ interface FinalizedReward {
648
+ day_id: bigint;
649
+ citizen_id: bigint;
650
+ claimant: string;
651
+ consistency_multiplier_bps: number;
652
+ raw_reward_ukdr: string;
653
+ final_reward_ukdr: string;
654
+ claimed: boolean;
655
+ expires_at_day_id: bigint;
656
+ }
657
+ declare const FinalizedReward: MessageFns$1<FinalizedReward>;
658
+ type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
659
+ type DeepPartial$1<T> = T extends bigint ? string | number | bigint : T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
660
+ [K in keyof T]?: DeepPartial$1<T[K]>;
661
+ } : Partial<T>;
662
+ interface MessageFns$1<T> {
663
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
664
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
665
+ create(base?: DeepPartial$1<T>): T;
666
+ fromPartial(object: DeepPartial$1<T>): T;
667
+ }
668
+
669
+ declare class RestQueryError extends Error {
670
+ readonly status?: number | undefined;
671
+ constructor(message: string, status?: number | undefined, cause?: unknown);
672
+ }
673
+ interface BankBalanceResponse {
674
+ balances: Array<{
675
+ denom: string;
676
+ amount: string;
677
+ }>;
678
+ }
679
+ /** Fetch ukdr balance for an address via LCD bank query. */
680
+ declare function fetchUkdrBalance(restUrl: string, address: string): Promise<string>;
681
+ interface UnclaimedRewardsResponse {
682
+ rewards: FinalizedReward[];
683
+ }
684
+ /** List finalized, unexpired, unclaimed rewards for a citizen wallet. */
685
+ declare function fetchUnclaimedFinalizedRewards(restUrl: string, address: string): Promise<FinalizedReward[]>;
686
+ interface FeeGrantAllowancesResponse {
687
+ allowances: Array<{
688
+ granter: string;
689
+ grantee: string;
690
+ allowance?: unknown;
691
+ }>;
692
+ }
693
+ /**
694
+ * Returns the first active feegrant granter for grantee, if any.
695
+ * Kingdom OS should grant claim gas via DEC-010 hot wallet before first claim.
696
+ */
697
+ declare function fetchFeeGrantGranter(restUrl: string, grantee: string): Promise<string | null>;
698
+
699
+ declare class CitizenTxError extends Error {
700
+ readonly code: CitizenTxErrorCode;
701
+ constructor(message: string, code: CitizenTxErrorCode, cause?: unknown);
702
+ }
703
+ type CitizenTxErrorCode = "INSUFFICIENT_FEE" | "INSUFFICIENT_BALANCE" | "SEQUENCE_MISMATCH" | "TX_FAILED" | "TIMEOUT" | "INVALID_INPUT";
704
+ interface BroadcastConfirmOptions {
705
+ /** Poll interval while waiting for inclusion (default 1500ms). */
706
+ pollIntervalMs?: number;
707
+ /** Max wait after broadcast before TIMEOUT (default 90s). */
708
+ timeoutMs?: number;
709
+ }
710
+ interface BroadcastConfirmResult {
711
+ hash: string;
712
+ height: number;
713
+ code: number;
714
+ rawLog: string;
715
+ /** Tx result after broadcast (DeliverTxResponse) or re-indexed confirmation (IndexedTx). */
716
+ deliverTx: DeliverTxResponse | IndexedTx;
717
+ }
718
+ declare function buildSendUkdrMsg(fromAddress: string, toAddress: string, amountKdr: string): EncodeObject;
719
+ declare function buildClaimRewardMsg(claimer: string, dayId: bigint | number): EncodeObject;
720
+ declare function defaultUkdrTxFee(feeUkdr?: string, feeGranter?: string): StdFee;
721
+ declare function citizenTxErrorMessage(code: CitizenTxErrorCode): string;
722
+ /** Broadcast a signed tx and wait until it is indexed with a definitive result code. */
723
+ declare function broadcastAndConfirmTx(client: SigningStargateClient, signerAddress: string, messages: readonly EncodeObject[], fee: StdFee | "auto" | number, memo?: string, options?: BroadcastConfirmOptions): Promise<BroadcastConfirmResult>;
724
+
725
+ /** MsgClaimReward claims a finalized reward for the given reward day. */
726
+ interface MsgClaimReward {
727
+ claimer: string;
728
+ day_id: bigint;
729
+ }
730
+ declare const MsgClaimReward: MessageFns<MsgClaimReward>;
731
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
732
+ type DeepPartial<T> = T extends bigint ? string | number | bigint : T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
733
+ [K in keyof T]?: DeepPartial<T[K]>;
734
+ } : Partial<T>;
735
+ interface MessageFns<T> {
736
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
737
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
738
+ create(base?: DeepPartial<T>): T;
739
+ fromPartial(object: DeepPartial<T>): T;
740
+ }
741
+
742
+ export { ATTESTATION_TYPE_CITIZENSHIP_APPLICATION, ATTESTATION_TYPE_RECOVERY, type AcknowledgeEmbeddedBackupOptions, ApplicationStatus, type AttestationPayloadInput, BECH32_PREFIX, type BankBalanceResponse, type BroadcastConfirmOptions, type BroadcastConfirmResult, type BrowserWalletApi, CHAIN_COIN_TYPE, type ChainCurrency, type ChainInfo, CitizenTxError, type CitizenTxErrorCode, type ClearEmbeddedWalletOptions, type CosmostationWindowApi, type CreateEmbeddedWalletOptions, DEFAULT_CHAIN_ID, DEFAULT_REST_URL, DEFAULT_RPC_URL, EMBEDDED_WALLET_KDF_PBKDF2, EMBEDDED_WALLET_KDF_PIN, EMBEDDED_WALLET_KDF_PRF, EMBEDDED_WALLET_KEY_DIRECT_ENTROPY, EMBEDDED_WALLET_KEY_HD_DERIVED, EMBEDDED_WALLET_PASSCODE_MAX_LENGTH, EMBEDDED_WALLET_PASSCODE_MIN_LENGTH, EMBEDDED_WALLET_PASSKEY_PBKDF2_ITERATIONS, EMBEDDED_WALLET_PIN_PBKDF2_ITERATIONS, EMBEDDED_WALLET_RECOVERY_PHRASE_DIRECT_ENTROPY_WARNING, EMBEDDED_WALLET_RECOVERY_PHRASE_GENERAL_WARNING, EMBEDDED_WALLET_VAULT_VERSION, type EmbeddedWalletBackupFileV1, EmbeddedWalletBackupRequiredError, EmbeddedWalletDecryptError, type EmbeddedWalletKdf, type EmbeddedWalletKeyType, EmbeddedWalletLockoutError, type EmbeddedWalletPlaintext, type EmbeddedWalletRecoveryPhraseReveal, type EmbeddedWalletRecoveryPhraseWarning, type EmbeddedWalletScopeOptions, type EmbeddedWalletSession, EmbeddedWalletVaultError, type EmbeddedWalletVaultV1, EmbeddedWalletWeakPasscodeError, type EnableEmbeddedPasskeyUnlockOptions, type EncryptWalletOptions, type FeeGrantAllowancesResponse, FinalizedReward, type ImportEmbeddedBackupOptions, InvalidChainConfigError, type MigrateLegacyEmbeddedWalletOptions, MsgClaimReward, MsgSubmitApplication, MsgSubmitRecoveryAttestation, PASSCODE_LOCKOUT_FAILURE_THRESHOLD, PASSCODE_LOCKOUT_INITIAL_MS, PASSCODE_LOCKOUT_MAX_MS, type PasscodeBlockReason, type PasscodeLockoutRecord, type PasscodeStrengthLabel, type PasscodeStrengthResult, type PasskeyAssertionResult, type PasskeyRegistrationResult, type RecoverEmbeddedWalletOptions, RecoveryAttestationStatus, RestQueryError, type RevealEmbeddedRecoveryPhraseOptions, RpcConnectionError, type SubmitApplicationParams, UKDR_DECIMALS, UKDR_DISPLAY_DENOM, UKDR_MINIMAL_DENOM, type UnclaimedRewardsResponse, type UnlockEmbeddedWalletOptions, VAULT_LEGACY_KEY, type VaultStorageOptions, WALLETCONNECT_COSMOS_METHODS, WALLETCONNECT_COSMOS_NAMESPACE, WEBAUTHN_RP_NAME, WalletAccountError, type WalletConnectChainConfig, type WalletConnectConnectResult, type WalletConnectMetadata, WalletConnectNotInitializedError, WalletConnectSessionError, WalletConnectSigningError, WalletConnectionError, WalletConnectionRejectedError, WalletNotInstalledError, type WebAuthnPrfCapabilities, WebAuthnUnavailableError, WebAuthnUserCancelledError, acknowledgeEmbeddedBackup, addressFromHdMnemonic, addressFromPrivateKey, assertPasscodeAllowedForCreation, assertPasscodeUnlockAllowed, assertPasskey, assertValidPasscode, assertValidRecoveryMnemonic, assertVaultPermitsTransaction, attestationSignPayload, broadcastAndConfirmTx, buildClaimRewardMsg, buildKingdomChainInfo, buildRequiredCosmosNamespaces, buildSendUkdrMsg, buildSubmitApplicationMsg, citizenTxErrorMessage, clearEmbeddedWallet, clearPasscodeLockoutRecord, clearVaultFromIndexedDb, computePasscodeLockoutDurationMs, connectCosmostation, connectKeplr, connectLeap, connectWalletConnect, createBrowserSigningClient, createEmbeddedWallet, createHdDerivedPlaintext, createKingdomChainRegistry, createPasskeyMaterialFromAssertion, createPbkdf2Salt, createWalletConnectOfflineSigner, decodeCredentialId, decodeDirectEntropyMnemonic, decryptWalletPayload, defaultEmbeddedHdPath, defaultUkdrTxFee, deriveKekFromPasscode, deriveKekFromPbkdf2, deriveKekFromPrf, derivePrivateKeyFromHdMnemonic, detectRecoveryMnemonicKeyType, detectWebAuthnPrfCapabilities, disconnectWalletConnect, downloadEmbeddedBackupFile, embeddedPlaintextToSigner, enableEmbeddedPasskeyUnlock, encodeCredentialId, encodeDirectEntropyMnemonic, encryptWalletPayload, evaluatePasscodeStrength, exportEncryptedBackup, fetchFeeGrantGranter, fetchUkdrBalance, fetchUnclaimedFinalizedRewards, formatUkdrAsKdr, getCosmostationKeplrApi, getEmbeddedOfflineSigner, getEmbeddedWalletSession, getPasscodeLockoutState, hasEmbeddedWallet, hasLegacyEmbeddedWallet, hasMixedCharacterClasses, importEmbeddedBackup, initWalletConnectClient, isCosmostationAvailable, isKeplrAvailable, isLeapAvailable, loadPasscodeLockoutRecord, loadVaultFromIndexedDb, lockEmbeddedWallet, markVaultBackupAcknowledged, migrateLegacyEmbeddedWallet, normalizePasscode, normalizeRecoveryMnemonic, parseEncryptedBackup, parseKdrToUkdr, parseWalletConnectAccount, plaintextFromRecoveryMnemonic, providerSeedFromHex, publicKeyFromPrivateSeed, readPrfOutput, recordPasscodeUnlockFailure, recordPasscodeUnlockSuccess, recoverEmbeddedWalletFromMnemonic, recoveryMnemonicAddress, recoveryMnemonicFromPlaintext, registerPasskey, resolvePlaintextKeyType, resolveVaultStorageKey, restoreWalletConnectSession, revealEmbeddedRecoveryPhrase, savePasscodeLockoutRecord, saveVaultToIndexedDb, selectEmbeddedWalletKdf, serializeBackupFile, signAttestationPayload, signCitizenshipAttestation, suggestAndConnect, toWalletConnectCosmosChainId, ukdrCoin, unlockEmbeddedWallet, validateChainConfig, vaultUsesPasscodeUnlock, vaultUsesPasskeyUnlock };