@kingdomchain/wallet-client 0.4.3 → 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
@@ -1,130 +1,131 @@
1
- # Kingdom Chain TypeScript / CosmJS client
2
-
3
- Self-contained TypeScript package for constructing, signing, and broadcasting Kingdom Chain transactions via [CosmJS](https://github.com/cosmos/cosm-js). Includes a Keplr / Leap / Cosmostation browser wallet connector for non-custodial signing.
4
-
5
- ## Scope (current)
6
-
7
- - **MsgSubmitApplication** (citizenship application)
8
- - **MsgSubmitRecoveryAttestation** (wallet recovery attestation)
9
- - **Browser wallet connector** (`src/browserSigner.ts`) — Keplr / Leap / Cosmostation via `experimentalSuggestChain` + `OfflineDirectSigner`
10
- - **WalletConnect mobile signer** (`src/walletConnectSigner.ts`) — WalletConnect v2 `OfflineDirectSigner` adapter
11
- - **Embedded passkey wallet** (`src/embeddedWallet/`) — WebAuthn PRF + PBKDF2 fallback, IndexedDB vault, mandatory backup gate
12
- - Ed25519 attestation signing ported from `x/compliance/types/attestation.go`
13
- - Proto codegen via `ts-proto` + `buf`
14
-
15
- ## Setup
16
-
17
- ```bash
18
- cd clients/ts
19
- npm install
20
- npm run codegen # regenerate from ../../proto (requires buf + repo root)
21
- ```
22
-
23
- ## Testing
24
-
25
- ```bash
26
- cd clients/ts
27
- npm test # unit + property fuzz (1500 cross-lang iterations)
28
- npm run test:mutate # Stryker mutation testing on attestation.ts + registry.ts
29
- ```
30
-
31
- Cross-language fuzz compares TS `attestationSignPayload` against a compiled Go helper (`payload_attestation.go`) for 1000 citizenship + 500 recovery inputs.
32
-
33
- ## Live E2E (Ona devnet)
34
-
35
- Requires a running node at `~/.kingdomchain-e2e` (see `scripts/citizen-compliance-e2e/run.sh`).
36
-
37
- ```bash
38
- # Build CLI if needed
39
- go build -o /tmp/kingdomchaind ./cmd/kingdomchaind
40
-
41
- cd clients/ts
42
- npm run e2e:submit-application
43
- npm run e2e:submit-recovery
44
- ```
45
-
46
- Environment overrides:
47
-
48
- | Variable | Default |
49
- |----------|---------|
50
- | `CHAIN_ID` | `kingdomchain-e2e` |
51
- | `RPC_URL` | `http://127.0.0.1:26657` |
52
- | `REST_URL` | `http://127.0.0.1:1317` |
53
- | `HOME_DIR` | `~/.kingdomchain-e2e` |
54
- | `KINGDOMCHAIND` | `/tmp/kingdomchaind` |
55
- | `PROVIDER_SEED_HEX` | devnet provider-alpha seed from e2e script |
56
-
57
- ## Browser wallet demo (Keplr / Leap)
58
-
59
- Manual click-through demo for Isa — **not automated in CI**. Unit tests mock `window.keplr` / `window.leap`; the demo requires a real extension in your browser.
60
-
61
- 1. Start the Ona devnet (`scripts/citizen-compliance-e2e/run.sh` or your existing node).
62
- 2. Fund the Keplr/Leap account you will connect with (`ukdr` on `kingdomchain-e2e`).
63
- 3. From `clients/ts`:
64
-
65
- ```bash
66
- npm run demo
67
- ```
68
-
69
- 4. Open the printed URL (default `http://localhost:5173`) in a browser with Keplr or Leap installed.
70
- 5. Click **Connect Keplr** or **Connect Leap**, approve the chain suggestion + connection, then **Submit test application**.
71
-
72
- Optional Vite env overrides (prefix `VITE_`):
73
-
74
- | Variable | Default |
75
- |----------|---------|
76
- | `VITE_CHAIN_ID` | `kingdomchain-e2e` |
77
- | `VITE_RPC_URL` | `http://127.0.0.1:26657` |
78
- | `VITE_REST_URL` | `http://127.0.0.1:1317` |
79
- | `VITE_PROVIDER_ID` | `provider-alpha` |
80
- | `VITE_POLICY_VERSION` | `policy-v1` |
81
- | `VITE_PROVIDER_SEED_HEX` | devnet provider-alpha seed |
82
-
83
- 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
- ## Kingdom OS / Base44 reference wiring
86
-
87
- Copy-paste React integration lives in `clients/kingdom-os-reference/`:
88
-
89
- - `useKingdomWallet.js` — unified hook for Keplr, Leap, Cosmostation, WalletConnect, embedded passkey
90
- - `WalletStep.jsx` — onboarding UI with side-by-side connect buttons
91
- - `WalletConnectQrModal.jsx` — QR pairing modal (`VITE_WC_PROJECT_ID` required)
92
- - `EmbeddedWalletPanel.jsx` — create / unlock / mandatory backup gate
93
-
94
- See `clients/kingdom-os-reference/README.md` for env vars and usage.
95
-
96
- ### Embedded wallet API (`src/embeddedWallet/`)
97
-
98
- - `createEmbeddedWallet({ userId, userName, displayName, rpId? })` — register passkey + encrypt vault in IndexedDB
99
- - `unlockEmbeddedWallet()` — passkey assertion → in-memory session
100
- - `getEmbeddedOfflineSigner()` — CosmJS signer; throws `EmbeddedWalletBackupRequiredError` until backup acknowledged
101
- - `acknowledgeEmbeddedBackup()` / `downloadEmbeddedBackupFile()` — mandatory backup gate
102
- - `importEmbeddedBackup(json)` — restore vault from user-held backup file
103
- - `hasEmbeddedWallet()` / `clearEmbeddedWallet()` — lifecycle helpers
104
-
105
- KDF selection: WebAuthn PRF when available, PBKDF2-passkey fallback (310k iterations — bump to 600k+ before production).
106
-
107
- **Recovery gap (phase 3):** The encrypted backup file requires the original passkey to decrypt. Option D (BIP39 mnemonic export for passkey loss without iCloud/Google sync) is approved in the ADR but **not implemented in phase 2** — see `docs/architecture/ADR-EMBEDDED-WALLET-ONBOARDING.md` § "Known gap: Option D mnemonic recovery".
108
-
109
- ### WalletConnect API (`src/walletConnectSigner.ts`)
110
-
111
- - `initWalletConnectClient({ chainId, projectId, metadata })`
112
- - `connectWalletConnect(client, chainId)` → `{ uri, session, signer }` (display `uri` as QR)
113
- - `restoreWalletConnectSession(client, chainId)` — reconnect on page load
114
- - `createWalletConnectOfflineSigner(client, session, chainId)`
115
- - `disconnectWalletConnect(client, session)`
116
-
117
- ### Browser wallet API (`src/browserSigner.ts`)
118
-
119
- - `isKeplrAvailable()` / `isLeapAvailable()`
120
- - `buildKingdomChainInfo(chainId, rpcUrl, restUrl)` — `ukdr` / KDR with **6 decimals** (`x/supply/types/constants.go`, `TOKENOMICS_COSMOS_SPEC.md`), bech32 prefix `king`, coin type 118
121
- - `connectKeplr(chainInfo)` / `connectLeap(chainInfo)` — suggest chain + enable + offline signer
122
- - `createBrowserSigningClient(rpcUrl, signer)` — `SigningStargateClient` + `createKingdomChainRegistry()`
123
-
124
- ## Encoding notes (for Base44 frontend)
125
-
126
- 1. **Custom protobuf registry** — CosmJS `SigningStargateClient` must be constructed with a `Registry` that includes Kingdom Chain message type URLs (e.g. `/isatheword.kingdomchain.compliance.v1.MsgSubmitApplication`) alongside `defaultRegistryTypes`.
127
- 2. **Attestation signing is off-chain** — providers sign a canonical SHA256-payload (not the tx bytes). The TS port in `src/attestation.ts` must match Go `AttestationSignPayload` exactly; the E2E script cross-checks against `scripts/citizen-compliance-e2e/sign_attestation.go`.
128
- 3. **Timestamps** — proto `google.protobuf.Timestamp` fields (`issued_at`, `expires_at`) are `Date` in generated TS; encoding uses `@bufbuild/protobuf` wire format.
129
- 4. **Uint64 fields** — `provider_key_version` is `bigint` in generated types.
130
- 5. **Tx signer** — `MsgSubmitApplication` signer is `applicant_wallet`; the fee payer / signer must be the applicant's secp256k1 account (`king` bech32 prefix, coin type 118).
1
+ # Kingdom Chain TypeScript / CosmJS client
2
+
3
+ Self-contained TypeScript package for constructing, signing, and broadcasting Kingdom Chain transactions via [CosmJS](https://github.com/cosmos/cosm-js). Includes a Keplr / Leap / Cosmostation browser wallet connector for non-custodial signing.
4
+
5
+ ## Scope (current)
6
+
7
+ - **MsgSubmitApplication** (citizenship application)
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`
10
+ - **Browser wallet connector** (`src/browserSigner.ts`) — Keplr / Leap / Cosmostation via `experimentalSuggestChain` + `OfflineDirectSigner`
11
+ - **WalletConnect mobile signer** (`src/walletConnectSigner.ts`) — WalletConnect v2 `OfflineDirectSigner` adapter
12
+ - **Embedded passkey wallet** (`src/embeddedWallet/`) — WebAuthn PRF + PBKDF2 fallback, IndexedDB vault, mandatory backup gate
13
+ - Ed25519 attestation signing ported from `x/compliance/types/attestation.go`
14
+ - Proto codegen via `ts-proto` + `buf`
15
+
16
+ ## Setup
17
+
18
+ ```bash
19
+ cd clients/ts
20
+ npm install
21
+ npm run codegen # regenerate from ../../proto (requires buf + repo root)
22
+ ```
23
+
24
+ ## Testing
25
+
26
+ ```bash
27
+ cd clients/ts
28
+ npm test # unit + property fuzz (1500 cross-lang iterations)
29
+ npm run test:mutate # Stryker mutation testing on attestation.ts + registry.ts
30
+ ```
31
+
32
+ Cross-language fuzz compares TS `attestationSignPayload` against a compiled Go helper (`payload_attestation.go`) for 1000 citizenship + 500 recovery inputs.
33
+
34
+ ## Live E2E (Ona devnet)
35
+
36
+ Requires a running node at `~/.kingdomchain-e2e` (see `scripts/citizen-compliance-e2e/run.sh`).
37
+
38
+ ```bash
39
+ # Build CLI if needed
40
+ go build -o /tmp/kingdomchaind ./cmd/kingdomchaind
41
+
42
+ cd clients/ts
43
+ npm run e2e:submit-application
44
+ npm run e2e:submit-recovery
45
+ ```
46
+
47
+ Environment overrides:
48
+
49
+ | Variable | Default |
50
+ |----------|---------|
51
+ | `CHAIN_ID` | `kingdomchain-e2e` |
52
+ | `RPC_URL` | `http://127.0.0.1:26657` |
53
+ | `REST_URL` | `http://127.0.0.1:1317` |
54
+ | `HOME_DIR` | `~/.kingdomchain-e2e` |
55
+ | `KINGDOMCHAIND` | `/tmp/kingdomchaind` |
56
+ | `PROVIDER_SEED_HEX` | devnet provider-alpha seed from e2e script |
57
+
58
+ ## Browser wallet demo (Keplr / Leap)
59
+
60
+ Manual click-through demo for Isa — **not automated in CI**. Unit tests mock `window.keplr` / `window.leap`; the demo requires a real extension in your browser.
61
+
62
+ 1. Start the Ona devnet (`scripts/citizen-compliance-e2e/run.sh` or your existing node).
63
+ 2. Fund the Keplr/Leap account you will connect with (`ukdr` on `kingdomchain-e2e`).
64
+ 3. From `clients/ts`:
65
+
66
+ ```bash
67
+ npm run demo
68
+ ```
69
+
70
+ 4. Open the printed URL (default `http://localhost:5173`) in a browser with Keplr or Leap installed.
71
+ 5. Click **Connect Keplr** or **Connect Leap**, approve the chain suggestion + connection, then **Submit test application**.
72
+
73
+ Optional Vite env overrides (prefix `VITE_`):
74
+
75
+ | Variable | Default |
76
+ |----------|---------|
77
+ | `VITE_CHAIN_ID` | `kingdomchain-e2e` |
78
+ | `VITE_RPC_URL` | `http://127.0.0.1:26657` |
79
+ | `VITE_REST_URL` | `http://127.0.0.1:1317` |
80
+ | `VITE_PROVIDER_ID` | `provider-alpha` |
81
+ | `VITE_POLICY_VERSION` | `policy-v1` |
82
+ | `VITE_PROVIDER_SEED_HEX` | devnet provider-alpha seed |
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.
85
+
86
+ ## Kingdom OS / Vercel reference wiring
87
+
88
+ Copy-paste React integration lives in `clients/kingdom-os-reference/` (for the **kingdom-os** Vercel app — Base44 is superseded):
89
+
90
+ - `useKingdomWallet.js` — unified hook for Keplr, Leap, Cosmostation, WalletConnect, embedded passkey
91
+ - `WalletStep.jsx` — onboarding UI with side-by-side connect buttons
92
+ - `WalletConnectQrModal.jsx` — QR pairing modal (`VITE_WC_PROJECT_ID` required)
93
+ - `EmbeddedWalletPanel.jsx` — create / unlock / mandatory backup gate
94
+
95
+ See `clients/kingdom-os-reference/README.md` for env vars and usage.
96
+
97
+ ### Embedded wallet API (`src/embeddedWallet/`)
98
+
99
+ - `createEmbeddedWallet({ userId, userName, displayName, rpId? })` — register passkey + encrypt vault in IndexedDB
100
+ - `unlockEmbeddedWallet()` — passkey assertion → in-memory session
101
+ - `getEmbeddedOfflineSigner()` — CosmJS signer; throws `EmbeddedWalletBackupRequiredError` until backup acknowledged
102
+ - `acknowledgeEmbeddedBackup()` / `downloadEmbeddedBackupFile()` — mandatory backup gate
103
+ - `importEmbeddedBackup(json)` — restore vault from user-held backup file
104
+ - `hasEmbeddedWallet()` / `clearEmbeddedWallet()` — lifecycle helpers
105
+
106
+ KDF selection: WebAuthn PRF when available, PBKDF2-passkey fallback (310k iterations — bump to 600k+ before production).
107
+
108
+ **Recovery gap (phase 3):** The encrypted backup file requires the original passkey to decrypt. Option D (BIP39 mnemonic export for passkey loss without iCloud/Google sync) is approved in the ADR but **not implemented in phase 2** — see `docs/architecture/ADR-EMBEDDED-WALLET-ONBOARDING.md` § "Known gap: Option D mnemonic recovery".
109
+
110
+ ### WalletConnect API (`src/walletConnectSigner.ts`)
111
+
112
+ - `initWalletConnectClient({ chainId, projectId, metadata })`
113
+ - `connectWalletConnect(client, chainId)` → `{ uri, session, signer }` (display `uri` as QR)
114
+ - `restoreWalletConnectSession(client, chainId)` — reconnect on page load
115
+ - `createWalletConnectOfflineSigner(client, session, chainId)`
116
+ - `disconnectWalletConnect(client, session)`
117
+
118
+ ### Browser wallet API (`src/browserSigner.ts`)
119
+
120
+ - `isKeplrAvailable()` / `isLeapAvailable()`
121
+ - `buildKingdomChainInfo(chainId, rpcUrl, restUrl)` — `ukdr` / KDR with **6 decimals** (`x/supply/types/constants.go`, `TOKENOMICS_COSMOS_SPEC.md`), bech32 prefix `king`, coin type 118
122
+ - `connectKeplr(chainInfo)` / `connectLeap(chainInfo)` — suggest chain + enable + offline signer
123
+ - `createBrowserSigningClient(rpcUrl, signer)` — `SigningStargateClient` + `createKingdomChainRegistry()`
124
+
125
+ ## Encoding notes (for Base44 frontend)
126
+
127
+ 1. **Custom protobuf registry** — CosmJS `SigningStargateClient` must be constructed with a `Registry` that includes Kingdom Chain message type URLs (e.g. `/isatheword.kingdomchain.compliance.v1.MsgSubmitApplication`) alongside `defaultRegistryTypes`.
128
+ 2. **Attestation signing is off-chain** — providers sign a canonical SHA256-payload (not the tx bytes). The TS port in `src/attestation.ts` must match Go `AttestationSignPayload` exactly; the E2E script cross-checks against `scripts/citizen-compliance-e2e/sign_attestation.go`.
129
+ 3. **Timestamps** — proto `google.protobuf.Timestamp` fields (`issued_at`, `expires_at`) are `Date` in generated TS; encoding uses `@bufbuild/protobuf` wire format.
130
+ 4. **Uint64 fields** — `provider_key_version` is `bigint` in generated types.
131
+ 5. **Tx signer** — `MsgSubmitApplication` signer is `applicant_wallet`; the fee payer / signer must be the applicant's secp256k1 account (`king` bech32 prefix, coin type 118).
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. */
@@ -634,4 +634,109 @@ declare function signCitizenshipAttestation(params: SubmitApplicationParams): Pr
634
634
  input: AttestationPayloadInput;
635
635
  }>;
636
636
 
637
- export { ATTESTATION_TYPE_CITIZENSHIP_APPLICATION, ATTESTATION_TYPE_RECOVERY, type AcknowledgeEmbeddedBackupOptions, ApplicationStatus, type AttestationPayloadInput, BECH32_PREFIX, type BrowserWalletApi, CHAIN_COIN_TYPE, type ChainCurrency, type ChainInfo, 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 ImportEmbeddedBackupOptions, InvalidChainConfigError, type MigrateLegacyEmbeddedWalletOptions, 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, 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, buildKingdomChainInfo, buildRequiredCosmosNamespaces, buildSubmitApplicationMsg, clearEmbeddedWallet, clearPasscodeLockoutRecord, clearVaultFromIndexedDb, computePasscodeLockoutDurationMs, 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, hasLegacyEmbeddedWallet, hasMixedCharacterClasses, importEmbeddedBackup, initWalletConnectClient, isCosmostationAvailable, isKeplrAvailable, isLeapAvailable, loadPasscodeLockoutRecord, loadVaultFromIndexedDb, lockEmbeddedWallet, markVaultBackupAcknowledged, migrateLegacyEmbeddedWallet, normalizePasscode, normalizeRecoveryMnemonic, parseEncryptedBackup, parseWalletConnectAccount, plaintextFromRecoveryMnemonic, providerSeedFromHex, publicKeyFromPrivateSeed, readPrfOutput, recordPasscodeUnlockFailure, recordPasscodeUnlockSuccess, recoverEmbeddedWalletFromMnemonic, recoveryMnemonicAddress, recoveryMnemonicFromPlaintext, registerPasskey, resolvePlaintextKeyType, resolveVaultStorageKey, 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 };