@waku/rln 0.1.1-5b9414a → 0.1.1-60a5070
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 +181 -147
- package/dist/.tsbuildinfo +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 +46 -31
- package/dist/rln_contract.js.map +1 -1
- package/package.json +6 -6
- 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 +73 -38
- package/bundle/assets/rln_wasm_bg-6f96f821.wasm +0 -0
Binary file
|
package/bundle/index.js
CHANGED
@@ -1907,7 +1907,7 @@ class RlnMessage {
|
|
1907
1907
|
this.rlnInstance = rlnInstance;
|
1908
1908
|
this.msg = msg;
|
1909
1909
|
this.rateLimitProof = rateLimitProof;
|
1910
|
-
this.
|
1910
|
+
this.pubsubTopic = "";
|
1911
1911
|
}
|
1912
1912
|
verify(roots) {
|
1913
1913
|
return this.rateLimitProof
|
@@ -1973,6 +1973,9 @@ class RLNEncoder {
|
|
1973
1973
|
console.timeEnd("proof_gen_timer");
|
1974
1974
|
return proof;
|
1975
1975
|
}
|
1976
|
+
get pubsubTopic() {
|
1977
|
+
return this.encoder.pubsubTopic;
|
1978
|
+
}
|
1976
1979
|
get contentTopic() {
|
1977
1980
|
return this.encoder.contentTopic;
|
1978
1981
|
}
|
@@ -1985,6 +1988,9 @@ class RLNDecoder {
|
|
1985
1988
|
this.rlnInstance = rlnInstance;
|
1986
1989
|
this.decoder = decoder;
|
1987
1990
|
}
|
1991
|
+
get pubsubTopic() {
|
1992
|
+
return this.decoder.pubsubTopic;
|
1993
|
+
}
|
1988
1994
|
get contentTopic() {
|
1989
1995
|
return this.decoder.contentTopic;
|
1990
1996
|
}
|
@@ -1993,8 +1999,8 @@ class RLNDecoder {
|
|
1993
1999
|
log("Message decoded", protoMessage);
|
1994
2000
|
return Promise.resolve(protoMessage);
|
1995
2001
|
}
|
1996
|
-
async fromProtoObj(
|
1997
|
-
const msg = await this.decoder.fromProtoObj(
|
2002
|
+
async fromProtoObj(pubsubTopic, proto) {
|
2003
|
+
const msg = await this.decoder.fromProtoObj(pubsubTopic, proto);
|
1998
2004
|
if (!msg)
|
1999
2005
|
return;
|
2000
2006
|
return new RlnMessage(this.rlnInstance, msg, proto.rateLimitProof);
|
@@ -2064,7 +2070,7 @@ const RLN_STORAGE_ABI = [
|
|
2064
2070
|
];
|
2065
2071
|
const SEPOLIA_CONTRACT = {
|
2066
2072
|
chainId: 11155111,
|
2067
|
-
address: "
|
2073
|
+
address: "0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4",
|
2068
2074
|
abi: RLN_REGISTRY_ABI,
|
2069
2075
|
};
|
2070
2076
|
|
@@ -24528,11 +24534,11 @@ class Keystore {
|
|
24528
24534
|
// TODO: add runtime validation of nwaku credentials
|
24529
24535
|
return {
|
24530
24536
|
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"),
|
24537
|
+
IDCommitment: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", [])),
|
24538
|
+
IDTrapdoor: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idTrapdoor", [])),
|
24539
|
+
IDNullifier: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idNullifier", [])),
|
24540
|
+
IDCommitmentBigInt: buildBigIntFromUint8Array(Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", []))),
|
24541
|
+
IDSecretHash: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", [])),
|
24536
24542
|
},
|
24537
24543
|
membership: {
|
24538
24544
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -24546,6 +24552,17 @@ class Keystore {
|
|
24546
24552
|
return null;
|
24547
24553
|
}
|
24548
24554
|
}
|
24555
|
+
static fromArraylikeToBytes(obj) {
|
24556
|
+
const bytes = [];
|
24557
|
+
let index = 0;
|
24558
|
+
let lastElement = obj[index];
|
24559
|
+
while (lastElement !== undefined) {
|
24560
|
+
bytes.push(lastElement);
|
24561
|
+
index += 1;
|
24562
|
+
lastElement = obj[index];
|
24563
|
+
}
|
24564
|
+
return new Uint8Array(bytes);
|
24565
|
+
}
|
24549
24566
|
// follows nwaku implementation
|
24550
24567
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
|
24551
24568
|
static computeMembershipHash(info) {
|
@@ -24578,10 +24595,23 @@ heap.push(undefined, null, true, false);
|
|
24578
24595
|
|
24579
24596
|
function getObject(idx) { return heap[idx]; }
|
24580
24597
|
|
24581
|
-
|
24598
|
+
let heap_next = heap.length;
|
24582
24599
|
|
24583
|
-
|
24600
|
+
function dropObject(idx) {
|
24601
|
+
if (idx < 132) return;
|
24602
|
+
heap[idx] = heap_next;
|
24603
|
+
heap_next = idx;
|
24604
|
+
}
|
24584
24605
|
|
24606
|
+
function takeObject(idx) {
|
24607
|
+
const ret = getObject(idx);
|
24608
|
+
dropObject(idx);
|
24609
|
+
return ret;
|
24610
|
+
}
|
24611
|
+
|
24612
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
24613
|
+
|
24614
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
|
24585
24615
|
let cachedUint8Memory0 = null;
|
24586
24616
|
|
24587
24617
|
function getUint8Memory0() {
|
@@ -24592,11 +24622,10 @@ function getUint8Memory0() {
|
|
24592
24622
|
}
|
24593
24623
|
|
24594
24624
|
function getStringFromWasm0(ptr, len) {
|
24625
|
+
ptr = ptr >>> 0;
|
24595
24626
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
24596
24627
|
}
|
24597
24628
|
|
24598
|
-
let heap_next = heap.length;
|
24599
|
-
|
24600
24629
|
function addHeapObject(obj) {
|
24601
24630
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
24602
24631
|
const idx = heap_next;
|
@@ -24606,21 +24635,9 @@ function addHeapObject(obj) {
|
|
24606
24635
|
return idx;
|
24607
24636
|
}
|
24608
24637
|
|
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
24638
|
let WASM_VECTOR_LEN = 0;
|
24622
24639
|
|
24623
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
24640
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
24624
24641
|
|
24625
24642
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
24626
24643
|
? function (arg, view) {
|
@@ -24639,14 +24656,14 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24639
24656
|
|
24640
24657
|
if (realloc === undefined) {
|
24641
24658
|
const buf = cachedTextEncoder.encode(arg);
|
24642
|
-
const ptr = malloc(buf.length);
|
24659
|
+
const ptr = malloc(buf.length) >>> 0;
|
24643
24660
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
24644
24661
|
WASM_VECTOR_LEN = buf.length;
|
24645
24662
|
return ptr;
|
24646
24663
|
}
|
24647
24664
|
|
24648
24665
|
let len = arg.length;
|
24649
|
-
let ptr = malloc(len);
|
24666
|
+
let ptr = malloc(len) >>> 0;
|
24650
24667
|
|
24651
24668
|
const mem = getUint8Memory0();
|
24652
24669
|
|
@@ -24662,7 +24679,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
24662
24679
|
if (offset !== 0) {
|
24663
24680
|
arg = arg.slice(offset);
|
24664
24681
|
}
|
24665
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
24682
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
24666
24683
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
24667
24684
|
const ret = encodeString(arg, view);
|
24668
24685
|
|
@@ -24885,7 +24902,7 @@ function getUint32Memory0() {
|
|
24885
24902
|
}
|
24886
24903
|
|
24887
24904
|
function passArrayJsValueToWasm0(array, malloc) {
|
24888
|
-
const ptr = malloc(array.length * 4);
|
24905
|
+
const ptr = malloc(array.length * 4) >>> 0;
|
24889
24906
|
const mem = getUint32Memory0();
|
24890
24907
|
for (let i = 0; i < array.length; i++) {
|
24891
24908
|
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
@@ -25069,11 +25086,7 @@ function handleError(f, args) {
|
|
25069
25086
|
}
|
25070
25087
|
}
|
25071
25088
|
|
25072
|
-
function
|
25073
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
25074
|
-
}
|
25075
|
-
|
25076
|
-
async function load(module, imports) {
|
25089
|
+
async function __wbg_load(module, imports) {
|
25077
25090
|
if (typeof Response === 'function' && module instanceof Response) {
|
25078
25091
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
25079
25092
|
try {
|
@@ -25104,17 +25117,9 @@ async function load(module, imports) {
|
|
25104
25117
|
}
|
25105
25118
|
}
|
25106
25119
|
|
25107
|
-
function
|
25120
|
+
function __wbg_get_imports() {
|
25108
25121
|
const imports = {};
|
25109
25122
|
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
25123
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
25119
25124
|
takeObject(arg0);
|
25120
25125
|
};
|
@@ -25125,33 +25130,46 @@ function getImports() {
|
|
25125
25130
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
25126
25131
|
const obj = getObject(arg1);
|
25127
25132
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
25128
|
-
var
|
25129
|
-
var
|
25130
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25131
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25132
|
-
};
|
25133
|
-
imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
|
25134
|
-
const ret = arg0;
|
25135
|
-
return addHeapObject(ret);
|
25133
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25134
|
+
var len1 = WASM_VECTOR_LEN;
|
25135
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25136
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25136
25137
|
};
|
25137
|
-
imports.wbg.
|
25138
|
-
const ret = arg0;
|
25138
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
25139
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
25139
25140
|
return addHeapObject(ret);
|
25140
25141
|
};
|
25141
|
-
imports.wbg.
|
25142
|
-
const ret =
|
25143
|
-
return
|
25142
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
25143
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
25144
|
+
return ret;
|
25144
25145
|
};
|
25145
25146
|
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
25146
25147
|
const ret = getObject(arg0);
|
25147
25148
|
return addHeapObject(ret);
|
25148
25149
|
};
|
25150
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
25151
|
+
const val = getObject(arg0);
|
25152
|
+
const ret = typeof(val) === 'object' && val !== null;
|
25153
|
+
return ret;
|
25154
|
+
};
|
25149
25155
|
imports.wbg.__wbg_String_91fba7ded13ba54c = function(arg0, arg1) {
|
25150
25156
|
const ret = String(getObject(arg1));
|
25151
|
-
const
|
25152
|
-
const
|
25153
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25154
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25157
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25158
|
+
const len1 = WASM_VECTOR_LEN;
|
25159
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25160
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25161
|
+
};
|
25162
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
25163
|
+
const ret = arg0;
|
25164
|
+
return addHeapObject(ret);
|
25165
|
+
};
|
25166
|
+
imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
|
25167
|
+
const ret = arg0;
|
25168
|
+
return addHeapObject(ret);
|
25169
|
+
};
|
25170
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
25171
|
+
const ret = BigInt.asUintN(64, arg0);
|
25172
|
+
return addHeapObject(ret);
|
25155
25173
|
};
|
25156
25174
|
imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
|
25157
25175
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
@@ -25162,54 +25180,47 @@ function getImports() {
|
|
25162
25180
|
};
|
25163
25181
|
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
25164
25182
|
const ret = getObject(arg1).stack;
|
25165
|
-
const
|
25166
|
-
const
|
25167
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25168
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25183
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25184
|
+
const len1 = WASM_VECTOR_LEN;
|
25185
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25186
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25169
25187
|
};
|
25170
25188
|
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
25189
|
+
let deferred0_0;
|
25190
|
+
let deferred0_1;
|
25171
25191
|
try {
|
25192
|
+
deferred0_0 = arg0;
|
25193
|
+
deferred0_1 = arg1;
|
25172
25194
|
console.error(getStringFromWasm0(arg0, arg1));
|
25173
25195
|
} finally {
|
25174
|
-
wasm.__wbindgen_free(
|
25196
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1);
|
25175
25197
|
}
|
25176
25198
|
};
|
25177
25199
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
25178
25200
|
const ret = getObject(arg0) === undefined;
|
25179
25201
|
return ret;
|
25180
25202
|
};
|
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) {
|
25203
|
+
imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) {
|
25188
25204
|
const ret = getObject(arg0).crypto;
|
25189
25205
|
return addHeapObject(ret);
|
25190
25206
|
};
|
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) {
|
25207
|
+
imports.wbg.__wbg_process_dd1577445152112e = function(arg0) {
|
25197
25208
|
const ret = getObject(arg0).process;
|
25198
25209
|
return addHeapObject(ret);
|
25199
25210
|
};
|
25200
|
-
imports.wbg.
|
25211
|
+
imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) {
|
25201
25212
|
const ret = getObject(arg0).versions;
|
25202
25213
|
return addHeapObject(ret);
|
25203
25214
|
};
|
25204
|
-
imports.wbg.
|
25215
|
+
imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) {
|
25205
25216
|
const ret = getObject(arg0).node;
|
25206
25217
|
return addHeapObject(ret);
|
25207
25218
|
};
|
25208
|
-
imports.wbg.
|
25219
|
+
imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) {
|
25209
25220
|
const ret = getObject(arg0).msCrypto;
|
25210
25221
|
return addHeapObject(ret);
|
25211
25222
|
};
|
25212
|
-
imports.wbg.
|
25223
|
+
imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () {
|
25213
25224
|
const ret = module.require;
|
25214
25225
|
return addHeapObject(ret);
|
25215
25226
|
}, arguments) };
|
@@ -25217,94 +25228,100 @@ function getImports() {
|
|
25217
25228
|
const ret = typeof(getObject(arg0)) === 'function';
|
25218
25229
|
return ret;
|
25219
25230
|
};
|
25220
|
-
imports.wbg.
|
25231
|
+
imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) {
|
25232
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
25233
|
+
}, arguments) };
|
25234
|
+
imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) {
|
25235
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
25236
|
+
}, arguments) };
|
25237
|
+
imports.wbg.__wbg_new_18bc2084e9a3e1ff = function() {
|
25221
25238
|
const ret = new Array();
|
25222
25239
|
return addHeapObject(ret);
|
25223
25240
|
};
|
25224
|
-
imports.wbg.
|
25241
|
+
imports.wbg.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
|
25225
25242
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
25226
25243
|
return addHeapObject(ret);
|
25227
25244
|
};
|
25228
|
-
imports.wbg.
|
25245
|
+
imports.wbg.__wbg_new_b6fd0149e79ffce8 = function() {
|
25229
25246
|
const ret = new Map();
|
25230
25247
|
return addHeapObject(ret);
|
25231
25248
|
};
|
25232
|
-
imports.wbg.
|
25249
|
+
imports.wbg.__wbg_call_f96b398515635514 = function() { return handleError(function (arg0, arg1) {
|
25233
25250
|
const ret = getObject(arg0).call(getObject(arg1));
|
25234
25251
|
return addHeapObject(ret);
|
25235
25252
|
}, arguments) };
|
25236
|
-
imports.wbg.
|
25253
|
+
imports.wbg.__wbg_new_7befa02319b36069 = function() {
|
25237
25254
|
const ret = new Object();
|
25238
25255
|
return addHeapObject(ret);
|
25239
25256
|
};
|
25240
|
-
imports.wbg.
|
25257
|
+
imports.wbg.__wbg_self_b9aad7f1c618bfaf = function() { return handleError(function () {
|
25241
25258
|
const ret = self.self;
|
25242
25259
|
return addHeapObject(ret);
|
25243
25260
|
}, arguments) };
|
25244
|
-
imports.wbg.
|
25261
|
+
imports.wbg.__wbg_window_55e469842c98b086 = function() { return handleError(function () {
|
25245
25262
|
const ret = window.window;
|
25246
25263
|
return addHeapObject(ret);
|
25247
25264
|
}, arguments) };
|
25248
|
-
imports.wbg.
|
25265
|
+
imports.wbg.__wbg_globalThis_d0957e302752547e = function() { return handleError(function () {
|
25249
25266
|
const ret = globalThis.globalThis;
|
25250
25267
|
return addHeapObject(ret);
|
25251
25268
|
}, arguments) };
|
25252
|
-
imports.wbg.
|
25269
|
+
imports.wbg.__wbg_global_ae2f87312b8987fb = function() { return handleError(function () {
|
25253
25270
|
const ret = global.global;
|
25254
25271
|
return addHeapObject(ret);
|
25255
25272
|
}, arguments) };
|
25256
|
-
imports.wbg.
|
25273
|
+
imports.wbg.__wbg_set_aee8682c7ee9ac44 = function(arg0, arg1, arg2) {
|
25257
25274
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
25258
25275
|
};
|
25259
|
-
imports.wbg.
|
25276
|
+
imports.wbg.__wbg_toString_27ba0397f8cf84a6 = function() { return handleError(function (arg0, arg1) {
|
25260
25277
|
const ret = getObject(arg0).toString(arg1);
|
25261
25278
|
return addHeapObject(ret);
|
25262
25279
|
}, arguments) };
|
25263
|
-
imports.wbg.
|
25280
|
+
imports.wbg.__wbg_call_35782e9a1aa5e091 = function() { return handleError(function (arg0, arg1, arg2) {
|
25264
25281
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
25265
25282
|
return addHeapObject(ret);
|
25266
25283
|
}, arguments) };
|
25267
|
-
imports.wbg.
|
25284
|
+
imports.wbg.__wbg_set_6c1b2b7b73337778 = function(arg0, arg1, arg2) {
|
25268
25285
|
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
25269
25286
|
return addHeapObject(ret);
|
25270
25287
|
};
|
25271
|
-
imports.wbg.
|
25288
|
+
imports.wbg.__wbg_fromEntries_10a57760b5d7d9b8 = function() { return handleError(function (arg0) {
|
25272
25289
|
const ret = Object.fromEntries(getObject(arg0));
|
25273
25290
|
return addHeapObject(ret);
|
25274
25291
|
}, arguments) };
|
25275
|
-
imports.wbg.
|
25292
|
+
imports.wbg.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
|
25276
25293
|
const ret = getObject(arg0).buffer;
|
25277
25294
|
return addHeapObject(ret);
|
25278
25295
|
};
|
25279
|
-
imports.wbg.
|
25296
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_92c251989c485785 = function(arg0, arg1, arg2) {
|
25280
25297
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
25281
25298
|
return addHeapObject(ret);
|
25282
25299
|
};
|
25283
|
-
imports.wbg.
|
25300
|
+
imports.wbg.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
|
25284
25301
|
const ret = new Uint8Array(getObject(arg0));
|
25285
25302
|
return addHeapObject(ret);
|
25286
25303
|
};
|
25287
|
-
imports.wbg.
|
25304
|
+
imports.wbg.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
|
25288
25305
|
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
25289
25306
|
};
|
25290
|
-
imports.wbg.
|
25307
|
+
imports.wbg.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
|
25291
25308
|
const ret = getObject(arg0).length;
|
25292
25309
|
return ret;
|
25293
25310
|
};
|
25294
|
-
imports.wbg.
|
25311
|
+
imports.wbg.__wbg_newwithlength_89eca18f2603a999 = function(arg0) {
|
25295
25312
|
const ret = new Uint8Array(arg0 >>> 0);
|
25296
25313
|
return addHeapObject(ret);
|
25297
25314
|
};
|
25298
|
-
imports.wbg.
|
25315
|
+
imports.wbg.__wbg_subarray_7649d027b2b141b3 = function(arg0, arg1, arg2) {
|
25299
25316
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
25300
25317
|
return addHeapObject(ret);
|
25301
25318
|
};
|
25302
25319
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
25303
25320
|
const ret = debugString(getObject(arg1));
|
25304
|
-
const
|
25305
|
-
const
|
25306
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
25307
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
25321
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
25322
|
+
const len1 = WASM_VECTOR_LEN;
|
25323
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
25324
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
25308
25325
|
};
|
25309
25326
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
25310
25327
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
@@ -25317,9 +25334,9 @@ function getImports() {
|
|
25317
25334
|
return imports;
|
25318
25335
|
}
|
25319
25336
|
|
25320
|
-
function
|
25337
|
+
function __wbg_finalize_init(instance, module) {
|
25321
25338
|
wasm = instance.exports;
|
25322
|
-
|
25339
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
25323
25340
|
cachedInt32Memory0 = null;
|
25324
25341
|
cachedUint32Memory0 = null;
|
25325
25342
|
cachedUint8Memory0 = null;
|
@@ -25328,19 +25345,21 @@ function finalizeInit(instance, module) {
|
|
25328
25345
|
return wasm;
|
25329
25346
|
}
|
25330
25347
|
|
25331
|
-
async function
|
25348
|
+
async function __wbg_init(input) {
|
25349
|
+
if (wasm !== undefined) return wasm;
|
25350
|
+
|
25332
25351
|
if (typeof input === 'undefined') {
|
25333
|
-
input = new URL(new URL('assets/rln_wasm_bg-
|
25352
|
+
input = new URL(new URL('assets/rln_wasm_bg-a503e304.wasm', import.meta.url).href, import.meta.url);
|
25334
25353
|
}
|
25335
|
-
const imports =
|
25354
|
+
const imports = __wbg_get_imports();
|
25336
25355
|
|
25337
25356
|
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
25338
25357
|
input = fetch(input);
|
25339
25358
|
}
|
25340
25359
|
|
25341
|
-
const { instance, module } = await
|
25360
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
25342
25361
|
|
25343
|
-
return
|
25362
|
+
return __wbg_finalize_init(instance, module);
|
25344
25363
|
}
|
25345
25364
|
|
25346
25365
|
const verificationKey = {
|
@@ -25779,7 +25798,7 @@ async function loadZkey() {
|
|
25779
25798
|
* @returns RLNInstance
|
25780
25799
|
*/
|
25781
25800
|
async function create$1() {
|
25782
|
-
await
|
25801
|
+
await __wbg_init?.();
|
25783
25802
|
init_panic_hook();
|
25784
25803
|
const witnessCalculator = await loadWitnessCalculator();
|
25785
25804
|
const zkey = await loadZkey();
|
@@ -49745,12 +49764,6 @@ class MerkleRootTracker {
|
|
49745
49764
|
}
|
49746
49765
|
|
49747
49766
|
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
49767
|
static async init(rlnInstance, options) {
|
49755
49768
|
const rlnContract = new RLNContract(rlnInstance, options);
|
49756
49769
|
await rlnContract.initStorageContract(options.provider);
|
@@ -49758,22 +49771,34 @@ class RLNContract {
|
|
49758
49771
|
rlnContract.subscribeToMembers(rlnInstance);
|
49759
49772
|
return rlnContract;
|
49760
49773
|
}
|
49761
|
-
|
49762
|
-
|
49763
|
-
const
|
49764
|
-
this.
|
49765
|
-
this.
|
49774
|
+
constructor(rlnInstance, { registryAddress, provider }) {
|
49775
|
+
this._members = new Map();
|
49776
|
+
const initialRoot = rlnInstance.getMerkleRoot();
|
49777
|
+
this.registryContract = new Contract(registryAddress, RLN_REGISTRY_ABI, provider);
|
49778
|
+
this.merkleRootTracker = new MerkleRootTracker(5, initialRoot);
|
49779
|
+
}
|
49780
|
+
async initStorageContract(provider, options = {}) {
|
49781
|
+
const storageIndex = options?.storageIndex
|
49782
|
+
? options.storageIndex
|
49783
|
+
: await this.registryContract.usingStorageIndex();
|
49784
|
+
const storageAddress = await this.registryContract.storages(storageIndex);
|
49785
|
+
if (!storageAddress || storageAddress === AddressZero) {
|
49786
|
+
throw Error("No RLN Storage initialized on registry contract.");
|
49787
|
+
}
|
49788
|
+
this.storageIndex = storageIndex;
|
49789
|
+
this.storageContract = new Contract(storageAddress, RLN_STORAGE_ABI, provider);
|
49766
49790
|
this._membersFilter = this.storageContract.filters.MemberRegistered();
|
49767
49791
|
this.deployBlock = await this.storageContract.deployedBlockNumber();
|
49768
49792
|
}
|
49769
49793
|
get contract() {
|
49770
49794
|
if (!this.storageContract) {
|
49771
|
-
throw Error("Storage contract was not initialized
|
49795
|
+
throw Error("Storage contract was not initialized");
|
49772
49796
|
}
|
49773
49797
|
return this.storageContract;
|
49774
49798
|
}
|
49775
49799
|
get members() {
|
49776
|
-
|
49800
|
+
const sortedMembers = Array.from(this._members.values()).sort((left, right) => left.index.toNumber() - right.index.toNumber());
|
49801
|
+
return sortedMembers;
|
49777
49802
|
}
|
49778
49803
|
get membersFilter() {
|
49779
49804
|
if (!this._membersFilter) {
|
@@ -49800,11 +49825,11 @@ class RLNContract {
|
|
49800
49825
|
const index = evt.args.index;
|
49801
49826
|
const toRemoveVal = toRemoveTable.get(evt.blockNumber);
|
49802
49827
|
if (toRemoveVal != undefined) {
|
49803
|
-
toRemoveVal.push(index);
|
49828
|
+
toRemoveVal.push(index.toNumber());
|
49804
49829
|
toRemoveTable.set(evt.blockNumber, toRemoveVal);
|
49805
49830
|
}
|
49806
49831
|
else {
|
49807
|
-
toRemoveTable.set(evt.blockNumber, [index]);
|
49832
|
+
toRemoveTable.set(evt.blockNumber, [index.toNumber()]);
|
49808
49833
|
}
|
49809
49834
|
}
|
49810
49835
|
else {
|
@@ -49815,21 +49840,24 @@ class RLNContract {
|
|
49815
49840
|
eventsPerBlock.push(evt);
|
49816
49841
|
toInsertTable.set(evt.blockNumber, eventsPerBlock);
|
49817
49842
|
}
|
49818
|
-
this.removeMembers(rlnInstance, toRemoveTable);
|
49819
|
-
this.insertMembers(rlnInstance, toInsertTable);
|
49820
49843
|
});
|
49844
|
+
this.removeMembers(rlnInstance, toRemoveTable);
|
49845
|
+
this.insertMembers(rlnInstance, toInsertTable);
|
49821
49846
|
}
|
49822
49847
|
insertMembers(rlnInstance, toInsert) {
|
49823
49848
|
toInsert.forEach((events, blockNumber) => {
|
49824
49849
|
events.forEach((evt) => {
|
49825
|
-
|
49850
|
+
const _idCommitment = evt?.args?.idCommitment;
|
49851
|
+
const index = evt?.args?.index;
|
49852
|
+
if (!_idCommitment || !index) {
|
49826
49853
|
return;
|
49827
49854
|
}
|
49828
|
-
const
|
49829
|
-
const index = evt.args.index;
|
49830
|
-
const idCommitment = zeroPad(arrayify(pubkey), 32);
|
49855
|
+
const idCommitment = zeroPad(arrayify(_idCommitment), 32);
|
49831
49856
|
rlnInstance.insertMember(idCommitment);
|
49832
|
-
this.
|
49857
|
+
this._members.set(index.toNumber(), {
|
49858
|
+
index,
|
49859
|
+
idCommitment: _idCommitment?._hex || hexlify(idCommitment),
|
49860
|
+
});
|
49833
49861
|
});
|
49834
49862
|
const currentRoot = rlnInstance.getMerkleRoot();
|
49835
49863
|
this.merkleRootTracker.pushRoot(blockNumber, currentRoot);
|
@@ -49839,9 +49867,8 @@ class RLNContract {
|
|
49839
49867
|
const removeDescending = new Map([...toRemove].sort().reverse());
|
49840
49868
|
removeDescending.forEach((indexes, blockNumber) => {
|
49841
49869
|
indexes.forEach((index) => {
|
49842
|
-
|
49843
|
-
|
49844
|
-
this.members.splice(idx, 1);
|
49870
|
+
if (this._members.has(index)) {
|
49871
|
+
this._members.delete(index);
|
49845
49872
|
}
|
49846
49873
|
rlnInstance.deleteMember(index);
|
49847
49874
|
});
|
@@ -49849,21 +49876,28 @@ class RLNContract {
|
|
49849
49876
|
});
|
49850
49877
|
}
|
49851
49878
|
subscribeToMembers(rlnInstance) {
|
49852
|
-
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, event));
|
49879
|
+
this.contract.on(this.membersFilter, (_pubkey, _index, event) => this.processEvents(rlnInstance, [event]));
|
49853
49880
|
}
|
49854
49881
|
async registerWithSignature(rlnInstance, signature) {
|
49855
49882
|
const identityCredential = await rlnInstance.generateSeededIdentityCredential(signature);
|
49856
49883
|
return this.registerWithKey(identityCredential);
|
49857
49884
|
}
|
49858
49885
|
async registerWithKey(credential) {
|
49859
|
-
if (
|
49886
|
+
if (this.storageIndex === undefined) {
|
49860
49887
|
throw Error("Cannot register credential, no storage contract index found.");
|
49861
49888
|
}
|
49862
|
-
const txRegisterResponse = await this.registryContract
|
49863
|
-
gasLimit: 100000,
|
49864
|
-
});
|
49889
|
+
const txRegisterResponse = await this.registryContract["register(uint16,uint256)"](this.storageIndex, credential.IDCommitmentBigInt, { gasLimit: 100000 });
|
49865
49890
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
49866
|
-
|
49891
|
+
// assumption: register(uint16,uint256) emits one event
|
49892
|
+
const memberRegistered = txRegisterReceipt?.events?.[0];
|
49893
|
+
if (!memberRegistered) {
|
49894
|
+
return undefined;
|
49895
|
+
}
|
49896
|
+
const decodedData = this.contract.interface.decodeEventLog("MemberRegistered", memberRegistered.data);
|
49897
|
+
return {
|
49898
|
+
idCommitment: decodedData.idCommitment,
|
49899
|
+
index: decodedData.index,
|
49900
|
+
};
|
49867
49901
|
}
|
49868
49902
|
roots() {
|
49869
49903
|
return this.merkleRootTracker.roots();
|