{"version":3,"sources":["../src/data.ts","../src/transaction.ts","../src/network.ts"],"sourcesContent":["// Aleo atomic data types.\n\n/** Aleo address string (view_key * G) */\nexport type address = string;\n\n/** Boolean value (true or false) */\nexport type bool = boolean | string;\n\n/** Aleo group element (often used for commitments or public keys) */\nexport type group = string;\n\n/** Unsigned 8-bit integer (0 to 255) */\nexport type u8 = number | string;\n\n/** Unsigned 16-bit integer (0 to 65,535) */\nexport type u16 = number | string;\n\n/** Unsigned 32-bit integer (0 to 4,294,967,295) */\nexport type u32 = number | string;\n\n/** Unsigned 64-bit integer (bigint for full precision) */\nexport type u64 = bigint | string;\n\n/** Unsigned 128-bit integer (bigint for full precision) */\nexport type u128 = bigint | string;\n\n/** Signed 8-bit integer (-128 to 127) */\nexport type i8 = number | string;\n\n/** Signed 16-bit integer (-32,768 to 32,767) */\nexport type i16 = number | string;\n\n/** Signed 32-bit integer (-2,147,483,648 to 2,147,483,647) */\nexport type i32 = number | string;\n\n/** Signed 64-bit integer (bigint for full precision) */\nexport type i64 = bigint | string;\n\n/** Signed 128-bit integer (bigint for full precision) */\nexport type i128 = bigint | string;\n\n/** Aleo field element */\nexport type field = string;\n\n/** Aleo scalar value */\nexport type scalar = string;\n\n/** Aleo signature string (result of signing a message with a private key) */\nexport type signature = string;\n\n/** A union type of all possible Aleo atomic types */\nexport type Literal =\n  | address\n  | bool\n  | group\n  | u8\n  | u16\n  | u32\n  | u64\n  | u128\n  | i8\n  | i16\n  | i32\n  | i64\n  | i128\n  | field\n  | scalar\n  | signature;\n\n/** An enum enumerating all literal types. */\nexport enum LiteralType {\n  ADDRESS = 'address',\n  BOOL = 'bool',\n  GROUP = 'group',\n  U8 = 'u8',\n  U16 = 'u16',\n  U32 = 'u32',\n  U64 = 'u64',\n  U128 = 'u128',\n  I8 = 'i8',\n  I16 = 'i16',\n  I32 = 'i32',\n  I64 = 'i64',\n  I128 = 'i128',\n  FIELD = 'field',\n  SCALAR = 'scalar',\n  SIGNATURE = 'signature',\n}\n\n/** Aleo struct type */\nexport type Struct = {\n  [key: string]: Array | Literal | Struct;\n};\n\n/** An aleo array type */\nexport type Array = Array[] | Literal[] | Struct[];\n\n/** All possible plaintext types */\nexport type Plaintext = Array | Literal | Struct;\n\n/** An enum enumerating all plaintext types. */\nexport enum PlaintextType {\n  ARRAY = 'array',\n  LITERAL = 'literal',\n  STRUCT = 'struct',\n}\n\n/** Ciphertext type */\nexport type Ciphertext = string;\n\n/** An aleo record type */\nexport interface Record {\n  owner: address;\n  [key: string]: Array | Literal | Struct;\n  nonce: string;\n}\n\n/** An aleo future type */\nexport type Future = {\n  programId: string;\n  function: string;\n  value: Future[] | Plaintext[];\n};\n\n/** A union type of all possible Aleo types */\nexport type Value = Plaintext | Record | Future;\n\n/** An enum enumerating all value types. */\nexport enum ValueType {\n  PLAINTEXT = 'plaintext',\n  RECORD = 'record',\n  FUTURE = 'future',\n}\n","import { LiteralType } from './data';\n\n/**\n * Status of a transaction\n */\nexport enum TransactionStatus {\n  PENDING = 'pending',\n  ACCEPTED = 'accepted',\n  FAILED = 'failed',\n  REJECTED = 'rejected',\n}\n\n/**\n * Represents an Aleo transaction\n */\nexport interface Transaction {\n  /**\n   * The transaction ID\n   */\n  id: string;\n\n  /**\n   * The transaction status\n   */\n  status: TransactionStatus;\n\n  /**\n   * The block height at which the transaction was confirmed\n   */\n  blockHeight?: number;\n\n  /**\n   * The transaction fee\n   */\n  fee?: number;\n\n  /**\n   * The transaction data\n   */\n  data?: Record<string, unknown>;\n}\n\n/**\n * Per-field comparison conditions on a record field. All present operators are AND-combined.\n */\nexport interface RecordFieldFilter {\n  eq?: string;\n  gte?: string;\n  lte?: string;\n  neq?: string;\n}\n\n/**\n * Map from a record field name (or dotted struct path, e.g. \"data.amount\") to a filter.\n * Multiple entries are AND-combined.\n */\nexport type RecordFilters = Record<string, RecordFieldFilter>;\n\n/**\n * A request the dapp emits in place of a literal input. The wallet fulfills the\n * request before passing the transaction to the SDK. See\n * `docs/adapter-privacy-extension.md` for the full specification.\n */\nexport type InputRequest =\n  | {\n      /** Fill the input slot with the active address. Allowed in `address`, `group`, `scalar`, or `field` positions. */\n      type: 'address';\n      label?: string;\n    }\n  | {\n      /**\n       * Use an owned record of type `program/recordname` as the input. When\n       * `uid` is present, it pins a specific record previously returned by\n       * `requestRecords` and `filters` is ignored. When absent, the wallet\n       * auto-selects an unspent record of `recordname` matching `filters`.\n       * `uid` and `filters` are mutually exclusive — supplying both is rejected\n       * before reaching the wallet.\n       *\n       * `recordname` is required so the gate can match the request against the\n       * dapp's grant on the same `(program, recordname, field)` triple the\n       * grant model uses; without it, filter keys that collide across record\n       * types in the same program would be ambiguous. Allowed in `record`,\n       * `dynamic_record`, or `external_record` positions.\n       */\n      type: 'record';\n      program: string;\n      recordname: string;\n      filters?: RecordFilters;\n      uid?: string;\n    }\n  | {\n      /**\n       * Fill the input slot with the output of a wallet-evaluated cryptographic\n       * algorithm. The wallet runs the named `algorithm` over its own state\n       * (view key, wallet-maintained counters, etc.) plus the dapp's `args`,\n       * and substitutes the result into the slot. The dapp never observes the\n       * wallet-side inputs — only the output.\n       *\n       * Strictly opt-in: the wallet refuses every derived request whose\n       * `(algorithm, program, function, inputPosition)` tuple is not present\n       * in the connection's `algorithmsAllowed`. Each algorithm declares its\n       * `args` schema and output Aleo type; the output type determines which\n       * input positions are valid (same rules as `type: \"address\"`).\n       */\n      type: 'derived';\n      algorithm: AlgorithmName;\n      args: Record<string, AlgorithmArg>;\n      label?: string;\n    };\n\n/** Algorithms that conforming wallets are expected to implement. */\nexport const KNOWN_ALGORITHMS = [\n  'program-scoped-blinding-factor',\n  'program-scoped-blinded-address',\n] as const;\n\n/**\n * New algorithms are added to `KNOWN_ALGORITHMS` as they're standardized. The\n * `(string & {})` extension in `AlgorithmName` permits unknown values for\n * forward-compat: a wallet shipping a new algorithm before this catalog is\n * updated can still be addressed. The wallet validates at runtime against its\n * own `algorithmsSupported()` list.\n */\nexport type KnownAlgorithm = (typeof KNOWN_ALGORITHMS)[number];\nexport type AlgorithmName = KnownAlgorithm | (string & Record<never, never>);\n\n/** Arg-level type: an Aleo literal type, or \"string\" for non-literal args (enums, identifiers). */\nexport type ArgType = LiteralType | 'string';\n\n/**\n * One typed argument passed to a wallet-side cryptographic algorithm. The\n * wallet parses `value` according to `type` — either an Aleo primitive type\n * (`LiteralType`) or `\"string\"` for non-literal args such as enum identifiers.\n */\nexport interface AlgorithmArg {\n  type: ArgType;\n  value: string;\n}\n\n/** A per-arg grant constraint: a fixed allowlist of acceptable values, or \"any\". */\nexport type ArgConstraint = string[] | 'any';\n\nconst PROGRAM_SCOPED_ARGS = {\n  mode: { type: 'string' as ArgType, possibleValues: ['issue', 'resolve'] as const },\n  membershipProgram: { type: 'string' as ArgType },\n  membershipMapping: { type: 'string' as ArgType },\n  targetAddress: { type: 'address' as ArgType, optional: true },\n} as const;\n\n/**\n * Static catalog of known algorithms — their dapp-provided `args` schema, the\n * Aleo type of their output, and the input-slot positions where they are\n * valid. The wallet is the source of truth at runtime; this registry lets the\n * SDK and dapp tooling render correct forms and pre-validate shapes.\n */\nexport const ALGORITHM_SCHEMAS = {\n  'program-scoped-blinding-factor': {\n    args: PROGRAM_SCOPED_ARGS,\n    outputType: 'field' as LiteralType,\n    validSlotTypes: ['field', 'scalar', 'group'] as LiteralType[],\n  },\n  'program-scoped-blinded-address': {\n    args: PROGRAM_SCOPED_ARGS,\n    outputType: 'address' as LiteralType,\n    validSlotTypes: ['address', 'group', 'scalar', 'field'] as LiteralType[],\n  },\n} as const satisfies Record<\n  KnownAlgorithm,\n  {\n    args: Record<string, { type: ArgType; possibleValues?: readonly string[]; optional?: boolean }>;\n    outputType: LiteralType;\n    validSlotTypes: LiteralType[];\n  }\n>;\n\n/**\n * One element of a transaction's `inputs` array. A literal Aleo value (string)\n * or an `InputRequest` describing a value the wallet should supply.\n */\nexport type TransactionInput = string | InputRequest;\n\n/**\n * Structured form of a record's plaintext fields, returned alongside the\n * wallet-defined record envelope from `requestRecords`. Only fields the dapp\n * has read access to are present; redacted fields are omitted (not\n * present-with-undefined). See `docs/adapter-privacy-extension.md` for the\n * grant rules that govern field exposure.\n */\nexport interface RecordView {\n  fields: Record<string, string>;\n}\n\n/**\n * Additive contract for the per-record envelope returned by `requestRecords`.\n * Wallets keep their existing record shape (e.g. Shield's `OwnedRecord`); this\n * interface declares the two new fields conforming wallets emit on top.\n *\n * - `recordView` — structured form of the plaintext, populated whenever the\n *   wallet decrypted the record.\n * - `uid` — wallet-issued opaque handle, stable for the lifetime of the\n *   connection. Pass back as `uid` in a `type: \"record\"` `InputRequest` to pin\n *   this exact record. Not derived from the record's commitment, nonce, or tag.\n *\n * Both are optional in the type because pre-spec wallets won't emit them;\n * conforming wallets always populate them.\n */\nexport interface RecordEnvelope {\n  recordView?: RecordView;\n  uid?: string;\n  [legacyField: string]: unknown;\n}\n\n/** Type guard for a literal input slot. */\nexport function isLiteralInput(input: TransactionInput): input is string {\n  return typeof input === 'string';\n}\n\n/** Returns true if any element of `inputs` is an `InputRequest` rather than a literal. */\nexport function hasInputRequest(inputs: TransactionInput[]): boolean {\n  return inputs.some(i => typeof i !== 'string');\n}\n\n/**\n * Transaction creation options\n */\nexport interface TransactionOptions {\n  /**\n   * The program to execute\n   */\n  program: string;\n\n  /**\n   * The function to call\n   */\n  function: string;\n\n  /**\n   * The function inputs. Each entry is either a literal Aleo value (string)\n   * or an `InputRequest` describing a value the wallet should supply.\n   */\n  inputs: TransactionInput[];\n\n  /**\n   * The transaction fee to pay\n   */\n  fee?: number;\n\n  /**\n   * Record indices to use\n   */\n  recordIndices?: number[];\n\n  /**\n   * Whether the fee is private\n   */\n  privateFee?: boolean;\n\n  /**\n   * List of program names that should be imported when calling a dynamic dispatch function.\n   */\n  imports?: string[];\n}\n\n/**\n * Transaction status response\n */\nexport interface TransactionStatusResponse {\n  /**\n   * The transaction status\n   */\n  status: string;\n\n  /**\n   * The onchain transaction ID (if already exists)\n   */\n  transactionId?: string;\n\n  /**\n   * The error message (if any)\n   */\n  error?: string;\n}\n\n/**\n * response of requestTransactionHistory\n */\nexport interface TxHistoryResult {\n  transactions: Array<{\n    transactionId: string;\n    id: string;\n  }>;\n}\n","/**\n * Supported Aleo networks\n */\nexport enum Network {\n  MAINNET = 'mainnet',\n  TESTNET = 'testnet',\n  CANARY = 'canary',\n}\n\n/**\n * Network configuration\n */\nexport interface NetworkConfig {\n  /**\n   * Network name\n   */\n  network: Network;\n\n  /**\n   * API endpoint for the network\n   */\n  apiUrl: string;\n\n  /**\n   * Explorer URL for the network\n   */\n  explorerUrl?: string;\n\n  /**\n   * Chain ID for the network\n   */\n  chainId: string;\n}\n"],"mappings":";AAsEO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,eAAY;AAhBF,SAAAA;AAAA,GAAA;AA+BL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,WAAQ;AACR,EAAAA,eAAA,aAAU;AACV,EAAAA,eAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AA2BL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,eAAY;AACZ,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;;;AC3HL,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBAAA,cAAW;AACX,EAAAA,mBAAA,YAAS;A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