@zelana/sdk 0.1.1 → 0.1.2

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/dist/index.d.ts CHANGED
@@ -47,4 +47,6 @@ export { ZelanaError } from './types';
47
47
  export { shielded, ShieldedTransactionBuilder, generateShieldedKeys, shieldedKeysFromSpendingKey, createNote, noteWithRandomness, computeCommitment, computeNullifier, tryDecryptNote, } from './shielded';
48
48
  export type { Note, EncryptedNote, ShieldedKeys, ShieldedInput, ShieldedOutput, PreparedShieldedTx, ShieldedTransaction, ShieldedWitness, ScanResult, MerklePath as ShieldedMerklePath, } from './shielded';
49
49
  export { bytesToHex, hexToBytes, bytesToBase58, base58ToBytes, u64ToLeBytes, leBytesToU64, concatBytes, bytesEqual, randomBytes, } from './utils';
50
+ export { OwnershipProver, MockOwnershipProver, mockProver, getProver, computeOwnershipWitness, } from './prover';
51
+ export type { OwnershipWitness, OwnershipProof, DelegatedShieldedRequest, } from './prover';
50
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,YAAY,EAEV,OAAO,EACP,YAAY,EAGZ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EAGZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gB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,EAEV,OAAO,EACP,YAAY,EAGZ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EAGZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAGhB,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EAGX,UAAU,EACV,WAAW,EAGX,iBAAiB,EAGjB,mBAAmB,EACnB,aAAa,EAGb,gBAAgB,EAChB,iBAAiB,EAGjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EAGf,QAAQ,GACT,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,UAAU,IAAI,kBAAkB,GACjC,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,wBAAwB,GACzB,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,27 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __toESM = (mod, isNodeMode, target) => {
7
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
8
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
+ for (let key of __getOwnPropNames(mod))
10
+ if (!__hasOwnProp.call(to, key))
11
+ __defProp(to, key, {
12
+ get: () => mod[key],
13
+ enumerable: true
14
+ });
15
+ return to;
16
+ };
17
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
18
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
19
+ }) : x)(function(x) {
20
+ if (typeof require !== "undefined")
21
+ return require.apply(this, arguments);
22
+ throw Error('Dynamic require of "' + x + '" is not supported');
23
+ });
24
+
1
25
  // node_modules/@noble/ed25519/index.js
2
26
  /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
