@waku/rln 0.1.1-8928376 → 0.1.1-9b1e818
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/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
- package/bundle/index.js +206 -147
- package/dist/.tsbuildinfo +1 -1
- package/dist/byte_utils.d.ts +7 -0
- package/dist/byte_utils.js +13 -0
- package/dist/byte_utils.js.map +1 -1
- package/dist/codec.d.ts +5 -3
- package/dist/codec.js +8 -2
- package/dist/codec.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/keystore/keystore.d.ts +4 -3
- package/dist/keystore/keystore.js +16 -5
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +5 -5
- package/dist/message.d.ts +1 -1
- package/dist/message.js +1 -1
- package/dist/rln.js +2 -2
- package/dist/rln.js.map +1 -1
- package/dist/rln_contract.d.ts +15 -11
- package/dist/rln_contract.js +48 -31
- package/dist/rln_contract.js.map +1 -1
- package/package.json +6 -6
- package/src/byte_utils.ts +14 -0
- package/src/codec.ts +10 -2
- package/src/constants.ts +1 -1
- package/src/message.ts +1 -1
- package/src/rln.ts +2 -2
- package/src/rln_contract.ts +74 -41
- package/bundle/assets/rln_wasm_bg-6f96f821.wasm +0 -0
package/bundle/index.js
CHANGED
@@ -1871,6 +1871,18 @@ function fromString(string, encoding = 'utf8') {
|
|
1871
1871
|
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
1872
1872
|
}
|
1873
1873
|
|
1874
|
+
/**
|
1875
|
+
* Convert input to a byte array.
|
1876
|
+
*
|
1877
|
+
* Handles both `0x` prefixed and non-prefixed strings.
|
1878
|
+
*/
|
1879
|
+
function hexToBytes$2(hex) {
|
1880
|
+
if (typeof hex === "string") {
|
1881
|
+
const _hex = hex.replace(/^0x/i, "");
|
1882
|
+
return fromString(_hex.toLowerCase(), "base16");
|
1883
|
+
}
|
1884
|
+
return hex;
|
1885
|
+
}
|
1874
1886
|
/**
|
1875
1887
|
* Encode utf-8 string to byte array.
|
1876
1888
|
*/
|
@@ -1907,7 +1919,7 @@ class RlnMessage {
|
|
1907
1919
|
this.rlnInstance = rlnInstance;
|
1908
1920
|
this.msg = msg;
|
1909
1921
|
this.rateLimitProof = rateLimitProof;
|
1910
|
-
this.
|
1922
|
+
this.pubsubTopic = "";
|
1911
1923
|
}
|
1912
1924
|
verify(roots) {
|
1913
1925
|
return this.rateLimitProof
|
@@ -1973,6 +1985,9 @@ class RLNEncoder {
|
|
1973
1985
|
console.timeEnd("proof_gen_timer");
|
1974
1986
|
return proof;
|
1975
1987
|
}
|
1988
|
+
get pubsubTopic() {
|
1989
|
+
return this.encoder.pubsubTopic;
|
1990
|
+
}
|
1976
1991
|
get contentTopic() {
|
1977
1992
|
return this.encoder.contentTopic;
|
1978
1993
|
}
|
@@ -1985,6 +2000,9 @@ class RLNDecoder {
|
|
1985
2000
|
this.rlnInstance = rlnInstance;
|
1986
2001
|
this.decoder = decoder;
|
1987
2002
|
}
|
2003
|
+
get pubsubTopic() {
|
2004
|
+
return this.decoder.pubsubTopic;
|
2005
|
+
}
|
1988
2006
|
get contentTopic() {
|
1989
2007
|
return this.decoder.contentTopic;
|
1990
2008
|
}
|
@@ -1993,8 +2011,8 @@ class RLNDecoder {
|
|
1993
2011
|
log("Message decoded", protoMessage);
|
1994
2012
|
return Promise.resolve(protoMessage);
|
1995
2013
|
}
|
1996
|
-
async fromProtoObj(
|
1997
|
-
const msg = await this.decoder.fromProtoObj(
|
2014
|
+
async fromProtoObj(pubsubTopic, proto) {
|
2015
|
+
const msg = await this.decoder.fromProtoObj(pubsubTopic, proto);
|
1998
2016
|
if (!msg)
|
1999
2017
|
return;
|
2000
2018
|
return new RlnMessage(this.rlnInstance, msg, proto.rateLimitProof);
|
@@ -2064,7 +2082,7 @@ const RLN_STORAGE_ABI = [
|
|
2064
2082
|
];
|
2065
2083
|
const SEPOLIA_CONTRACT = {
|
2066
2084
|
chainId: 11155111,
|
2067
|
-
address: "
|
2085
|
+
address: "0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4",
|
2068
2086
|
abi: RLN_REGISTRY_ABI,
|
2069
2087
|
};
|
2070
2088
|
|
@@ -23904,6 +23922,19 @@ function buildBigIntFromUint8Array(array) {
|
|
23904
23922
|
const dataView = new DataView(array.buffer);
|
23905
23923
|
return dataView.getBigUint64(0, true);
|
23906
23924
|
}
|
23925
|
+
/**
|
23926
|
+
* Fills with zeros to set length
|
23927
|
+
* @param array little endian Uint8Array
|
23928
|
+
* @param length amount to pad
|
23929
|
+
* @returns little endian Uint8Array padded with zeros to set length
|
23930
|
+
*/
|
23931
|
+
function zeroPadLE(array, length) {
|
23932
|
+
const result = new Uint8Array(length);
|
23933
|
+
for (let i = 0; i < length; i++) {
|
23934
|
+
result[i] = array[i] || 0;
|
23935
|
+
}
|
23936
|
+
return result;
|
23937
|
+
}
|
23907
23938
|
|
23908
23939
|
const U32_MASK64 = BigInt(2 ** 32 - 1);
|
23909
23940
|
const _32n = BigInt(32);
|
@@ -24528,11 +24559,11 @@ class Keystore {
|
|
24528
24559
|
// TODO: add runtime validation of nwaku credentials
|
24529
24560
|
return {
|
24530
24561
|
identity: {
|
24531
|
-
IDCommitment: _.get(obj, "identityCredential.idCommitment"),
|
24532
|
-
IDTrapdoor: _.get(obj, "identityCredential.idTrapdoor"),
|
24533
|
-
IDNullifier: _.get(obj, "identityCredential.idNullifier"),
|
24534
|
-
IDCommitmentBigInt: buildBigIntFromUint8Array(
|
24535
|
-
IDSecretHash: _.get(obj, "identityCredential.idSecretHash"),
|
24562
|
+
IDCommitment: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", [])),
|
24563
|
+
IDTrapdoor: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idTrapdoor", [])),
|
24564
|
+
IDNullifier: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idNullifier", [])),
|
24565
|
+
IDCommitmentBigInt: buildBigIntFromUint8Array(Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", []))),
|
24566
|
+
IDSecretHash: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", [])),
|
24536
24567
|
},
|
24537
24568
|
membership: {
|
24538
24569
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -24546,6 +24577,17 @@ class Keystore {
|
|
24546
24577
|
return null;
|
24547
24578
|
}
|
24548
24579
|
}
|
24580
|
+
static fromArraylikeToBytes(obj) {
|
24581
|
+
const bytes = [];
|
24582
|
+
let index = 0;
|
24583
|
+
let lastElement = obj[index];
|
24584
|
+
while (lastElement !== undefined) {
|
24585
|
+
bytes.push(lastElement);
|
24586
|
+
index += 1;
|
24587
|
+
lastElement = obj[index];
|
24588
|
+
}
|
24589
|
+
return new Uint8Array(bytes);
|
24590
|
+
}
|
24549
24591
|
// follows nwaku implementation
|
24550
24592
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
|
24551
24593
|
static computeMembershipHash(info) {
|
@@ -24578,10 +24620,23 @@ heap.push(undefined, null, true, false);
|
|
24578
24620
|
|
24579
24621
|
function getObject(idx) { return heap[idx]; }
|
24580
24622
|
|
24581
|
-
|
24623
|
+
let heap_next = heap.length;
|
24624
|
+
|
24625
|
+
function dropObject(idx) {
|
24626
|
+
if (idx < 132) return;
|
24627
|
+
heap[idx] = heap_next;
|
24628
|
+
heap_next = idx;
|
24629
|
+
}
|
24582
24630
|
|
24583
|
-
|
24631
|
+
function takeObject(idx) {
|
24632
|
+
const ret = getObject(idx);
|
24633
|
+
dropObject(idx);
|
24634
|
+
return ret;
|
24635
|
+
}
|
24584
24636
|
|
24637
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
24638
|
+
|
24639
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
24585
24640
|
let cachedUint8Memory0 = null;
|
24586
24641
|
|
24587
24642
|
function getUint8Memory0() {
|
@@ -24592,11 +24647,10 @@ function getUint8Memory0() {
|
|
24592
24647
|
}
|
24593
24648
|
|
24594
24649
|
function getStringFromWasm0(ptr, len) {
|
24650
|
+
ptr = ptr >>> 0;
|
24595
24651
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
24596
24652
|
}
|
24597
24653
|
|
24598
|
-
let heap_next = heap.length;
|
24599
|
-
|
24600
24654
|
function addHeapObject(obj) {
|
24601
24655
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
24602
24656
|
const idx = heap_next;
|
@@ -24606,21 +24660,9 @@ function addHeapObject(obj) {
|
|
24606
24660
|
return idx;
|
24607
24661
|
}
|
24608
24662
|
|
24609
|
-
function dropObject(idx) {
|
24610
|
-
if (idx < 132) return;
|
24611
|
-
heap[idx] = heap_next;
|
24612
|
-
heap_next = idx;
|
24613
|
-
}
|
24614
|
-
|
24615
|
-
function takeObject(idx) {
|
24616
|
-
const ret = getObject(idx);
|
24617
|
-
dropObject(idx);
|
24618
|
-
return ret;
|
24619
|
-
}
|
24620
|
-
|
24621
24663
|
let WASM_VECTOR_LEN = 0;
|
24622
24664
|
|
24623
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
24665
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
24624
24666
|
|
24625
24667
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
24626
24668
|
? function (arg, view) {
|
@@ -24639,14 +24681,14 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24639
24681
|
|
24640
24682
|
if (realloc === undefined) {
|
24641
24683
|
const buf = cachedTextEncoder.encode(arg);
|
24642
|
-
const ptr = malloc(buf.length);
|
24684
|
+
const ptr = malloc(buf.length) >>> 0;
|
24643
24685
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
24644
24686
|
WASM_VECTOR_LEN = buf.length;
|
24645
24687
|
return ptr;
|
24646
24688
|
}
|
24647
24689
|
|
24648
24690
|
let len = arg.length;
|
24649
|
-
let ptr = malloc(len);
|
24691
|
+
let ptr = malloc(len) >>> 0;
|
24650
24692
|
|
24651
24693
|
const mem = getUint8Memory0();
|
24652
24694
|
|
@@ -24662,7 +24704,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24662
24704
|
if (offset !== 0) {
|
24663
24705
|
arg = arg.slice(offset);
|
24664
24706
|
}
|
24665
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
24707
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
24666
24708
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
24667
24709
|
const ret = encodeString(arg, view);
|
24668
24710
|
|
@@ -24885,7 +24927,7 @@ function getUint32Memory0() {
|
|
24885
24927
|
}
|
24886
24928
|
|
24887
24929
|
function passArrayJsValueToWasm0(array, malloc) {
|
24888
|
-
const ptr = malloc(array.length * 4);
|
24930
|
+
const ptr = malloc(array.length * 4) >>> 0;
|
24889
24931
|
const mem = getUint32Memory0();
|
24890
24932
|
for (let i = 0; i < array.length; i++) {
|
24891
24933
|
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
@@ -25069,11 +25111,7 @@ function handleError(f, args) {
|
|
25069
25111
|
}
|
25070
25112
|
}
|
25071
25113
|
|
25072
|
-
function
|
25073
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
25074
|
-
}
|
25075
|
-
|
25076
|
-
async function load(module, imports) {
|
25114
|
+
async function __wbg_load(module, imports) {
|
25077
25115
|
if (typeof Response === 'function' && module instanceof Response) {
|
25078
25116
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
25079
25117
|
try {
|
@@ -25104,17 +25142,9 @@ async function load(module, imports) {
|
|
25104
25142
|
}
|
25105
25143
|
}
|
25106
25144
|
|
25107
|
-
function
|
25145
|
+
function __wbg_get_imports() {
|
25108
25146
|
const imports = {};
|
25109
25147
|
imports.wbg = {};
|
25110
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
25111
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
25112
|
-
return ret;
|
25113
|
-
};
|
25114
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
25115
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
25116
|
-
return addHeapObject(ret);
|
25117
|
-
};
|
25118
25148
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
25119
25149
|
takeObject(arg0);
|
25120
25150
|
};
|
@@ -25125,33 +25155,46 @@ function getImports() {
|
|
25125
25155
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
25126
25156
|
const obj = getObject(arg1);
|
25127
25157
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
25128
|
-
var
|
25129
|
-
var
|
25130
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25131
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25158
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25159
|
+
var len1 = WASM_VECTOR_LEN;
|
25160
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25161
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25132
25162
|
};
|
25133
|
-
imports.wbg.
|
25134
|
-
const ret = arg0;
|
25135
|
-
return addHeapObject(ret);
|
25136
|
-
};
|
25137
|
-
imports.wbg.__wbindgen_number_new = function(arg0) {
|
25138
|
-
const ret = arg0;
|
25163
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
25164
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
25139
25165
|
return addHeapObject(ret);
|
25140
25166
|
};
|
25141
|
-
imports.wbg.
|
25142
|
-
const ret =
|
25143
|
-
return
|
25167
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
25168
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
25169
|
+
return ret;
|
25144
25170
|
};
|
25145
25171
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
25146
25172
|
const ret = getObject(arg0);
|
25147
25173
|
return addHeapObject(ret);
|
25148
25174
|
};
|
25175
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
25176
|
+
const val = getObject(arg0);
|
25177
|
+
const ret = typeof(val) === 'object' && val !== null;
|
25178
|
+
return ret;
|
25179
|
+
};
|
25149
25180
|
imports.wbg.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {
|
25150
25181
|
const ret = String(getObject(arg1));
|
25151
|
-
const
|
25152
|
-
const
|
25153
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25154
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25182
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25183
|
+
const len1 = WASM_VECTOR_LEN;
|
25184
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25185
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25186
|
+
};
|
25187
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
25188
|
+
const ret = arg0;
|
25189
|
+
return addHeapObject(ret);
|
25190
|
+
};
|
25191
|
+
imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
|
25192
|
+
const ret = arg0;
|
25193
|
+
return addHeapObject(ret);
|
25194
|
+
};
|
25195
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
25196
|
+
const ret = BigInt.asUintN(64, arg0);
|
25197
|
+
return addHeapObject(ret);
|
25155
25198
|
};
|
25156
25199
|
imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
|
25157
25200
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
@@ -25162,54 +25205,47 @@ function getImports() {
|
|
25162
25205
|
};
|
25163
25206
|
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
25164
25207
|
const ret = getObject(arg1).stack;
|
25165
|
-
const
|
25166
|
-
const
|
25167
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25168
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25208
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25209
|
+
const len1 = WASM_VECTOR_LEN;
|
25210
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25211
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25169
25212
|
};
|
25170
25213
|
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
25214
|
+
let deferred0_0;
|
25215
|
+
let deferred0_1;
|
25171
25216
|
try {
|
25217
|
+
deferred0_0 = arg0;
|
25218
|
+
deferred0_1 = arg1;
|
25172
25219
|
console.error(getStringFromWasm0(arg0, arg1));
|
25173
25220
|
} finally {
|
25174
|
-
wasm.__wbindgen_free(
|
25221
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1);
|
25175
25222
|
}
|
25176
25223
|
};
|
25177
25224
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
25178
25225
|
const ret = getObject(arg0) === undefined;
|
25179
25226
|
return ret;
|
25180
25227
|
};
|
25181
|
-
imports.wbg.
|
25182
|
-
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
25183
|
-
}, arguments) };
|
25184
|
-
imports.wbg.__wbg_getRandomValues_805f1c3d65988a5a = function() { return handleError(function (arg0, arg1) {
|
25185
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
25186
|
-
}, arguments) };
|
25187
|
-
imports.wbg.__wbg_crypto_e1d53a1d73fb10b8 = function(arg0) {
|
25228
|
+
imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) {
|
25188
25229
|
const ret = getObject(arg0).crypto;
|
25189
25230
|
return addHeapObject(ret);
|
25190
25231
|
};
|
25191
|
-
imports.wbg.
|
25192
|
-
const val = getObject(arg0);
|
25193
|
-
const ret = typeof(val) === 'object' && val !== null;
|
25194
|
-
return ret;
|
25195
|
-
};
|
25196
|
-
imports.wbg.__wbg_process_038c26bf42b093f8 = function(arg0) {
|
25232
|
+
imports.wbg.__wbg_process_dd1577445152112e = function(arg0) {
|
25197
25233
|
const ret = getObject(arg0).process;
|
25198
25234
|
return addHeapObject(ret);
|
25199
25235
|
};
|
25200
|
-
imports.wbg.
|
25236
|
+
imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) {
|
25201
25237
|
const ret = getObject(arg0).versions;
|
25202
25238
|
return addHeapObject(ret);
|
25203
25239
|
};
|
25204
|
-
imports.wbg.
|
25240
|
+
imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) {
|
25205
25241
|
const ret = getObject(arg0).node;
|
25206
25242
|
return addHeapObject(ret);
|
25207
25243
|
};
|
25208
|
-
imports.wbg.
|
25244
|
+
imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) {
|
25209
25245
|
const ret = getObject(arg0).msCrypto;
|
25210
25246
|
return addHeapObject(ret);
|
25211
25247
|
};
|
25212
|
-
imports.wbg.
|
25248
|
+
imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () {
|
25213
25249
|
const ret = module.require;
|
25214
25250
|
return addHeapObject(ret);
|
25215
25251
|
}, arguments) };
|
@@ -25217,94 +25253,100 @@ function getImports() {
|
|
25217
25253
|
const ret = typeof(getObject(arg0)) === 'function';
|
25218
25254
|
return ret;
|
25219
25255
|
};
|
25220
|
-
imports.wbg.
|
25256
|
+
imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) {
|
25257
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
25258
|
+
}, arguments) };
|
25259
|
+
imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) {
|
25260
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
25261
|
+
}, arguments) };
|
25262
|
+
imports.wbg.__wbg_new_18bc2084e9a3e1ff = function() {
|
25221
25263
|
const ret = new Array();
|
25222
25264
|
return addHeapObject(ret);
|
25223
25265
|
};
|
25224
|
-
imports.wbg.
|
25266
|
+
imports.wbg.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
|
25225
25267
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
25226
25268
|
return addHeapObject(ret);
|
25227
25269
|
};
|
25228
|
-
imports.wbg.
|
25270
|
+
imports.wbg.__wbg_new_b6fd0149e79ffce8 = function() {
|
25229
25271
|
const ret = new Map();
|
25230
25272
|
return addHeapObject(ret);
|
25231
25273
|
};
|
25232
|
-
imports.wbg.
|
25274
|
+
imports.wbg.__wbg_call_f96b398515635514 = function() { return handleError(function (arg0, arg1) {
|
25233
25275
|
const ret = getObject(arg0).call(getObject(arg1));
|
25234
25276
|
return addHeapObject(ret);
|
25235
25277
|
}, arguments) };
|
25236
|
-
imports.wbg.
|
25278
|
+
imports.wbg.__wbg_new_7befa02319b36069 = function() {
|
25237
25279
|
const ret = new Object();
|
25238
25280
|
return addHeapObject(ret);
|
25239
25281
|
};
|
25240
|
-
imports.wbg.
|
25282
|
+
imports.wbg.__wbg_self_b9aad7f1c618bfaf = function() { return handleError(function () {
|
25241
25283
|
const ret = self.self;
|
25242
25284
|
return addHeapObject(ret);
|
25243
25285
|
}, arguments) };
|
25244
|
-
imports.wbg.
|
25286
|
+
imports.wbg.__wbg_window_55e469842c98b086 = function() { return handleError(function () {
|
25245
25287
|
const ret = window.window;
|
25246
25288
|
return addHeapObject(ret);
|
25247
25289
|
}, arguments) };
|
25248
|
-
imports.wbg.
|
25290
|
+
imports.wbg.__wbg_globalThis_d0957e302752547e = function() { return handleError(function () {
|
25249
25291
|
const ret = globalThis.globalThis;
|
25250
25292
|
return addHeapObject(ret);
|
25251
25293
|
}, arguments) };
|
25252
|
-
imports.wbg.
|
25294
|
+
imports.wbg.__wbg_global_ae2f87312b8987fb = function() { return handleError(function () {
|
25253
25295
|
const ret = global.global;
|
25254
25296
|
return addHeapObject(ret);
|
25255
25297
|
}, arguments) };
|
25256
|
-
imports.wbg.
|
25298
|
+
imports.wbg.__wbg_set_aee8682c7ee9ac44 = function(arg0, arg1, arg2) {
|
25257
25299
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
25258
25300
|
};
|
25259
|
-
imports.wbg.
|
25301
|
+
imports.wbg.__wbg_toString_27ba0397f8cf84a6 = function() { return handleError(function (arg0, arg1) {
|
25260
25302
|
const ret = getObject(arg0).toString(arg1);
|
25261
25303
|
return addHeapObject(ret);
|
25262
25304
|
}, arguments) };
|
25263
|
-
imports.wbg.
|
25305
|
+
imports.wbg.__wbg_call_35782e9a1aa5e091 = function() { return handleError(function (arg0, arg1, arg2) {
|
25264
25306
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
25265
25307
|
return addHeapObject(ret);
|
25266
25308
|
}, arguments) };
|
25267
|
-
imports.wbg.
|
25309
|
+
imports.wbg.__wbg_set_6c1b2b7b73337778 = function(arg0, arg1, arg2) {
|
25268
25310
|
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
25269
25311
|
return addHeapObject(ret);
|
25270
25312
|
};
|
25271
|
-
imports.wbg.
|
25313
|
+
imports.wbg.__wbg_fromEntries_10a57760b5d7d9b8 = function() { return handleError(function (arg0) {
|
25272
25314
|
const ret = Object.fromEntries(getObject(arg0));
|
25273
25315
|
return addHeapObject(ret);
|
25274
25316
|
}, arguments) };
|
25275
|
-
imports.wbg.
|
25317
|
+
imports.wbg.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
|
25276
25318
|
const ret = getObject(arg0).buffer;
|
25277
25319
|
return addHeapObject(ret);
|
25278
25320
|
};
|
25279
|
-
imports.wbg.
|
25321
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_92c251989c485785 = function(arg0, arg1, arg2) {
|
25280
25322
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
25281
25323
|
return addHeapObject(ret);
|
25282
25324
|
};
|
25283
|
-
imports.wbg.
|
25325
|
+
imports.wbg.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
|
25284
25326
|
const ret = new Uint8Array(getObject(arg0));
|
25285
25327
|
return addHeapObject(ret);
|
25286
25328
|
};
|
25287
|
-
imports.wbg.
|
25329
|
+
imports.wbg.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
|
25288
25330
|
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
25289
25331
|
};
|
25290
|
-
imports.wbg.
|
25332
|
+
imports.wbg.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
|
25291
25333
|
const ret = getObject(arg0).length;
|
25292
25334
|
return ret;
|
25293
25335
|
};
|
25294
|
-
imports.wbg.
|
25336
|
+
imports.wbg.__wbg_newwithlength_89eca18f2603a999 = function(arg0) {
|
25295
25337
|
const ret = new Uint8Array(arg0 >>> 0);
|
25296
25338
|
return addHeapObject(ret);
|
25297
25339
|
};
|
25298
|
-
imports.wbg.
|
25340
|
+
imports.wbg.__wbg_subarray_7649d027b2b141b3 = function(arg0, arg1, arg2) {
|
25299
25341
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
25300
25342
|
return addHeapObject(ret);
|
25301
25343
|
};
|
25302
25344
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
25303
25345
|
const ret = debugString(getObject(arg1));
|
25304
|
-
const
|
25305
|
-
const
|
25306
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25307
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25346
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25347
|
+
const len1 = WASM_VECTOR_LEN;
|
25348
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25349
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25308
25350
|
};
|
25309
25351
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
25310
25352
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
@@ -25317,9 +25359,9 @@ function getImports() {
|
|
25317
25359
|
return imports;
|
25318
25360
|
}
|
25319
25361
|
|
25320
|
-
function
|
25362
|
+
function __wbg_finalize_init(instance, module) {
|
25321
25363
|
wasm = instance.exports;
|
25322
|
-
|
25364
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
25323
25365
|
cachedInt32Memory0 = null;
|
25324
25366
|
cachedUint32Memory0 = null;
|
25325
25367
|
cachedUint8Memory0 = null;
|
@@ -25328,19 +25370,21 @@ function finalizeInit(instance, module) {
|
|
25328
25370
|
return wasm;
|
25329
25371
|
}
|
25330
25372
|
|
25331
|
-
async function
|
25373
|
+
async function __wbg_init(input) {
|
25374
|
+
if (wasm !== undefined) return wasm;
|
25375
|
+
|
25332
25376
|
if (typeof input === 'undefined') {
|
25333
|
-
input = new URL(new URL('assets/rln_wasm_bg-
|
25377
|
+
input = new URL(new URL('assets/rln_wasm_bg-a503e304.wasm', import.meta.url).href, import.meta.url);
|
25334
25378
|
}
|
25335
|
-
const imports =
|
25379
|
+
const imports = __wbg_get_imports();
|
25336
25380
|
|
25337
25381
|
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
25338
25382
|
input = fetch(input);
|
25339
25383
|
}
|
25340
25384
|
|
25341
|
-
const { instance, module } = await
|
25385
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
25342
25386
|
|
25343
|
-
return
|
25387
|
+
return __wbg_finalize_init(instance, module);
|
25344
25388
|
}
|
25345
25389
|
|
25346
25390
|
const verificationKey = {
|
@@ -25779,7 +25823,7 @@ async function loadZkey() {
|
|
25779
25823
|
* @returns RLNInstance
|
25780
25824
|
*/
|
25781
25825
|
async function create$1() {
|
25782
|
-
await
|
25826
|
+
await __wbg_init?.();
|
25783
25827
|
init_panic_hook();
|
25784
25828
|
const witnessCalculator = await loadWitnessCalculator();
|
25785
25829
|
const zkey = await loadZkey();
|
@@ -49745,12 +49789,6 @@ class MerkleRootTracker {
|
|
49745
49789
|
}
|
49746
49790
|
|
49747
49791
|
class RLNContract {
|
49748
|
-
constructor(rlnInstance, { address, provider }) {
|
49749
|
-
this._members = [];
|
49750
|
-
const initialRoot = rlnInstance.getMerkleRoot();
|
49751
|
-
this.registryContract = new Contract(address, RLN_REGISTRY_ABI, provider);
|
49752
|
-
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
49753
|
-
}
|
49754
49792
|
static async init(rlnInstance, options) {
|
49755
49793
|
const rlnContract = new RLNContract(rlnInstance, options);
|
49756
49794
|
await rlnContract.initStorageContract(options.provider);
|
@@ -49758,22 +49796,34 @@ class RLNContract {
|
|
49758
49796
|
rlnContract.subscribeToMembers(rlnInstance);
|
49759
49797
|
return rlnContract;
|
49760
49798
|
}
|
49761
|
-
|
49762
|
-
|
49763
|
-
const
|
49764
|
-
this.
|
49765
|
-
this.
|
49799
|
+
constructor(rlnInstance, { registryAddress, provider }) {
|
49800
|
+
this._members = new Map();
|
49801
|
+
const initialRoot = rlnInstance.getMerkleRoot();
|
49802
|
+
this.registryContract = new Contract(registryAddress, RLN_REGISTRY_ABI, provider);
|
49803
|
+
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
49804
|
+
}
|
49805
|
+
async initStorageContract(provider, options = {}) {
|
49806
|
+
const storageIndex = options?.storageIndex
|
49807
|
+
? options.storageIndex
|
49808
|
+
: await this.registryContract.usingStorageIndex();
|
49809
|
+
const storageAddress = await this.registryContract.storages(storageIndex);
|
49810
|
+
if (!storageAddress || storageAddress === AddressZero) {
|
49811
|
+
throw Error("No RLN Storage initialized on registry contract.");
|
49812
|
+
}
|
49813
|
+
this.storageIndex = storageIndex;
|
49814
|
+
this.storageContract = new Contract(storageAddress, RLN_STORAGE_ABI, provider);
|
49766
49815
|
this._membersFilter = this.storageContract.filters.MemberRegistered();
|
49767
49816
|
this.deployBlock = await this.storageContract.deployedBlockNumber();
|
49768
49817
|
}
|
49769
49818
|
get contract() {
|
49770
49819
|
if (!this.storageContract) {
|
49771
|
-
throw Error("Storage contract was not initialized
|
49820
|
+
throw Error("Storage contract was not initialized");
|
49772
49821
|
}
|
49773
49822
|
return this.storageContract;
|
49774
49823
|
}
|
49775
49824
|
get members() {
|
49776
|
-
|
49825
|
+
const sortedMembers = Array.from(this._members.values()).sort((left, right) => left.index.toNumber() - right.index.toNumber());
|
49826
|
+
return sortedMembers;
|
49777
49827
|
}
|
49778
49828
|
get membersFilter() {
|
49779
49829
|
if (!this._membersFilter) {
|
@@ -49800,11 +49850,11 @@ class RLNContract {
|
|
49800
49850
|
const index = evt.args.index;
|
49801
49851
|
const toRemoveVal = toRemoveTable.get(evt.blockNumber);
|
49802
49852
|
if (toRemoveVal != undefined) {
|
49803
|
-
toRemoveVal.push(index);
|
49853
|
+
toRemoveVal.push(index.toNumber());
|
49804
49854
|
toRemoveTable.set(evt.blockNumber, toRemoveVal);
|
49805
49855
|
}
|
49806
49856
|
else {
|
49807
|
-
toRemoveTable.set(evt.blockNumber, [index]);
|
49857
|
+
toRemoveTable.set(evt.blockNumber, [index.toNumber()]);
|
49808
49858
|
}
|
49809
49859
|
}
|
49810
49860
|
else {
|
@@ -49815,21 +49865,24 @@ class RLNContract {
|
|
49815
49865
|
eventsPerBlock.push(evt);
|
49816
49866
|
toInsertTable.set(evt.blockNumber, eventsPerBlock);
|
49817
49867
|
}
|
49818
|
-
this.removeMembers(rlnInstance, toRemoveTable);
|
49819
|
-
this.insertMembers(rlnInstance, toInsertTable);
|
49820
49868
|
});
|
49869
|
+
this.removeMembers(rlnInstance, toRemoveTable);
|
49870
|
+
this.insertMembers(rlnInstance, toInsertTable);
|
49821
49871
|
}
|
49822
49872
|
insertMembers(rlnInstance, toInsert) {
|
49823
49873
|
toInsert.forEach((events, blockNumber) => {
|
49824
49874
|
events.forEach((evt) => {
|
49825
|
-
|
49875
|
+
const _idCommitment = evt?.args?.idCommitment;
|
49876
|
+
const index = evt?.args?.index;
|
49877
|
+
if (!_idCommitment || !index) {
|
49826
49878
|
return;
|
49827
49879
|
}
|
49828
|
-
const
|
49829
|
-
const index = evt.args.index;
|
49830
|
-
const idCommitment = zeroPad(arrayify(pubkey), 32);
|
49880
|
+
const idCommitment = zeroPadLE(hexToBytes$2(_idCommitment?._hex), 32);
|
49831
49881
|
rlnInstance.insertMember(idCommitment);
|
49832
|
-
this.
|
49882
|
+
this._members.set(index.toNumber(), {
|
49883
|
+
index,
|
49884
|
+
idCommitment: _idCommitment?._hex,
|
49885
|
+
});
|
49833
49886
|
});
|
49834
49887
|
const currentRoot = rlnInstance.getMerkleRoot();
|
49835
49888
|
this.merkleRootTracker.pushRoot(blockNumber, currentRoot);
|
@@ -49839,9 +49892,8 @@ class RLNContract {
|
|
49839
49892
|
const removeDescending = new Map([...toRemove].sort().reverse());
|
49840
49893
|
removeDescending.forEach((indexes, blockNumber) => {
|
49841
49894
|
indexes.forEach((index) => {
|
49842
|
-
|
49843
|
-
|
49844
|
-
this.members.splice(idx, 1);
|
49895
|
+
if (this._members.has(index)) {
|
49896
|
+
this._members.delete(index);
|
49845
49897
|
}
|
49846
49898
|
rlnInstance.deleteMember(index);
|
49847
49899
|
});
|
@@ -49849,21 +49901,28 @@ class RLNContract {
|
|
49849
49901
|
});
|
49850
49902
|
}
|
49851
49903
|
subscribeToMembers(rlnInstance) {
|
49852
|
-
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, event));
|
49904
|
+
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, [event]));
|
49853
49905
|
}
|
49854
49906
|
async registerWithSignature(rlnInstance, signature) {
|
49855
49907
|
const identityCredential = await rlnInstance.generateSeededIdentityCredential(signature);
|
49856
49908
|
return this.registerWithKey(identityCredential);
|
49857
49909
|
}
|
49858
49910
|
async registerWithKey(credential) {
|
49859
|
-
if (
|
49911
|
+
if (this.storageIndex === undefined) {
|
49860
49912
|
throw Error("Cannot register credential, no storage contract index found.");
|
49861
49913
|
}
|
49862
|
-
const txRegisterResponse = await this.registryContract
|
49863
|
-
gasLimit: 100000,
|
49864
|
-
});
|
49914
|
+
const txRegisterResponse = await this.registryContract["register(uint16,uint256)"](this.storageIndex, credential.IDCommitmentBigInt, { gasLimit: 100000 });
|
49865
49915
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
49866
|
-
|
49916
|
+
// assumption: register(uint16,uint256) emits one event
|
49917
|
+
const memberRegistered = txRegisterReceipt?.events?.[0];
|
49918
|
+
if (!memberRegistered) {
|
49919
|
+
return undefined;
|
49920
|
+
}
|
49921
|
+
const decodedData = this.contract.interface.decodeEventLog("MemberRegistered", memberRegistered.data);
|
49922
|
+
return {
|
49923
|
+
idCommitment: decodedData.idCommitment,
|
49924
|
+
index: decodedData.index,
|
49925
|
+
};
|
49867
49926
|
}
|
49868
49927
|
roots() {
|
49869
49928
|
return this.merkleRootTracker.roots();
|