3
27
  var ed25519_CURVE = {
@@ -1783,6 +1807,187 @@ var shielded = {
1783
1807
  computeNullifier,
1784
1808
  TransactionBuilder: ShieldedTransactionBuilder
1785
1809
  };
1810
+ // src/prover.ts
1811
+ class OwnershipProver {
1812
+ wasmModule = null;
1813
+ noirCircuit = null;
1814
+ backend = null;
1815
+ initialized = false;
1816
+ async init(options) {
1817
+ if (this.initialized) {
1818
+ return;
1819
+ }
1820
+ try {
1821
+ const wasmModule = await this.loadWasmModule(options?.wasmUrl);
1822
+ this.wasmModule = wasmModule;
1823
+ } catch (error) {
1824
+ throw new Error(`Failed to load ownership-prover WASM: ${error}`);
1825
+ }
1826
+ if (!options?.witnessOnly) {
1827
+ try {
1828
+ await this.loadNoirCircuit(options?.circuitUrl);
1829
+ } catch (error) {
1830
+ console.warn("Noir circuit not loaded, proof generation disabled:", error);
1831
+ }
1832
+ }
1833
+ this.initialized = true;
1834
+ }
1835
+ async loadWasmModule(wasmUrl) {
1836
+ try {
1837
+ const module = await import("zelana-ownership-prover");
1838
+ await module.default();
1839
+ return module;
1840
+ } catch {
1841
+ if (wasmUrl) {
1842
+ const importFn = new Function("url", "return import(url)");
1843
+ const module = await importFn(wasmUrl);
1844
+ await module.default();
1845
+ return module;
1846
+ }
1847
+ throw new Error("Could not load WASM module");
1848
+ }
1849
+ }
1850
+ async loadNoirCircuit(circuitUrl) {
1851
+ console.log("Noir circuit loading not yet implemented");
1852
+ this.noirCircuit = null;
1853
+ this.backend = null;
1854
+ }
1855
+ isInitialized() {
1856
+ return this.initialized;
1857
+ }
1858
+ canProve() {
1859
+ return this.initialized && this.noirCircuit !== null;
1860
+ }
1861
+ derivePublicKey(spendingKey) {
1862
+ this.ensureInitialized();
1863
+ const hex = this.wasmModule.derivePublicKey(bytesToHex2(spendingKey));
1864
+ return hexToBytes2(hex);
1865
+ }
1866
+ computeCommitment(ownerPk, value, blinding) {
1867
+ this.ensureInitialized();
1868
+ const hex = this.wasmModule.computeCommitment(bytesToHex2(ownerPk), value, bytesToHex2(blinding));
1869
+ return hexToBytes2(hex);
1870
+ }
1871
+ computeNullifier(spendingKey, commitment, position) {
1872
+ this.ensureInitialized();
1873
+ const hex = this.wasmModule.computeNullifier(bytesToHex2(spendingKey), bytesToHex2(commitment), position);
1874
+ return hexToBytes2(hex);
1875
+ }
1876
+ computeBlindedProxy(commitment, position) {
1877
+ this.ensureInitialized();
1878
+ const hex = this.wasmModule.computeBlindedProxy(bytesToHex2(commitment), position);
1879
+ return hexToBytes2(hex);
1880
+ }
1881
+ computeWitness(spendingKey, value, blinding, position) {
1882
+ this.ensureInitialized();
1883
+ return this.wasmModule.generateWitness(bytesToHex2(spendingKey), value, bytesToHex2(blinding), position);
1884
+ }
1885
+ verifyWitness(spendingKey, value, blinding, position, expectedCommitment, expectedNullifier, expectedProxy) {
1886
+ this.ensureInitialized();
1887
+ return this.wasmModule.verifyWitness(bytesToHex2(spendingKey), value, bytesToHex2(blinding), position, bytesToHex2(expectedCommitment), bytesToHex2(expectedNullifier), bytesToHex2(expectedProxy));
1888
+ }
1889
+ async prove(spendingKey, value, blinding, position) {
1890
+ this.ensureInitialized();
1891
+ if (!this.canProve()) {
1892
+ throw new Error("Noir circuit not loaded - proof generation unavailable");
1893
+ }
1894
+ const witness = this.computeWitness(spendingKey, value, blinding, position);
1895
+ throw new Error("Proof generation not yet implemented");
1896
+ }
1897
+ async verify(proof) {
1898
+ if (!this.canProve()) {
1899
+ throw new Error("Noir circuit not loaded - verification unavailable");
1900
+ }
1901
+ throw new Error("Proof verification not yet implemented");
1902
+ }
1903
+ ensureInitialized() {
1904
+ if (!this.initialized || !this.wasmModule) {
1905
+ throw new Error("Prover not initialized - call init() first");
1906
+ }
1907
+ }
1908
+ }
1909
+ var globalProver = null;
1910
+ async function getProver() {
1911
+ if (!globalProver) {
1912
+ globalProver = new OwnershipProver;
1913
+ await globalProver.init({ witnessOnly: true });
1914
+ }
1915
+ return globalProver;
1916
+ }
1917
+ async function computeOwnershipWitness(spendingKey, value, blinding, position) {
1918
+ const prover = await getProver();
1919
+ return prover.computeWitness(spendingKey, value, blinding, position);
1920
+ }
1921
+
1922
+ class MockOwnershipProver extends OwnershipProver {
1923
+ async init() {}
1924
+ isInitialized() {
1925
+ return true;
1926
+ }
1927
+ canProve() {
1928
+ return true;
1929
+ }
1930
+ derivePublicKey(spendingKey) {
1931
+ return this.mockHash("PK", spendingKey);
1932
+ }
1933
+ computeCommitment(ownerPk, value, blinding) {
1934
+ const valueBytes = new Uint8Array(8);
1935
+ new DataView(valueBytes.buffer).setBigUint64(0, value, true);
1936
+ return this.mockHash("CM", ownerPk, valueBytes, blinding);
1937
+ }
1938
+ computeNullifier(spendingKey, commitment, position) {
1939
+ const posBytes = new Uint8Array(8);
1940
+ new DataView(posBytes.buffer).setBigUint64(0, position, true);
1941
+ return this.mockHash("NF", spendingKey, commitment, posBytes);
1942
+ }
1943
+ computeBlindedProxy(commitment, position) {
1944
+ const posBytes = new Uint8Array(8);
1945
+ new DataView(posBytes.buffer).setBigUint64(0, position, true);
1946
+ return this.mockHash("BP", commitment, posBytes);
1947
+ }
1948
+ computeWitness(spendingKey, value, blinding, position) {
1949
+ const ownerPk = this.derivePublicKey(spendingKey);
1950
+ const commitment = this.computeCommitment(ownerPk, value, blinding);
1951
+ const nullifier = this.computeNullifier(spendingKey, commitment, position);
1952
+ const blindedProxy = this.computeBlindedProxy(commitment, position);
1953
+ return {
1954
+ ownerPk: bytesToHex2(ownerPk),
1955
+ commitment: bytesToHex2(commitment),
1956
+ nullifier: bytesToHex2(nullifier),
1957
+ blindedProxy: bytesToHex2(blindedProxy)
1958
+ };
1959
+ }
1960
+ async prove(spendingKey, value, blinding, position) {
1961
+ const witness = this.computeWitness(spendingKey, value, blinding, position);
1962
+ const fakeProof = this.mockHash("PROOF", hexToBytes2(witness.commitment), hexToBytes2(witness.nullifier));
1963
+ return {
1964
+ proof: fakeProof,
1965
+ publicInputs: {
1966
+ commitment: hexToBytes2(witness.commitment),
1967
+ nullifier: hexToBytes2(witness.nullifier),
1968
+ blindedProxy: hexToBytes2(witness.blindedProxy)
1969
+ }
1970
+ };
1971
+ }
1972
+ mockHash(domain, ...inputs) {
1973
+ const domainBytes = new TextEncoder().encode(domain);
1974
+ const combined = new Uint8Array(domainBytes.length + inputs.reduce((acc, i) => acc + i.length, 0));
1975
+ let offset = 0;
1976
+ combined.set(domainBytes, offset);
1977
+ offset += domainBytes.length;
1978
+ for (const input of inputs) {
1979
+ combined.set(input, offset);
1980
+ offset += input.length;
1981
+ }
1982
+ const result = new Uint8Array(32);
1983
+ for (let i = 0;i < combined.length; i++) {
1984
+ result[i % 32] ^= combined[i];
1985
+ result[(i + 1) % 32] ^= combined[i] << 4 | combined[i] >> 4;
1986
+ }
1987
+ return result;
1988
+ }
1989
+ }
1990
+ var mockProver = new MockOwnershipProver;
1786
1991
  export {
1787
1992
  u64ToLeBytes,
1788
1993
  tryDecryptNote,
@@ -1790,11 +1995,14 @@ export {
1790
1995
  shielded,
1791
1996
  randomBytes2 as randomBytes,
1792
1997
  noteWithRandomness,
1998
+ mockProver,
1793
1999
  leBytesToU64,
1794
2000
  hexToBytes2 as hexToBytes,
2001
+ getProver,
1795
2002
  generateShieldedKeys,
1796
2003
  createNote,
1797
2004
  concatBytes2 as concatBytes,
2005
+ computeOwnershipWitness,
1798
2006
  computeNullifier,
1799
2007
  computeCommitment,
1800
2008
  bytesToHex2 as bytesToHex,
@@ -1805,6 +2013,8 @@ export {
1805
2013
  ZelanaClient,
1806
2014
  ShieldedTransactionBuilder,
1807
2015
  PublicKey,
2016
+ OwnershipProver,
2017
+ MockOwnershipProver,
1808
2018
  Keypair,
1809
2019
  ApiClient
1810
2020
  };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Ownership Prover - Client-Side ZK Proof Generation
3
+ *
4
+ * This module provides the client-side proving functionality for Split Proving.
5
+ * Users generate lightweight ownership proofs in their browser, which are then
6
+ * verified by the sequencer and enhanced with Merkle proofs by the Swarm.
7
+ *
8
+ * Architecture:
9
+ * 1. User computes witness using WASM MiMC (matches Noir circuit exactly)
10
+ * 2. User generates ownership proof using Noir WASM prover (~500ms)
11
+ * 3. Proof is sent to sequencer for verification and batching
12
+ * 4. Swarm generates validity proof with Merkle membership (heavy work)
13
+ */
14
+ import type { Bytes32 } from './types';
15
+ /**
16
+ * Witness data computed from private inputs
17
+ */
18
+ export interface OwnershipWitness {
19
+ /** Owner's derived public key (32 bytes hex) */
20
+ ownerPk: string;
21
+ /** Note commitment (32 bytes hex) */
22
+ commitment: string;
23
+ /** Nullifier revealed when spending (32 bytes hex) */
24
+ nullifier: string;
25
+ /** Blinded proxy for swarm delegation (32 bytes hex) */
26
+ blindedProxy: string;
27
+ }
28
+ /**
29
+ * Complete ownership proof ready for submission
30
+ */
31
+ export interface OwnershipProof {
32
+ /** The ZK proof bytes */
33
+ proof: Uint8Array;
34
+ /** Public inputs to the circuit */
35
+ publicInputs: {
36
+ commitment: Bytes32;
37
+ nullifier: Bytes32;
38
+ blindedProxy: Bytes32;
39
+ };
40
+ }
41
+ /**
42
+ * Request to submit a delegated shielded transaction
43
+ */
44
+ export interface DelegatedShieldedRequest {
45
+ /** Ownership proof (serialized) */
46
+ ownershipProof: Uint8Array;
47
+ /** Nullifier being spent */
48
+ nullifier: Bytes32;
49
+ /** Input commitment */
50
+ commitment: Bytes32;
51
+ /** Blinded proxy for swarm lookup */
52
+ blindedProxy: Bytes32;
53
+ /** Output commitment for new note */
54
+ outputCommitment: Bytes32;
55
+ /** Encrypted note data */
56
+ ciphertext: Uint8Array;
57
+ /** Ephemeral key for decryption */
58
+ ephemeralKey: Bytes32;
59
+ }
60
+ /**
61
+ * OwnershipProver handles client-side ownership proof generation.
62
+ *
63
+ * This class:
64
+ * 1. Loads the WASM module for MiMC hash computation
65
+ * 2. Loads the Noir circuit for proof generation
66
+ * 3. Provides methods to compute witnesses and generate proofs
67
+ *
68
+ * Usage:
69
+ * ```typescript
70
+ * const prover = new OwnershipProver();
71
+ * await prover.init();
72
+ *
73
+ * // Compute witness from private inputs
74
+ * const witness = prover.computeWitness(spendingKey, value, blinding, position);
75
+ *
76
+ * // Generate proof
77
+ * const proof = await prover.prove(spendingKey, value, blinding, position);
78
+ * ```
79
+ */
80
+ export declare class OwnershipProver {
81
+ private wasmModule;
82
+ private noirCircuit;
83
+ private backend;
84
+ private initialized;
85
+ /**
86
+ * Initialize the prover
87
+ *
88
+ * This loads:
89
+ * 1. The ownership-prover WASM module (MiMC hash)
90
+ * 2. The Noir circuit definition
91
+ * 3. The Barretenberg backend for proving
92
+ *
93
+ * @param options Configuration options
94
+ */
95
+ init(options?: {
96
+ /** URL to fetch WASM from (defaults to CDN) */
97
+ wasmUrl?: string;
98
+ /** URL to fetch circuit JSON from (defaults to CDN) */
99
+ circuitUrl?: string;
100
+ /** Skip Noir initialization (for witness-only mode) */
101
+ witnessOnly?: boolean;
102
+ }): Promise<void>;
103
+ /**
104
+ * Load the WASM module
105
+ */
106
+ private loadWasmModule;
107
+ /**
108
+ * Load the Noir circuit and backend
109
+ */
110
+ private loadNoirCircuit;
111
+ /**
112
+ * Check if the prover is initialized
113
+ */
114
+ isInitialized(): boolean;
115
+ /**
116
+ * Check if proof generation is available
117
+ */
118
+ canProve(): boolean;
119
+ /**
120
+ * Derive public key from spending key
121
+ *
122
+ * pk = MiMC_hash3(PK_DOMAIN, spending_key, 0)
123
+ */
124
+ derivePublicKey(spendingKey: Bytes32): Bytes32;
125
+ /**
126
+ * Compute note commitment
127
+ *
128
+ * commitment = MiMC_hash3(owner_pk, value, blinding)
129
+ */
130
+ computeCommitment(ownerPk: Bytes32, value: bigint, blinding: Bytes32): Bytes32;
131
+ /**
132
+ * Compute nullifier
133
+ *
134
+ * nullifier = MiMC_hash4(NULLIFIER_DOMAIN, spending_key, commitment, position)
135
+ */
136
+ computeNullifier(spendingKey: Bytes32, commitment: Bytes32, position: bigint): Bytes32;
137
+ /**
138
+ * Compute blinded proxy for swarm delegation
139
+ *
140
+ * blinded_proxy = MiMC_hash3(DELEGATE_DOMAIN, commitment, position)
141
+ */
142
+ computeBlindedProxy(commitment: Bytes32, position: bigint): Bytes32;
143
+ /**
144
+ * Compute complete witness from private inputs
145
+ *
146
+ * This computes all public outputs that will be revealed to the sequencer.
147
+ */
148
+ computeWitness(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint): OwnershipWitness;
149
+ /**
150
+ * Verify that computed witness matches expected values
151
+ *
152
+ * Useful for debugging before generating a proof.
153
+ */
154
+ verifyWitness(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint, expectedCommitment: Bytes32, expectedNullifier: Bytes32, expectedProxy: Bytes32): boolean;
155
+ /**
156
+ * Generate an ownership proof
157
+ *
158
+ * This is the main entry point for proof generation. It:
159
+ * 1. Computes the witness using WASM MiMC
160
+ * 2. Generates the Noir proof using Barretenberg
161
+ *
162
+ * @param spendingKey The user's spending key (secret)
163
+ * @param value The note value in lamports
164
+ * @param blinding Random blinding factor
165
+ * @param position Position in the commitment tree
166
+ * @returns The proof and public inputs
167
+ */
168
+ prove(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint): Promise<OwnershipProof>;
169
+ /**
170
+ * Verify an ownership proof locally
171
+ *
172
+ * This is for debugging/testing. In production, the sequencer verifies proofs.
173
+ */
174
+ verify(proof: OwnershipProof): Promise<boolean>;
175
+ private ensureInitialized;
176
+ }
177
+ /**
178
+ * Get or create the global prover instance
179
+ */
180
+ export declare function getProver(): Promise<OwnershipProver>;
181
+ /**
182
+ * Compute witness using the global prover
183
+ */
184
+ export declare function computeOwnershipWitness(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint): Promise<OwnershipWitness>;
185
+ /**
186
+ * MockOwnershipProver provides a fake prover for development.
187
+ *
188
+ * It generates deterministic "proofs" using SHA-256 instead of real ZK proofs.
189
+ * This is useful for:
190
+ * - Development without WASM setup
191
+ * - Testing the API flow
192
+ * - Benchmarking non-proof overhead
193
+ *
194
+ * WARNING: This does NOT provide any cryptographic security!
195
+ */
196
+ export declare class MockOwnershipProver extends OwnershipProver {
197
+ init(): Promise<void>;
198
+ isInitialized(): boolean;
199
+ canProve(): boolean;
200
+ derivePublicKey(spendingKey: Bytes32): Bytes32;
201
+ computeCommitment(ownerPk: Bytes32, value: bigint, blinding: Bytes32): Bytes32;
202
+ computeNullifier(spendingKey: Bytes32, commitment: Bytes32, position: bigint): Bytes32;
203
+ computeBlindedProxy(commitment: Bytes32, position: bigint): Bytes32;
204
+ computeWitness(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint): OwnershipWitness;
205
+ prove(spendingKey: Bytes32, value: bigint, blinding: Bytes32, position: bigint): Promise<OwnershipProof>;
206
+ private mockHash;
207
+ }
208
+ export declare const mockProver: MockOwnershipProver;
209
+ //# sourceMappingURL=prover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prover.d.ts","sourceRoot":"","sources":["../src/prover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAA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AAO,CAAC,eAAe,CAAC,CAM1D;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,CAAC,CAG3B;AAMD;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IAChD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,IAAI,OAAO;IAIxB,QAAQ,IAAI,OAAO;IAInB,eAAe,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAK9C,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;IAO9E,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMtF,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMnE,cAAc,CACZ,WAAW,EAAE,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,GACf,gBAAgB;IAcb,KAAK,CACT,WAAW,EAAE,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAoB1B,OAAO,CAAC,QAAQ;CA0BjB;AAGD,eAAO,MAAM,UAAU,qBAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zelana/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for Zelana L2",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -44,4 +44,4 @@
44
44
  "type": "git",
45
45
  "url": "https://github.com/zelana/zelana"
46
46
  }
47
- }
47
+ }