moneysurfer 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/cli.js +583 -315
- package/package.json +9 -11
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,15 @@ function safePrefix(chainId) {
|
|
|
6
6
|
if (!prefix) throw new config_UsageError(`no Safe Transaction Service known for ${chainName(chainId)}`);
|
|
7
7
|
return prefix;
|
|
8
8
|
}
|
|
9
|
+
function parseChain(v) {
|
|
10
|
+
if (/^\d+$/.test(v)) return Number(v);
|
|
11
|
+
let hit = Object.entries(CHAINS).find(([, c])=>c.name.toLowerCase() === v.toLowerCase());
|
|
12
|
+
if (!hit) {
|
|
13
|
+
let names = Object.values(CHAINS).map((c)=>c.name.toLowerCase()).join(', ');
|
|
14
|
+
throw new config_UsageError(`unknown chain '${v}' -- ${names}, or a chain id`);
|
|
15
|
+
}
|
|
16
|
+
return Number(hit[0]);
|
|
17
|
+
}
|
|
9
18
|
function split(lst, le = !1) {
|
|
10
19
|
let len = lst.length, Ah = new Uint32Array(len), Al = new Uint32Array(len);
|
|
11
20
|
for(let i = 0; i < len; i++){
|
|
@@ -3610,6 +3619,37 @@ function solidityProof({ proof: p, publicSignals }) {
|
|
|
3610
3619
|
pubSignals: publicSignals
|
|
3611
3620
|
};
|
|
3612
3621
|
}
|
|
3622
|
+
function snarkjsProof({ proof: p }) {
|
|
3623
|
+
let s = String;
|
|
3624
|
+
return {
|
|
3625
|
+
protocol: 'groth16',
|
|
3626
|
+
curve: 'bn128',
|
|
3627
|
+
pi_a: [
|
|
3628
|
+
s(p.pi_a[0]),
|
|
3629
|
+
s(p.pi_a[1]),
|
|
3630
|
+
'1'
|
|
3631
|
+
],
|
|
3632
|
+
pi_b: [
|
|
3633
|
+
[
|
|
3634
|
+
s(p.pi_b[0][0]),
|
|
3635
|
+
s(p.pi_b[0][1])
|
|
3636
|
+
],
|
|
3637
|
+
[
|
|
3638
|
+
s(p.pi_b[1][0]),
|
|
3639
|
+
s(p.pi_b[1][1])
|
|
3640
|
+
],
|
|
3641
|
+
[
|
|
3642
|
+
'1',
|
|
3643
|
+
'0'
|
|
3644
|
+
]
|
|
3645
|
+
],
|
|
3646
|
+
pi_c: [
|
|
3647
|
+
s(p.pi_c[0]),
|
|
3648
|
+
s(p.pi_c[1]),
|
|
3649
|
+
'1'
|
|
3650
|
+
]
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3613
3653
|
async function connect(chainId) {
|
|
3614
3654
|
let net = rpc(function(chain) {
|
|
3615
3655
|
let override = rpcOverrideUrl();
|
|
@@ -3694,7 +3734,7 @@ async function init(o) {
|
|
|
3694
3734
|
await signer.signTyped(typed)
|
|
3695
3735
|
];
|
|
3696
3736
|
if (a !== b) throw Error('the wallet signed the same message differently twice; it cannot derive a stable seed');
|
|
3697
|
-
return saveMnemonic((address1 = signer.address, entropyToMnemonic(hkdf_hkdf(sha2_sha256, utils_hexToBytes(a.slice(2)).slice(0, 32), utils_hexToBytes(address1.toLowerCase().slice(2)), utils_utf8ToBytes(SEED_CONTEXT), 32), english_wordlist))), commands_log(`this is the account privacypools.com derives for ${signer.address}`);
|
|
3737
|
+
return saveMnemonic((address1 = signer.address, entropyToMnemonic(hkdf_hkdf(sha2_sha256, utils_hexToBytes(a.slice(2)).slice(0, 32), utils_hexToBytes(address1.toLowerCase().slice(2)), utils_utf8ToBytes(SEED_CONTEXT), 32), english_wordlist))), commands_log(`this is the account v1.privacypools.com derives for ${signer.address}`);
|
|
3698
3738
|
}
|
|
3699
3739
|
let words = generateMnemonic(english_wordlist, 256);
|
|
3700
3740
|
saveMnemonic(words), commands_out(words);
|
|
@@ -4003,37 +4043,7 @@ async function withdraw(key, amountArg, to, chainId, o) {
|
|
|
4003
4043
|
data: commands_hex(data)
|
|
4004
4044
|
},
|
|
4005
4045
|
publicSignals: proof.publicSignals.map(String),
|
|
4006
|
-
proof:
|
|
4007
|
-
let s = String;
|
|
4008
|
-
return {
|
|
4009
|
-
protocol: 'groth16',
|
|
4010
|
-
curve: 'bn128',
|
|
4011
|
-
pi_a: [
|
|
4012
|
-
s(p.pi_a[0]),
|
|
4013
|
-
s(p.pi_a[1]),
|
|
4014
|
-
'1'
|
|
4015
|
-
],
|
|
4016
|
-
pi_b: [
|
|
4017
|
-
[
|
|
4018
|
-
s(p.pi_b[0][0]),
|
|
4019
|
-
s(p.pi_b[0][1])
|
|
4020
|
-
],
|
|
4021
|
-
[
|
|
4022
|
-
s(p.pi_b[1][0]),
|
|
4023
|
-
s(p.pi_b[1][1])
|
|
4024
|
-
],
|
|
4025
|
-
[
|
|
4026
|
-
'1',
|
|
4027
|
-
'0'
|
|
4028
|
-
]
|
|
4029
|
-
],
|
|
4030
|
-
pi_c: [
|
|
4031
|
-
s(p.pi_c[0]),
|
|
4032
|
-
s(p.pi_c[1]),
|
|
4033
|
-
'1'
|
|
4034
|
-
]
|
|
4035
|
-
};
|
|
4036
|
-
}(proof),
|
|
4046
|
+
proof: snarkjsProof(proof),
|
|
4037
4047
|
scope: String(scope),
|
|
4038
4048
|
chainId
|
|
4039
4049
|
});
|
|
@@ -4102,15 +4112,7 @@ async function commands_ragequit(key, chainId, o) {
|
|
|
4102
4112
|
}
|
|
4103
4113
|
}
|
|
4104
4114
|
async function run(cmd, rest, v, c) {
|
|
4105
|
-
let chain = void 0 === v.chain ? void 0 :
|
|
4106
|
-
if (/^\d+$/.test(v)) return Number(v);
|
|
4107
|
-
let hit = Object.entries(CHAINS).find(([, c])=>c.name.toLowerCase() === v.toLowerCase());
|
|
4108
|
-
if (!hit) {
|
|
4109
|
-
let names = Object.values(CHAINS).map((c)=>c.name.toLowerCase()).join(', ');
|
|
4110
|
-
throw new config_UsageError(`unknown chain '${v}' -- ${names}, or a chain id`);
|
|
4111
|
-
}
|
|
4112
|
-
return Number(hit[0]);
|
|
4113
|
-
}(v.chain), commands = {
|
|
4115
|
+
let chain = void 0 === v.chain ? void 0 : parseChain(v.chain), commands = {
|
|
4114
4116
|
setup: ()=>setup(),
|
|
4115
4117
|
init: ()=>init({
|
|
4116
4118
|
import: v.import,
|
|
@@ -4227,7 +4229,7 @@ function noteScalar(rootSecret, what, a, b) {
|
|
|
4227
4229
|
let info = utils_utf8ToBytes(`${NOTE_INFO}${what}:${a}:${b}`);
|
|
4228
4230
|
return reduce(hkdf_hkdf(sha2_sha256, appSecretFrom(rootSecret), utils_utf8ToBytes(PP_V2), info, 48));
|
|
4229
4231
|
}
|
|
4230
|
-
function account_recover(keys, rootSecret, owner, tokenIds, ev) {
|
|
4232
|
+
function account_recover(keys, rootSecret, owner, tokenIds, ev, chainId) {
|
|
4231
4233
|
let ragequits = new Map(ev.ragequits.map((r)=>[
|
|
4232
4234
|
r.label,
|
|
4233
4235
|
r
|
|
@@ -4235,7 +4237,7 @@ function account_recover(keys, rootSecret, owner, tokenIds, ev) {
|
|
|
4235
4237
|
for (let tokenId of tokenIds){
|
|
4236
4238
|
let unused, mine = ev.deposits.filter((d)=>d.tokenId.toLowerCase() === tokenId.toLowerCase());
|
|
4237
4239
|
for(let i = 0n, misses = 0; misses < account_MISSES; i++){
|
|
4238
|
-
let { noteSecret, depositSecret } = crypto_depositSecrets(rootSecret, tokenId, i), ah = crypto_noteAddressHash(owner, noteSecret), d = mine.find((x)=>{
|
|
4240
|
+
let { noteSecret, depositSecret } = crypto_depositSecrets(rootSecret, tokenId, i, chainId), ah = crypto_noteAddressHash(owner, noteSecret), d = mine.find((x)=>{
|
|
4239
4241
|
let pre = v2_crypto_precommitment(ah, tokenId, x.value);
|
|
4240
4242
|
return crypto_commitment(pre, crypto_label(pre, depositSecret)) === x.commitment;
|
|
4241
4243
|
});
|
|
@@ -4245,9 +4247,9 @@ function account_recover(keys, rootSecret, owner, tokenIds, ev) {
|
|
|
4245
4247
|
}
|
|
4246
4248
|
misses = 0;
|
|
4247
4249
|
let label = crypto_label(v2_crypto_precommitment(ah, tokenId, d.value), depositSecret);
|
|
4248
|
-
accounts.push(function(keys, rootSecret, owner, tokenId, index, label, deposit, ev, ragequit) {
|
|
4250
|
+
accounts.push(function(keys, rootSecret, owner, tokenId, index, label, deposit, ev, ragequit, chainId) {
|
|
4249
4251
|
let lost, note = {
|
|
4250
|
-
noteSecret: crypto_depositSecrets(rootSecret, tokenId, index).noteSecret,
|
|
4252
|
+
noteSecret: crypto_depositSecrets(rootSecret, tokenId, index, chainId).noteSecret,
|
|
4251
4253
|
tokenId,
|
|
4252
4254
|
value: deposit.value,
|
|
4253
4255
|
label,
|
|
@@ -4289,7 +4291,7 @@ function account_recover(keys, rootSecret, owner, tokenIds, ev) {
|
|
|
4289
4291
|
lost
|
|
4290
4292
|
}
|
|
4291
4293
|
};
|
|
4292
|
-
}(keys, rootSecret, owner, tokenId, i, label, d, ev, ragequits.get(label)));
|
|
4294
|
+
}(keys, rootSecret, owner, tokenId, i, label, d, ev, ragequits.get(label), chainId));
|
|
4293
4295
|
}
|
|
4294
4296
|
nextIndex.set(tokenId.toLowerCase(), unused ?? 0n);
|
|
4295
4297
|
}
|
|
@@ -4302,52 +4304,33 @@ function transactCircuit(inputs, outputs) {
|
|
|
4302
4304
|
if (inputs < 1 || inputs > 5 || outputs < 1 || outputs > 5) throw new config_UsageError(`no transact circuit for ${inputs}x${outputs} -- both must be 1..5`);
|
|
4303
4305
|
return `transact_${inputs}x${outputs}`;
|
|
4304
4306
|
}
|
|
4305
|
-
function artifact(circuit) {
|
|
4306
|
-
let a = CIRCUITS[circuit];
|
|
4307
|
-
if (!a) throw new config_UsageError(`unknown circuit '${circuit}'`);
|
|
4308
|
-
return a;
|
|
4309
|
-
}
|
|
4310
4307
|
function pinned(circuit, kind) {
|
|
4311
|
-
let a =
|
|
4308
|
+
let a = function(circuit) {
|
|
4309
|
+
let a = CIRCUITS[circuit];
|
|
4310
|
+
if (!a) throw new config_UsageError(`unknown circuit '${circuit}'`);
|
|
4311
|
+
return a;
|
|
4312
|
+
}(circuit);
|
|
4312
4313
|
return 'wasm' === kind ? a.wasmSha256 : 'zkey' === kind ? a.provingKeySha256 : a.verificationKeySha256;
|
|
4313
4314
|
}
|
|
4314
4315
|
function artifacts_load(circuit, kind) {
|
|
4315
4316
|
let file = artifacts_path(circuit, kind);
|
|
4316
4317
|
if (!existsSync(file)) throw new config_UsageError(`${circuit}.${kind} is not downloaded -- run \`setup ${circuit}\``);
|
|
4317
4318
|
let bytes = new Uint8Array(readFileSync(file)), want = pinned(circuit, kind), got = utils_bytesToHex(sha2_sha256(bytes));
|
|
4318
|
-
if (got !== want) throw
|
|
4319
|
+
if (got !== want) throw new config_UsageError(`${file} has sha256 ${got}, not the pinned ${want} -- it is from an older set; run \`moneysurfer v2 setup ${circuit}\``);
|
|
4319
4320
|
return bytes;
|
|
4320
4321
|
}
|
|
4321
4322
|
async function fetchArtifact(circuit, kind) {
|
|
4322
|
-
let
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
bytes = new Uint8Array(await res.arrayBuffer());
|
|
4334
|
-
} catch (e) {
|
|
4335
|
-
failures.push(`${gateway}: ${e.message}`);
|
|
4336
|
-
continue;
|
|
4337
|
-
}
|
|
4338
|
-
let got = utils_bytesToHex(sha2_sha256(bytes));
|
|
4339
|
-
if (got !== want) {
|
|
4340
|
-
failures.push(`${gateway}: sha256 ${got}, want ${want}`);
|
|
4341
|
-
continue;
|
|
4342
|
-
}
|
|
4343
|
-
mkdirSync(config_ASSETS, {
|
|
4344
|
-
recursive: !0
|
|
4345
|
-
});
|
|
4346
|
-
let file = artifacts_path(circuit, kind);
|
|
4347
|
-
return writeFileSync(`${file}.tmp`, bytes), renameSync(`${file}.tmp`, file), bytes;
|
|
4348
|
-
}
|
|
4349
|
-
throw Error(`could not fetch ${circuit}.${kind} (${cid}):\n ${failures.join(`
|
|
4350
|
-
`)}`);
|
|
4323
|
+
let url = `${ARTIFACTS_URL}/${remote(circuit, kind)}`, want = pinned(circuit, kind), res = await fetch(url, {
|
|
4324
|
+
signal: AbortSignal.timeout(300000)
|
|
4325
|
+
});
|
|
4326
|
+
if (!res.ok) throw Error(`could not fetch ${circuit}.${kind}: ${url}: HTTP ${res.status}`);
|
|
4327
|
+
let bytes = new Uint8Array(await res.arrayBuffer()), got = utils_bytesToHex(sha2_sha256(bytes));
|
|
4328
|
+
if (got !== want) throw Error(`${url} has sha256 ${got}, not the pinned ${want} -- refused`);
|
|
4329
|
+
mkdirSync(config_ASSETS, {
|
|
4330
|
+
recursive: !0
|
|
4331
|
+
});
|
|
4332
|
+
let file = artifacts_path(circuit, kind);
|
|
4333
|
+
return writeFileSync(`${file}.tmp`, bytes), renameSync(`${file}.tmp`, file), bytes;
|
|
4351
4334
|
}
|
|
4352
4335
|
function artifacts_verificationKey(circuit) {
|
|
4353
4336
|
let j = JSON.parse(new TextDecoder().decode(artifacts_load(circuit, 'vkey'))), g1 = (p)=>p.map(BigInt);
|
|
@@ -4389,9 +4372,13 @@ async function chain_getLogs(net, address, topics, from, to, progress) {
|
|
|
4389
4372
|
}
|
|
4390
4373
|
return address.length > 1 && !batched ? out.sort((a, b)=>Number(a.blockNumber) - Number(b.blockNumber) || Number(a.logIndex) - Number(b.logIndex)) : out;
|
|
4391
4374
|
}
|
|
4375
|
+
function chain_writeCache(file, json) {
|
|
4376
|
+
mkdirSync(join(config_HOME, 'cache'), {
|
|
4377
|
+
recursive: !0
|
|
4378
|
+
}), writeFileSync(`${file}.tmp`, json), renameSync(`${file}.tmp`, file);
|
|
4379
|
+
}
|
|
4392
4380
|
async function sync(net, log) {
|
|
4393
|
-
|
|
4394
|
-
let file1, head = Number(await net.call('eth_blockNumber')), ev = existsSync(file1 = chain_cacheFile()) ? JSON.parse(readFileSync(file1, 'utf8'), revive) : chain_empty(), from = Math.max(DEPLOYED_BLOCK, ev.block - chain_REORG_BLOCKS + 1), keep = (xs)=>xs.filter((x)=>x.block < from);
|
|
4381
|
+
let file, head = Number(await net.call('eth_blockNumber')), ev = existsSync(file = chain_cacheFile()) ? JSON.parse(readFileSync(file, 'utf8'), revive) : chain_empty(), from = Math.max(deployment().deployedBlock, ev.block - chain_REORG_BLOCKS + 1), keep = (xs)=>xs.filter((x)=>x.block < from);
|
|
4395
4382
|
ev.deposits = keep(ev.deposits), ev.ragequits = keep(ev.ragequits), ev.transacts = keep(ev.transacts), ev.notes = keep(ev.notes);
|
|
4396
4383
|
let addresses = [
|
|
4397
4384
|
POOL_ADDR,
|
|
@@ -4445,9 +4432,7 @@ async function sync(net, log) {
|
|
|
4445
4432
|
].sort((a, b)=>a[0] - b[0]);
|
|
4446
4433
|
return ev.leaves = ordered(leaves), ev.keystoreLeaves = ordered(keystoreLeaves), ev.aspRoots = [
|
|
4447
4434
|
...aspRoots
|
|
4448
|
-
], ev.block = head,
|
|
4449
|
-
recursive: !0
|
|
4450
|
-
}), writeFileSync(`${file}.tmp`, json), renameSync(`${file}.tmp`, file), log?.(`${ev.deposits.length} deposits, ${ev.transacts.length} transacts, ${ev.ragequits.length} ragequits, ${ev.leaves.length} leaves, ${ev.keystoreLeaves.length} accounts`), ev;
|
|
4435
|
+
], ev.block = head, chain_writeCache(chain_cacheFile(), JSON.stringify(ev, replace)), log?.(`${ev.deposits.length} deposits, ${ev.transacts.length} transacts, ${ev.ragequits.length} ragequits, ${ev.leaves.length} leaves, ${ev.keystoreLeaves.length} accounts`), ev;
|
|
4451
4436
|
}
|
|
4452
4437
|
async function chain_stateTree(net, ev) {
|
|
4453
4438
|
return checked(net, POOL_ADDR, chain_POOL.isKnownRoot, ev.leaves, 'state');
|
|
@@ -4461,21 +4446,54 @@ async function checked(net, to, method, entries, what) {
|
|
|
4461
4446
|
if (!await rpc_read(net, to, method, tree.root)) throw Error(`the ${what} tree we built has root 0x${tree.root.toString(16)}, which the contract does not know`);
|
|
4462
4447
|
return tree;
|
|
4463
4448
|
}
|
|
4464
|
-
|
|
4465
|
-
let
|
|
4449
|
+
function chain_matching(leaves, root) {
|
|
4450
|
+
let tree = new crypto_LeanIMT(leaves);
|
|
4451
|
+
if (tree.root === root) return tree;
|
|
4452
|
+
let sorted = new crypto_LeanIMT([
|
|
4453
|
+
...leaves
|
|
4454
|
+
].sort((a, b)=>a < b ? -1 : +(a > b)));
|
|
4455
|
+
return sorted.root === root ? sorted : void 0;
|
|
4456
|
+
}
|
|
4457
|
+
async function chain_aspSet(net, log) {
|
|
4458
|
+
let [root, cid] = await Promise.all([
|
|
4459
|
+
rpc_read(net, ASP_REGISTRY, ASP.latestASPRoot, void 0),
|
|
4460
|
+
rpc_read(net, ASP_REGISTRY, ASP.latestIPFSCID, void 0)
|
|
4461
|
+
]), done = (tree, source)=>({
|
|
4462
|
+
root,
|
|
4463
|
+
tree,
|
|
4464
|
+
source
|
|
4465
|
+
}), file = chain_aspCache(root);
|
|
4466
|
+
if (existsSync(file)) {
|
|
4467
|
+
let tree = chain_matching(JSON.parse(readFileSync(file, 'utf8')).map(BigInt), root);
|
|
4468
|
+
if (tree) return done(tree, 'cache');
|
|
4469
|
+
}
|
|
4470
|
+
let save = (tree)=>chain_writeCache(file, JSON.stringify(tree.levels[0].map(String)));
|
|
4471
|
+
for (let gw of config_IPFS_GATEWAYS)try {
|
|
4472
|
+
let res = await fetch(`${gw}/ipfs/${cid}`, {
|
|
4473
|
+
signal: AbortSignal.timeout(60000)
|
|
4474
|
+
});
|
|
4475
|
+
if (!res.ok) continue;
|
|
4476
|
+
let levels = await res.json(), tree = chain_matching(levels[0].map(BigInt), root);
|
|
4477
|
+
if (!tree) {
|
|
4478
|
+
log?.(`${gw} served ${cid}, but it does not hash to the ASP root -- ignored`);
|
|
4479
|
+
continue;
|
|
4480
|
+
}
|
|
4481
|
+
return save(tree), done(tree, `IPFS ${cid} via ${gw}`);
|
|
4482
|
+
} catch {}
|
|
4483
|
+
log?.(`no IPFS gateway served ${cid}; asking the ASP's API instead (it sees your IP, not your notes)`);
|
|
4484
|
+
let url = `${aspApi()}/association-set/leaves?chainId=${config_chainId()}&entrypoint=${ENTRYPOINT_ADDR}`, res = await fetch(url, {
|
|
4466
4485
|
signal: AbortSignal.timeout(60000)
|
|
4467
4486
|
});
|
|
4468
4487
|
if (!res.ok) throw Error(`${url}: HTTP ${res.status}`);
|
|
4469
|
-
let { leaves } = await res.json(), tree =
|
|
4470
|
-
if (tree
|
|
4471
|
-
return
|
|
4472
|
-
root,
|
|
4473
|
-
tree,
|
|
4474
|
-
source: url
|
|
4475
|
-
};
|
|
4488
|
+
let { leaves } = await res.json(), tree = chain_matching(leaves.map(BigInt), root);
|
|
4489
|
+
if (!tree) throw Error(`the ASP's ${leaves.length} leaves do not hash to the root the registry published (0x${root.toString(16)}) -- the set is stale or is not this pool's`);
|
|
4490
|
+
return save(tree), done(tree, url);
|
|
4476
4491
|
}
|
|
4477
4492
|
async function tokenMeta(net, token) {
|
|
4478
|
-
if (isNative(token)) return
|
|
4493
|
+
if (isNative(token)) return {
|
|
4494
|
+
symbol: deployment().native,
|
|
4495
|
+
decimals: 18
|
|
4496
|
+
};
|
|
4479
4497
|
let [symbol, decimals] = await Promise.all([
|
|
4480
4498
|
rpc_read(net, token, v2_chain_ERC20.symbol),
|
|
4481
4499
|
rpc_read(net, token, v2_chain_ERC20.decimals)
|
|
@@ -4486,7 +4504,7 @@ async function tokenMeta(net, token) {
|
|
|
4486
4504
|
};
|
|
4487
4505
|
}
|
|
4488
4506
|
async function assets(net) {
|
|
4489
|
-
let found = await Promise.all(
|
|
4507
|
+
let found = await Promise.all(deployment().tokens.map(async (tokenId)=>{
|
|
4490
4508
|
let [meta, cfg] = await Promise.all([
|
|
4491
4509
|
tokenMeta(net, tokenId),
|
|
4492
4510
|
rpc_read(net, ENTRYPOINT_ADDR, chain_ENTRYPOINT.assets, tokenId)
|
|
@@ -4591,6 +4609,95 @@ async function buildDeposit(p) {
|
|
|
4591
4609
|
proof
|
|
4592
4610
|
};
|
|
4593
4611
|
}
|
|
4612
|
+
async function request(url, body) {
|
|
4613
|
+
let res = await fetch(url, {
|
|
4614
|
+
...void 0 !== body && {
|
|
4615
|
+
method: 'POST',
|
|
4616
|
+
headers: {
|
|
4617
|
+
'content-type': 'application/json'
|
|
4618
|
+
},
|
|
4619
|
+
body: JSON.stringify(body)
|
|
4620
|
+
},
|
|
4621
|
+
signal: AbortSignal.timeout(60000)
|
|
4622
|
+
}), text = await res.text(), json = {};
|
|
4623
|
+
try {
|
|
4624
|
+
json = JSON.parse(text);
|
|
4625
|
+
} catch {}
|
|
4626
|
+
if (!res.ok) {
|
|
4627
|
+
let why = json.message ?? json.error ?? text;
|
|
4628
|
+
throw Error(`HTTP ${res.status} ${('string' == typeof why ? why : JSON.stringify(why)).slice(0, 300)}`);
|
|
4629
|
+
}
|
|
4630
|
+
return json;
|
|
4631
|
+
}
|
|
4632
|
+
async function relayer_details(base) {
|
|
4633
|
+
let d = await request(`${base}/v1/details/${CHAIN_TYPE}/${config_chainId()}`);
|
|
4634
|
+
if (d.id !== config_chainId()) throw Error(`answered for chain ${d.id}`);
|
|
4635
|
+
if (!d.contracts?.relay || !d.relayerAddress) throw Error('its details name no relay contract');
|
|
4636
|
+
return {
|
|
4637
|
+
relay: d.contracts.relay,
|
|
4638
|
+
relayerAddress: d.relayerAddress,
|
|
4639
|
+
assets: new Set((d.assets ?? []).map((a)=>a.address.toLowerCase()))
|
|
4640
|
+
};
|
|
4641
|
+
}
|
|
4642
|
+
async function relayer_quote(base, asset, recipient, amount) {
|
|
4643
|
+
let q = await request(`${base}/v1/quote/${CHAIN_TYPE}/${config_chainId()}/receive`, {
|
|
4644
|
+
asset,
|
|
4645
|
+
commit: !0,
|
|
4646
|
+
recipient,
|
|
4647
|
+
extraGas: !1,
|
|
4648
|
+
amount: String(amount)
|
|
4649
|
+
}), c = q.feeCommitment, feeAmount = BigInt(q.feeAmount), data = utils_hexToBytes(c.data.replace(/^0x/, '')), routing = decodePayoutRouting(data), wrong = [
|
|
4650
|
+
q.processor?.toLowerCase() !== RELAY_ADDR.toLowerCase() && `it submits through ${q.processor}, not the PrivacyPoolRelay ${RELAY_ADDR}`,
|
|
4651
|
+
c.asset.toLowerCase() !== asset.toLowerCase() && `the fee is in ${c.asset}, not ${asset}`,
|
|
4652
|
+
routing.recipient.toLowerCase() !== recipient.toLowerCase() && `the routing pays ${routing.recipient}`,
|
|
4653
|
+
(routing.feeAmount !== feeAmount || BigInt(c.feeAmount) !== feeAmount) && `the routing takes ${routing.feeAmount} while the fee quoted is ${feeAmount}`,
|
|
4654
|
+
0n !== routing.nativeGas && `the routing asks for ${routing.nativeGas} of native gas`,
|
|
4655
|
+
BigInt(q.amountSent) !== amount + feeAmount && `amountSent ${q.amountSent} is not ${amount} + ${feeAmount}`
|
|
4656
|
+
].filter(Boolean);
|
|
4657
|
+
if (wrong.length) throw Error(`its quote is not what was asked for: ${wrong.join('; ')}`);
|
|
4658
|
+
return {
|
|
4659
|
+
amount,
|
|
4660
|
+
feeAmount,
|
|
4661
|
+
amountSent: amount + feeAmount,
|
|
4662
|
+
data,
|
|
4663
|
+
routing,
|
|
4664
|
+
expiration: Number(c.expiration),
|
|
4665
|
+
commitment: {
|
|
4666
|
+
...c,
|
|
4667
|
+
extraGas: !1
|
|
4668
|
+
}
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
async function quoteGross(base, asset, recipient, gross) {
|
|
4672
|
+
let q = await relayer_quote(base, asset, recipient, gross);
|
|
4673
|
+
for(let i = 0; i < 3; i++){
|
|
4674
|
+
let net = gross - q.feeAmount;
|
|
4675
|
+
if (net <= 0n) throw Error(`its fee of ${q.feeAmount} leaves nothing of ${gross}`);
|
|
4676
|
+
if ((q = await relayer_quote(base, asset, recipient, net)).amountSent <= gross) return q;
|
|
4677
|
+
}
|
|
4678
|
+
throw Error(`its fee keeps moving; no quote fits within ${gross}`);
|
|
4679
|
+
}
|
|
4680
|
+
async function relay(base, o) {
|
|
4681
|
+
var p;
|
|
4682
|
+
let h, s, reply = await request(`${base}/v1/relay/${CHAIN_TYPE}/${config_chainId()}/withdrawal`, {
|
|
4683
|
+
signedFeeCommitment: o.quote.commitment,
|
|
4684
|
+
proof: (p = o.proof, h = (s)=>`0x${BigInt(s).toString(16)}`, {
|
|
4685
|
+
...s = snarkjsProof(p),
|
|
4686
|
+
pi_a: s.pi_a.map(h),
|
|
4687
|
+
pi_b: s.pi_b.map((xs)=>xs.map(h)),
|
|
4688
|
+
pi_c: s.pi_c.map(h),
|
|
4689
|
+
publicSignals: p.publicSignals.map(h)
|
|
4690
|
+
}),
|
|
4691
|
+
noteData: o.notes.map((n)=>({
|
|
4692
|
+
hint: n.hint,
|
|
4693
|
+
data: `0x${utils_bytesToHex(n.ciphertext)}`
|
|
4694
|
+
})),
|
|
4695
|
+
inputNullifierNumber: o.inputs,
|
|
4696
|
+
outputCommitmentNumber: o.notes.length
|
|
4697
|
+
});
|
|
4698
|
+
if ('string' != typeof reply.txHash) throw Error(`the relayer answered without a transaction: ${JSON.stringify(reply)}`);
|
|
4699
|
+
return reply.txHash;
|
|
4700
|
+
}
|
|
4594
4701
|
async function zap_quote(net, router, value, ppm) {
|
|
4595
4702
|
let q = await rpc_read(net, router, ROUTER.quote, value);
|
|
4596
4703
|
return {
|
|
@@ -4623,8 +4730,12 @@ async function assertRouter(net, router, vault, entrypoint) {
|
|
|
4623
4730
|
if (gotEntrypoint.toLowerCase() !== entrypoint.toLowerCase()) throw new config_UsageError(`router ${router} deposits into ${gotEntrypoint}, not ${entrypoint} -- refusing to use it`);
|
|
4624
4731
|
}
|
|
4625
4732
|
async function commands_connect() {
|
|
4626
|
-
let net = rpc(
|
|
4627
|
-
|
|
4733
|
+
let net = rpc(function() {
|
|
4734
|
+
let url = rpcOverrideUrl() ?? process.env.MONEYSURFER_RPC ?? deployment().rpc;
|
|
4735
|
+
if (url) return url;
|
|
4736
|
+
throw new config_UsageError(`no public RPC on ${chainName(selected)} serves the logs a sync reads -- pass --rpc-url, or set\n MONEYSURFER_RPC, to a provider of your own (Alchemy, QuickNode, NodeReal with a key, ...)`);
|
|
4737
|
+
}());
|
|
4738
|
+
return await assertChain(net, config_chainId()), net;
|
|
4628
4739
|
}
|
|
4629
4740
|
function commands_saveMnemonic(words) {
|
|
4630
4741
|
mkdirSync(dirname(commands_MNEMONIC_FILE), {
|
|
@@ -4650,7 +4761,7 @@ async function commands_init(o) {
|
|
|
4650
4761
|
}
|
|
4651
4762
|
if (o.fromWallet) {
|
|
4652
4763
|
var address, address1;
|
|
4653
|
-
let signer = await makeSigner(await commands_connect(),
|
|
4764
|
+
let signer = await makeSigner(await commands_connect(), config_chainId(), o.sig);
|
|
4654
4765
|
v2_commands_log(`asking ${signer.address} to sign the secret-derivation message, twice ...`);
|
|
4655
4766
|
let typed = (address = signer.address, {
|
|
4656
4767
|
types: {
|
|
@@ -4699,7 +4810,7 @@ async function commands_init(o) {
|
|
|
4699
4810
|
await signer.signTyped(typed)
|
|
4700
4811
|
];
|
|
4701
4812
|
if (a !== b) throw Error('the wallet signed the same message differently twice; it cannot derive a stable seed');
|
|
4702
|
-
commands_saveMnemonic(entropyToMnemonic((address1 = signer.address, hkdf_hkdf(sha2_sha256, utils_hexToBytes(a.toLowerCase().replace(/^0x/, '')).slice(0, 32), utils_hexToBytes(address1.toLowerCase().slice(2)), utils_utf8ToBytes(ROOT_DERIVATION_INFO), 32)), english_wordlist)), v2_commands_log(`these words carry the root secret
|
|
4813
|
+
commands_saveMnemonic(entropyToMnemonic((address1 = signer.address, hkdf_hkdf(sha2_sha256, utils_hexToBytes(a.toLowerCase().replace(/^0x/, '')).slice(0, 32), utils_hexToBytes(address1.toLowerCase().slice(2)), utils_utf8ToBytes(ROOT_DERIVATION_INFO), 32)), english_wordlist)), v2_commands_log(`these words carry the root secret privacypools.com derives for ${signer.address}`), v2_commands_log(' UNVERIFIED: the derivation was recovered from the app bundle and has never been checked'), v2_commands_log(' against an account the app itself made. Confirm `register` before funding anything.');
|
|
4703
4814
|
return;
|
|
4704
4815
|
}
|
|
4705
4816
|
let words = generateMnemonic(english_wordlist, 256);
|
|
@@ -4711,7 +4822,7 @@ async function commands_account(net, c) {
|
|
|
4711
4822
|
if (!m) throw new config_UsageError('no seed -- run `moneysurfer v2 init` first, or set MONEYSURFER_MNEMONIC');
|
|
4712
4823
|
if (!validateMnemonic(m.trim(), english_wordlist)) throw new config_UsageError('the seed is not a valid BIP-39 phrase');
|
|
4713
4824
|
return mnemonicToEntropy(m.trim(), english_wordlist);
|
|
4714
|
-
}(), owner = c.safe ?? c.sig.from ?? (await makeSigner(net,
|
|
4825
|
+
}(), owner = c.safe ?? c.sig.from ?? (await makeSigner(net, config_chainId(), c.sig)).address;
|
|
4715
4826
|
return {
|
|
4716
4827
|
keys: function(rootSecret, revocableKeyIndex = 0n) {
|
|
4717
4828
|
var salt;
|
|
@@ -4746,11 +4857,11 @@ async function commands_setup(which) {
|
|
|
4746
4857
|
'zkey',
|
|
4747
4858
|
'vkey'
|
|
4748
4859
|
]){
|
|
4749
|
-
if (
|
|
4860
|
+
if (artifacts_current(c, kind)) {
|
|
4750
4861
|
v2_commands_log(`have ${c}.${kind}`);
|
|
4751
4862
|
continue;
|
|
4752
4863
|
}
|
|
4753
|
-
v2_commands_log(
|
|
4864
|
+
v2_commands_log(`${have(c, kind) ? 'replacing an out-of-date' : 'downloading'} ${c}.${kind} ...`);
|
|
4754
4865
|
let bytes = await fetchArtifact(c, kind);
|
|
4755
4866
|
v2_commands_log(` ${bytes.length} bytes, sha256 ${pinned(c, kind)} matches`);
|
|
4756
4867
|
}
|
|
@@ -4768,9 +4879,9 @@ async function commands_poolsCmd() {
|
|
|
4768
4879
|
async function v2_commands_balance(c) {
|
|
4769
4880
|
let net = await commands_connect(), { keys, root, owner } = await commands_account(net, c), all = await assets(net), ev = await sync(net, v2_commands_log), { accounts } = account_recover(keys, root, owner, [
|
|
4770
4881
|
...new Set(all.map((a)=>a.tokenId))
|
|
4771
|
-
], ev);
|
|
4882
|
+
], ev, config_chainId());
|
|
4772
4883
|
if (!accounts.length) return v2_commands_log(`no notes found for this seed at ${owner}`);
|
|
4773
|
-
let asp = await chain_aspSet(net), registered = await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.nullifyingKeys, owner) !== 0n;
|
|
4884
|
+
let asp = await chain_aspSet(net, v2_commands_log), registered = await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.nullifyingKeys, owner) !== 0n;
|
|
4774
4885
|
v2_commands_out(`${owner}${registered ? '' : ' NOT REGISTERED -- `moneysurfer v2 register` before spending'}`);
|
|
4775
4886
|
let byToken = new Map();
|
|
4776
4887
|
for (let a of accounts){
|
|
@@ -4880,7 +4991,7 @@ async function v2_commands_deposit(key, amountArg, c) {
|
|
|
4880
4991
|
}
|
|
4881
4992
|
let ev = await sync(net), { nextIndex } = account_recover(keys, root, owner, [
|
|
4882
4993
|
asset.tokenId
|
|
4883
|
-
], ev), queue = c.safe ? await safeQueue(net,
|
|
4994
|
+
], ev, config_chainId()), queue = c.safe ? await safeQueue(net, config_chainId(), c.safe) : void 0, waiting = queue ? function(q, tokenId) {
|
|
4884
4995
|
let tok = BigInt(tokenId).toString(16).padStart(64, '0'), found = [];
|
|
4885
4996
|
for (let { data } of q.queued)for(let i = data.indexOf(tok); -1 !== i; i = data.indexOf(tok, i + 1)){
|
|
4886
4997
|
let before = data.slice(i - 64, i), after = data.slice(i + 64, i + 128);
|
|
@@ -4892,13 +5003,13 @@ async function v2_commands_deposit(key, amountArg, c) {
|
|
|
4892
5003
|
return found;
|
|
4893
5004
|
}(queue, asset.tokenId) : [], index = nextIndex.get(asset.tokenId.toLowerCase()) ?? 0n;
|
|
4894
5005
|
for(;;){
|
|
4895
|
-
let s = crypto_depositSecrets(root, asset.tokenId, index);
|
|
5006
|
+
let s = crypto_depositSecrets(root, asset.tokenId, index, config_chainId());
|
|
4896
5007
|
if (!waiting.some((w)=>commitmentAt(asset.tokenId, owner, s, w.value) === w.commitment) && await rpc_read(net, POOL_ADDR, chain_POOL.commitments, commitmentAt(asset.tokenId, owner, s, value)) === 0n) break;
|
|
4897
5008
|
index++;
|
|
4898
5009
|
}
|
|
4899
5010
|
let fee = value * asset.vettingFeeBPS / 10000n;
|
|
4900
5011
|
v2_commands_log(`depositing ${commands_amountOf(asset, value)} from ${owner}`), fee > 0n && v2_commands_log(` it costs ${commands_amountOf(asset, value + fee)}: the ${Number(asset.vettingFeeBPS) / 100}% vetting fee is on top`), v2_commands_log(` account #${index + 1n}`);
|
|
4901
|
-
let secrets = crypto_depositSecrets(root, asset.tokenId, index), started = Date.now();
|
|
5012
|
+
let secrets = crypto_depositSecrets(root, asset.tokenId, index, config_chainId()), started = Date.now();
|
|
4902
5013
|
v2_commands_log(`proving on ${c.threads} threads ...`);
|
|
4903
5014
|
let dep = await buildDeposit({
|
|
4904
5015
|
owner,
|
|
@@ -5009,13 +5120,13 @@ async function commands_simulate(net, from, call, asset) {
|
|
|
5009
5120
|
throw new config_UsageError(`it would revert, nothing was sent: ${why}`);
|
|
5010
5121
|
}
|
|
5011
5122
|
async function commands_spendNonce(net, safe, a, privateNullifyingKey) {
|
|
5012
|
-
let q = await safeQueue(net,
|
|
5123
|
+
let q = await safeQueue(net, config_chainId(), safe), same = queuedWith(q, nullifier(privateNullifyingKey, a.note.commitment));
|
|
5013
5124
|
return same && v2_commands_log(`account #${a.index + 1n} has a proposal waiting at nonce ${same.nonce} already; both spend the account, so whichever the owners execute first leaves the other to revert -- reject that one in the Safe app to clear its nonce`), nextNonce(q);
|
|
5014
5125
|
}
|
|
5015
5126
|
async function proposeCalls(net, c, calls, what, at) {
|
|
5016
|
-
let safe = c.safe, nonce = at ?? nextNonce(await safeQueue(net,
|
|
5127
|
+
let safe = c.safe, nonce = at ?? nextNonce(await safeQueue(net, config_chainId(), safe)), call = calls.length > 1 ? batch(calls) : calls[0];
|
|
5017
5128
|
if (c.dryRun) {
|
|
5018
|
-
let { safeTxHash } = await prepareSafeTx(net,
|
|
5129
|
+
let { safeTxHash } = await prepareSafeTx(net, config_chainId(), safe, call, nonce);
|
|
5019
5130
|
v2_commands_out(JSON.stringify({
|
|
5020
5131
|
safe,
|
|
5021
5132
|
safeTxHash,
|
|
@@ -5025,11 +5136,11 @@ async function proposeCalls(net, c, calls, what, at) {
|
|
|
5025
5136
|
}, null, 2));
|
|
5026
5137
|
return;
|
|
5027
5138
|
}
|
|
5028
|
-
let signer = await makeSigner(net,
|
|
5139
|
+
let signer = await makeSigner(net, config_chainId(), c.sig);
|
|
5029
5140
|
v2_commands_log(`proposing ${what} to Safe ${safe} as ${signer.address}${calls.length > 1 ? ', batched with the approval' : ''}`);
|
|
5030
5141
|
let { safeTxHash, queue } = await proposeSafeTx({
|
|
5031
5142
|
net,
|
|
5032
|
-
chainId:
|
|
5143
|
+
chainId: config_chainId(),
|
|
5033
5144
|
safe,
|
|
5034
5145
|
signer,
|
|
5035
5146
|
call,
|
|
@@ -5037,23 +5148,48 @@ async function proposeCalls(net, c, calls, what, at) {
|
|
|
5037
5148
|
});
|
|
5038
5149
|
v2_commands_log(`proposed ${safeTxHash} at nonce ${nonce}; the owners confirm and execute it at ${queue}`);
|
|
5039
5150
|
}
|
|
5151
|
+
function tooDear(asset, q, gross, maxPercent) {
|
|
5152
|
+
let asks = `asks ${commands_amountOf(asset, q.feeAmount)} (${Number(1000000n * q.feeAmount / gross) / 10000}%)`;
|
|
5153
|
+
return asset.maxRelayFee > 0n && q.feeAmount > asset.maxRelayFee ? `${asks}, above the pool's cap of ${commands_amountOf(asset, asset.maxRelayFee)}` : 1000000n * q.feeAmount > gross * BigInt(Math.round(10000 * maxPercent)) ? `${asks}, above --max-fee-percent ${maxPercent}` : void 0;
|
|
5154
|
+
}
|
|
5155
|
+
async function commands_pickRelayer(urls, asset, recipient, gross, maxPercent) {
|
|
5156
|
+
let refused = [];
|
|
5157
|
+
for (let url of urls){
|
|
5158
|
+
let base = url.replace(/\/$/, '');
|
|
5159
|
+
try {
|
|
5160
|
+
let d = await relayer_details(base);
|
|
5161
|
+
if (!d.assets.has(asset.tokenId.toLowerCase())) {
|
|
5162
|
+
refused.push(`${base}: does not relay ${asset.symbol} on ${chainName(config_chainId())}`);
|
|
5163
|
+
continue;
|
|
5164
|
+
}
|
|
5165
|
+
let q = await quoteGross(base, asset.tokenId, recipient, gross), why = tooDear(asset, q, gross, maxPercent);
|
|
5166
|
+
if (!why) return {
|
|
5167
|
+
base,
|
|
5168
|
+
details: d,
|
|
5169
|
+
quote: q
|
|
5170
|
+
};
|
|
5171
|
+
refused.push(`${base}: ${why}`);
|
|
5172
|
+
} catch (e) {
|
|
5173
|
+
refused.push(`${base}: ${e.message}`);
|
|
5174
|
+
}
|
|
5175
|
+
}
|
|
5176
|
+
throw new config_UsageError(`no relayer takes this withdrawal:\n ${refused.join(`
|
|
5177
|
+
`)}\n raise --max-fee-percent, name one with --relayer, or pay the gas with --self`);
|
|
5178
|
+
}
|
|
5040
5179
|
async function commands_withdraw(key, amountArg, to, v, c) {
|
|
5041
|
-
var signals;
|
|
5042
|
-
let tail;
|
|
5043
5180
|
if (!key || !amountArg || !to) throw new config_UsageError('usage: moneysurfer v2 withdraw <asset> <amount|all> <recipient>');
|
|
5044
5181
|
if ([
|
|
5045
5182
|
v.relayer,
|
|
5046
5183
|
v.self,
|
|
5047
5184
|
c.safe
|
|
5048
5185
|
].filter(Boolean).length > 1) throw new config_UsageError('--relayer, --self and --safe are exclusive');
|
|
5049
|
-
|
|
5050
|
-
Pass --self to submit and pay gas yourself (this links that address to the withdrawal),
|
|
5051
|
-
or --safe SAFE to have a Safe submit it.`);
|
|
5052
|
-
let recipient = flags_checksummed(to), net = await commands_connect(), asset = pickAsset(await assets(net), key), { keys, root, owner } = await commands_account(net, c);
|
|
5186
|
+
let relayed = !(v.self || c.safe), recipient = flags_checksummed(to), net = await commands_connect(), asset = pickAsset(await assets(net), key), { keys, root, owner } = await commands_account(net, c);
|
|
5053
5187
|
if (await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.nullifyingKeys, owner) === 0n) throw new config_UsageError(`${owner} is not in the Keystore -- run \`moneysurfer v2 register\` first`);
|
|
5188
|
+
let signer = relayed ? void 0 : await signerFor(net, c, owner), processor = relayed ? RELAY_ADDR : c.safe ?? signer.address;
|
|
5189
|
+
if (!relayed && recipient.toLowerCase() !== processor.toLowerCase()) throw new config_UsageError(`a spend pays whoever submits it -- ${processor} -- and the pool will not pay ${recipient}:\n it hands the amount to msg.sender and requires that to be the processooor the proof names.\n Name ${processor} as the recipient, or leave out ${c.safe ? '--safe' : '--self'} and let a relayer\n submit it: its PrivacyPoolRelay is then the processooor and pays the recipient.`);
|
|
5054
5190
|
let ev = await sync(net, v2_commands_log), { accounts } = account_recover(keys, root, owner, [
|
|
5055
5191
|
asset.tokenId
|
|
5056
|
-
], ev), amount = 'all' === amountArg ? 'all' : parseUnits(amountArg, asset.decimals), a = function(accounts, amount, id) {
|
|
5192
|
+
], ev, config_chainId()), amount = 'all' === amountArg ? 'all' : parseUnits(amountArg, asset.decimals), a = function(accounts, amount, id) {
|
|
5057
5193
|
if (void 0 !== id) {
|
|
5058
5194
|
let a = accounts.find((x)=>String(Number(x.index) + 1) === id.replace(/^#/, ''));
|
|
5059
5195
|
if (!a) throw new config_UsageError(`no account #${id} (see: moneysurfer v2 balance)`);
|
|
@@ -5068,7 +5204,7 @@ async function commands_withdraw(key, amountArg, to, v, c) {
|
|
|
5068
5204
|
let [state, ks, asp] = await Promise.all([
|
|
5069
5205
|
chain_stateTree(net, ev),
|
|
5070
5206
|
keystoreTree(net, ev),
|
|
5071
|
-
chain_aspSet(net)
|
|
5207
|
+
chain_aspSet(net, v2_commands_log)
|
|
5072
5208
|
]), timestamp = await rpc_read(net, POOL_ADDR, chain_POOL.commitments, a.note.commitment);
|
|
5073
5209
|
if (0n === timestamp) throw Error('the pool does not hold this note -- re-sync, or it was never mined');
|
|
5074
5210
|
let note = {
|
|
@@ -5084,126 +5220,177 @@ async function commands_withdraw(key, amountArg, to, v, c) {
|
|
|
5084
5220
|
}(state, commitmentLeaf(a.note.commitment, timestamp)), function(set, lbl) {
|
|
5085
5221
|
if (0 > set.tree.levels[0].indexOf(aspLeaf(lbl))) throw new config_UsageError(`label 0x${lbl.toString(16)} is not in the association set -- not attested yet, or rejected`);
|
|
5086
5222
|
}(asp, a.label);
|
|
5087
|
-
let
|
|
5088
|
-
recipient,
|
|
5089
|
-
feeRecipient: recipient,
|
|
5090
|
-
feeAmount: 0n,
|
|
5091
|
-
nativeGas: 0n
|
|
5092
|
-
}), notes = [
|
|
5223
|
+
let notes = [
|
|
5093
5224
|
NO_NOTE
|
|
5094
|
-
],
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
{
|
|
5225
|
+
], proveSpend = (amountOut, data)=>{
|
|
5226
|
+
let outputs = [
|
|
5227
|
+
{
|
|
5228
|
+
owner,
|
|
5229
|
+
noteSecret: changeSecret(root, a.label, BigInt(a.spends.length)),
|
|
5230
|
+
value: a.note.value - amountOut,
|
|
5231
|
+
label: a.label
|
|
5232
|
+
}
|
|
5233
|
+
];
|
|
5234
|
+
v2_commands_log(`proving ${transactCircuit(1, 1)} on ${c.threads} threads ...`);
|
|
5235
|
+
let t = function(account, notes, outputs, trees, { amountOut = 0n, context }) {
|
|
5236
|
+
if (!notes.length) throw new config_UsageError('a transact spends at least one note');
|
|
5237
|
+
let tokenId = notes[0].tokenId;
|
|
5238
|
+
if (notes.some((n)=>n.tokenId !== tokenId)) throw new config_UsageError('every note in one transact shares a tokenId');
|
|
5239
|
+
let inValue = notes.reduce((a, n)=>a + n.value, 0n), outValue = outputs.reduce((a, o)=>a + o.value, 0n);
|
|
5240
|
+
if (inValue !== outValue + amountOut) throw new config_UsageError(`value does not balance: ${inValue} in, ${outValue} out plus ${amountOut} withdrawn`);
|
|
5241
|
+
let perLabel = new Map();
|
|
5242
|
+
for (let n of notes)perLabel.set(n.label, (perLabel.get(n.label) ?? 0n) + n.value);
|
|
5243
|
+
for (let o of outputs){
|
|
5244
|
+
let left = perLabel.get(o.label);
|
|
5245
|
+
if (void 0 === left) throw new config_UsageError(`output label 0x${o.label.toString(16)} is not inherited from an input`);
|
|
5246
|
+
if (o.value > left) throw new config_UsageError(`label 0x${o.label.toString(16)} has ${left} left across its inputs, but an output spends ${o.value}`);
|
|
5247
|
+
perLabel.set(o.label, left - o.value);
|
|
5248
|
+
}
|
|
5249
|
+
let kp = locate(trees.keystore, accountLeaf(account), 'the account'), sp = notes.map((n)=>locate(trees.state, noteLeaf(n), 'the note')), ap = notes.map((n)=>locate(trees.asp, aspLeaf(n.label), 'the label'));
|
|
5250
|
+
return {
|
|
5251
|
+
circuit: transactCircuit(notes.length, outputs.length),
|
|
5252
|
+
nullifiers: notes.map((n)=>noteNullifier(n, account.privateNullifyingKey)),
|
|
5253
|
+
commitments: outputs.map((o)=>crypto_commitment(v2_crypto_precommitment(crypto_noteAddressHash(o.owner, o.noteSecret), tokenId, o.value), o.label)),
|
|
5254
|
+
input: {
|
|
5255
|
+
tokenId: BigInt(tokenId),
|
|
5256
|
+
context,
|
|
5257
|
+
value: notes.map((n)=>n.value),
|
|
5258
|
+
noteSecret: notes.map((n)=>n.noteSecret),
|
|
5259
|
+
label: notes.map((n)=>n.label),
|
|
5260
|
+
timestamp: notes.map((n)=>n.timestamp),
|
|
5261
|
+
ownerAddress: BigInt(account.owner),
|
|
5262
|
+
privateNullifyingKey: account.privateNullifyingKey,
|
|
5263
|
+
privateRevocableKey: account.privateRevocableKey,
|
|
5264
|
+
keystoreRoot: trees.keystore.root,
|
|
5265
|
+
keystoreLeafIndex: BigInt(kp.index),
|
|
5266
|
+
keystoreTreeDepth: BigInt(kp.siblings.length),
|
|
5267
|
+
keystoreSiblings: notes_pad(kp.siblings, 18),
|
|
5268
|
+
stateRoot: trees.state.root,
|
|
5269
|
+
stateLeafIndex: sp.map((p)=>BigInt(p.index)),
|
|
5270
|
+
stateTreeDepth: sp.map((p)=>BigInt(p.siblings.length)),
|
|
5271
|
+
stateSiblings: sp.flatMap((p)=>notes_pad(p.siblings, 22)),
|
|
5272
|
+
associationSetRoot: trees.asp.root,
|
|
5273
|
+
associationSetLeafIndex: ap.map((p)=>BigInt(p.index)),
|
|
5274
|
+
associationSetTreeDepth: ap.map((p)=>BigInt(p.siblings.length)),
|
|
5275
|
+
associationSetSiblings: ap.flatMap((p)=>notes_pad(p.siblings, 18)),
|
|
5276
|
+
amountOut,
|
|
5277
|
+
tokenIdOut: BigInt(tokenId),
|
|
5278
|
+
outputNoteAddressHash: outputs.map((o)=>crypto_noteAddressHash(o.owner, o.noteSecret)),
|
|
5279
|
+
outputValue: outputs.map((o)=>o.value),
|
|
5280
|
+
outputLabel: outputs.map((o)=>o.label)
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
}({
|
|
5105
5284
|
owner,
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5285
|
+
privateNullifyingKey: keys.privateNullifyingKey,
|
|
5286
|
+
privateRevocableKey: keys.privateRevocableKey
|
|
5287
|
+
}, [
|
|
5288
|
+
note
|
|
5289
|
+
], outputs, {
|
|
5290
|
+
state,
|
|
5291
|
+
keystore: ks,
|
|
5292
|
+
asp: asp.tree
|
|
5293
|
+
}, {
|
|
5294
|
+
amountOut,
|
|
5295
|
+
context: utils_utils_bytesToNumberBE(sha3_keccak_256(ROUTING.transactContext.encodeInput({
|
|
5296
|
+
transactParams: {
|
|
5297
|
+
processor: processor,
|
|
5298
|
+
data: data
|
|
5299
|
+
},
|
|
5300
|
+
notes: notes.map((n)=>({
|
|
5301
|
+
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5302
|
+
data: n.ciphertext
|
|
5303
|
+
}))
|
|
5304
|
+
}).slice(4))) % crypto_SNARK_FIELD
|
|
5305
|
+
});
|
|
5306
|
+
return prover_prove(t.circuit, t.input, c.threads);
|
|
5307
|
+
}, transactArgs = (proof, data)=>{
|
|
5308
|
+
var signals;
|
|
5309
|
+
let tail, s = solidityProof(proof);
|
|
5127
5310
|
return {
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
stateSiblings: sp.flatMap((p)=>notes_pad(p.siblings, 22)),
|
|
5149
|
-
associationSetRoot: trees.asp.root,
|
|
5150
|
-
associationSetLeafIndex: ap.map((p)=>BigInt(p.index)),
|
|
5151
|
-
associationSetTreeDepth: ap.map((p)=>BigInt(p.siblings.length)),
|
|
5152
|
-
associationSetSiblings: ap.flatMap((p)=>notes_pad(p.siblings, 18)),
|
|
5153
|
-
amountOut,
|
|
5154
|
-
tokenIdOut: BigInt(tokenId),
|
|
5155
|
-
outputNoteAddressHash: outputs.map((o)=>crypto_noteAddressHash(o.owner, o.noteSecret)),
|
|
5156
|
-
outputValue: outputs.map((o)=>o.value),
|
|
5157
|
-
outputLabel: outputs.map((o)=>o.label)
|
|
5158
|
-
}
|
|
5311
|
+
proof: {
|
|
5312
|
+
pA: s.pA,
|
|
5313
|
+
pB: s.pB,
|
|
5314
|
+
pC: s.pC,
|
|
5315
|
+
pubSignals: (signals = proof.publicSignals, tail = 2, [
|
|
5316
|
+
signals.slice(0, 1),
|
|
5317
|
+
signals.slice(1, tail),
|
|
5318
|
+
...signals.slice(tail, tail + 6).map((x)=>[
|
|
5319
|
+
x
|
|
5320
|
+
])
|
|
5321
|
+
])
|
|
5322
|
+
},
|
|
5323
|
+
transactParams: {
|
|
5324
|
+
processooor: processor,
|
|
5325
|
+
data
|
|
5326
|
+
},
|
|
5327
|
+
notes: notes.map((n)=>({
|
|
5328
|
+
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5329
|
+
ciphertext: n.ciphertext
|
|
5330
|
+
}))
|
|
5159
5331
|
};
|
|
5160
|
-
}({
|
|
5161
|
-
owner,
|
|
5162
|
-
privateNullifyingKey: keys.privateNullifyingKey,
|
|
5163
|
-
privateRevocableKey: keys.privateRevocableKey
|
|
5164
|
-
}, [
|
|
5165
|
-
note
|
|
5166
|
-
], outputs, {
|
|
5167
|
-
state,
|
|
5168
|
-
keystore: ks,
|
|
5169
|
-
asp: asp.tree
|
|
5170
|
-
}, {
|
|
5171
|
-
amountOut: value,
|
|
5172
|
-
context
|
|
5173
|
-
}), proof = await prover_prove(t.circuit, t.input, c.threads), s = solidityProof(proof), calldata = chain_POOL.transact.encodeInput({
|
|
5174
|
-
proof: {
|
|
5175
|
-
pA: s.pA,
|
|
5176
|
-
pB: s.pB,
|
|
5177
|
-
pC: s.pC,
|
|
5178
|
-
pubSignals: (signals = proof.publicSignals, tail = 2, [
|
|
5179
|
-
signals.slice(0, 1),
|
|
5180
|
-
signals.slice(1, tail),
|
|
5181
|
-
...signals.slice(tail, tail + 6).map((x)=>[
|
|
5182
|
-
x
|
|
5183
|
-
])
|
|
5184
|
-
])
|
|
5185
|
-
},
|
|
5186
|
-
transactParams: {
|
|
5187
|
-
processooor: processor,
|
|
5188
|
-
data
|
|
5189
|
-
},
|
|
5190
|
-
notes: notes.map((n)=>({
|
|
5191
|
-
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5192
|
-
ciphertext: n.ciphertext
|
|
5193
|
-
}))
|
|
5194
|
-
}), call = {
|
|
5195
|
-
to: POOL_ADDR,
|
|
5196
|
-
value: 0n,
|
|
5197
|
-
data: calldata
|
|
5198
5332
|
};
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5333
|
+
if (!relayed) {
|
|
5334
|
+
let data = payoutRouting({
|
|
5335
|
+
recipient,
|
|
5336
|
+
feeRecipient: recipient,
|
|
5337
|
+
feeAmount: 0n,
|
|
5338
|
+
nativeGas: 0n
|
|
5339
|
+
});
|
|
5340
|
+
v2_commands_log(`withdrawing ${commands_amountOf(asset, value)} from account #${a.index + 1n} to ${recipient}`), a.note.value > value && v2_commands_log(` ${commands_amountOf(asset, a.note.value - value)} stays in the pool as a new note`);
|
|
5341
|
+
let proof = await proveSpend(value, data), calldata = chain_POOL.transact.encodeInput(transactArgs(proof, data)), call = {
|
|
5342
|
+
to: POOL_ADDR,
|
|
5343
|
+
value: 0n,
|
|
5344
|
+
data: calldata
|
|
5345
|
+
};
|
|
5346
|
+
return c.safe ? proposeCalls(net, c, [
|
|
5347
|
+
call
|
|
5348
|
+
], 'the withdrawal', await commands_spendNonce(net, c.safe, a, keys.privateNullifyingKey)) : (await commands_simulate(net, signer.address, call, asset), v2_commands_log('simulated: the pool accepts it'), c.dryRun) ? void v2_commands_out(JSON.stringify({
|
|
5349
|
+
to: call.to,
|
|
5350
|
+
data: v2_commands_hex(calldata),
|
|
5351
|
+
recipient,
|
|
5352
|
+
amountOut: String(value)
|
|
5353
|
+
}, null, 2)) : (v2_commands_log(`submitting from ${signer.address} -- this links that address to the withdrawal`), void v2_commands_log(`sent: ${await signer.send(call)}`));
|
|
5354
|
+
}
|
|
5355
|
+
let maxPercent = c.maxFeePercent ?? 1, r = await commands_pickRelayer(v.relayer ? [
|
|
5356
|
+
v.relayer
|
|
5357
|
+
] : RELAYERS, asset, recipient, value, maxPercent);
|
|
5358
|
+
v2_commands_log(`relayer ${r.base}: fee ${commands_amountOf(asset, r.quote.feeAmount)} to ${r.quote.routing.feeRecipient}`), v2_commands_log(`withdrawing ${commands_amountOf(asset, r.quote.amountSent)} from account #${a.index + 1n}: ${commands_amountOf(asset, r.quote.amount)} to ${recipient}`), a.note.value > r.quote.amountSent && v2_commands_log(` ${commands_amountOf(asset, a.note.value - r.quote.amountSent)} stays in the pool as a new note`);
|
|
5359
|
+
let proof = await proveSpend(r.quote.amountSent, r.quote.data);
|
|
5360
|
+
for(let tries = 0; Date.now() > r.quote.expiration - 5000; tries++){
|
|
5361
|
+
if (3 === tries) throw Error("the relayer's quote keeps expiring before the proof is ready -- try more --threads");
|
|
5362
|
+
v2_commands_log('the quote expired while proving; asking again');
|
|
5363
|
+
let q = await quoteGross(r.base, asset.tokenId, recipient, value), why = tooDear(asset, q, value, maxPercent);
|
|
5364
|
+
if (why) throw new config_UsageError(`the relayer now ${why}`);
|
|
5365
|
+
let same = q.amountSent === r.quote.amountSent && utils_bytesToHex(q.data) === utils_bytesToHex(r.quote.data);
|
|
5366
|
+
r = {
|
|
5367
|
+
...r,
|
|
5368
|
+
quote: q
|
|
5369
|
+
}, same || (v2_commands_log(` the fee moved to ${commands_amountOf(asset, q.feeAmount)}`), proof = await proveSpend(q.amountSent, q.data));
|
|
5370
|
+
}
|
|
5371
|
+
let calldata = RELAY.relay.encodeInput(transactArgs(proof, r.quote.data)), sim = await net.dryRun({
|
|
5372
|
+
from: r.details.relayerAddress,
|
|
5373
|
+
to: RELAY_ADDR,
|
|
5374
|
+
data: v2_commands_hex(calldata)
|
|
5375
|
+
});
|
|
5376
|
+
if (!sim.success) throw new config_UsageError(`it would revert, nothing was sent: ${sim.reason}`);
|
|
5377
|
+
if (v2_commands_log('simulated: the relay accepts it'), c.dryRun) return void v2_commands_out(JSON.stringify({
|
|
5378
|
+
relayer: r.base,
|
|
5379
|
+
to: RELAY_ADDR,
|
|
5203
5380
|
data: v2_commands_hex(calldata),
|
|
5204
5381
|
recipient,
|
|
5205
|
-
amountOut: String(
|
|
5206
|
-
|
|
5382
|
+
amountOut: String(r.quote.amountSent),
|
|
5383
|
+
fee: String(r.quote.feeAmount)
|
|
5384
|
+
}, null, 2));
|
|
5385
|
+
let spent = nullifier(keys.privateNullifyingKey, a.note.commitment), tx = await relay(r.base, {
|
|
5386
|
+
quote: r.quote,
|
|
5387
|
+
proof,
|
|
5388
|
+
notes,
|
|
5389
|
+
inputs: 1
|
|
5390
|
+
});
|
|
5391
|
+
v2_commands_log(`relayer sent ${tx} -- waiting for the chain`);
|
|
5392
|
+
for(let deadline = Date.now() + 900000; Date.now() < deadline; await commands_sleep(4000))if (await rpc_read(net, POOL_ADDR, chain_POOL.spentNullifiers, spent) !== 0n) return v2_commands_log(`withdrawn: ${tx}`);
|
|
5393
|
+
throw Error('not confirmed within 15 minutes -- check `moneysurfer v2 balance` before trying again');
|
|
5207
5394
|
}
|
|
5208
5395
|
async function v2_commands_ragequit(key, v, c) {
|
|
5209
5396
|
var account, note, trees;
|
|
@@ -5211,7 +5398,7 @@ async function v2_commands_ragequit(key, v, c) {
|
|
|
5211
5398
|
if (!key || void 0 === v.id) throw new config_UsageError('usage: moneysurfer v2 ragequit <asset> --id N');
|
|
5212
5399
|
let net = await commands_connect(), asset = pickAsset(await assets(net), key), { keys, root, owner } = await commands_account(net, c), ev = await sync(net, v2_commands_log), { accounts } = account_recover(keys, root, owner, [
|
|
5213
5400
|
asset.tokenId
|
|
5214
|
-
], ev), a = accounts.find((x)=>String(Number(x.index) + 1) === v.id.replace(/^#/, ''));
|
|
5401
|
+
], ev, config_chainId()), a = accounts.find((x)=>String(Number(x.index) + 1) === v.id.replace(/^#/, ''));
|
|
5215
5402
|
if (!a) throw new config_UsageError(`no account #${v.id} (see: moneysurfer v2 balance)`);
|
|
5216
5403
|
if (!account_spendable(a)) throw new config_UsageError(`account #${v.id} has nothing left`);
|
|
5217
5404
|
let ks = await keystoreTree(net, ev), timestamp = await rpc_read(net, POOL_ADDR, chain_POOL.commitments, a.note.commitment);
|
|
@@ -5265,17 +5452,55 @@ async function v2_commands_ragequit(key, v, c) {
|
|
|
5265
5452
|
}
|
|
5266
5453
|
async function commands_status() {
|
|
5267
5454
|
let net = await commands_connect();
|
|
5268
|
-
v2_commands_out(`
|
|
5455
|
+
v2_commands_out(`chain ${chainName(config_chainId())} (${config_chainId()})`), v2_commands_out(`pool ${POOL_ADDR}`), v2_commands_out(` keystore ${await rpc_read(net, POOL_ADDR, chain_POOL.keystore)}`), v2_commands_out(` aspRegistry ${await rpc_read(net, POOL_ADDR, chain_POOL.aspRegistry)}`);
|
|
5456
|
+
let transactKey = sha3_keccak_256(utils_hexToBytes(`${'0'.repeat(63)}1`.repeat(2)));
|
|
5457
|
+
for (let [label, circuit, at] of [
|
|
5458
|
+
[
|
|
5459
|
+
'depositVk',
|
|
5460
|
+
'deposit',
|
|
5461
|
+
rpc_read(net, POOL_ADDR, chain_POOL.depositVerifier)
|
|
5462
|
+
],
|
|
5463
|
+
[
|
|
5464
|
+
'ragequitVk',
|
|
5465
|
+
'ragequit',
|
|
5466
|
+
rpc_read(net, POOL_ADDR, chain_POOL.ragequitVerifier)
|
|
5467
|
+
],
|
|
5468
|
+
[
|
|
5469
|
+
'transactVk',
|
|
5470
|
+
'transact_1x1',
|
|
5471
|
+
rpc_read(net, POOL_ADDR, chain_POOL.verifiers, transactKey).then((v)=>v.verifier)
|
|
5472
|
+
]
|
|
5473
|
+
]){
|
|
5474
|
+
let address = await at, how = artifacts_current(circuit, 'vkey') ? !function(code, circuit) {
|
|
5475
|
+
let j, hay = code.toLowerCase();
|
|
5476
|
+
return [
|
|
5477
|
+
...(j = JSON.parse(new TextDecoder().decode(artifacts_load(circuit, 'vkey')))).vk_delta_2.slice(0, 2).flat(),
|
|
5478
|
+
...j.IC.flatMap((p)=>p.slice(0, 2))
|
|
5479
|
+
].map((w)=>{
|
|
5480
|
+
let hex;
|
|
5481
|
+
return (hex = BigInt(w).toString(16)).length % 2 && (hex = `0${hex}`), `${(0x5f + hex.length / 2).toString(16)}${hex}`;
|
|
5482
|
+
}).every((p)=>hay.includes(p));
|
|
5483
|
+
}(String(await net.call('eth_getCode', address, 'latest')), circuit) ? `NOT built from the pinned ${circuit} key -- proofs made here will be rejected` : `built from the pinned ${circuit} key` : `run \`moneysurfer v2 setup ${circuit}\` to check it`;
|
|
5484
|
+
v2_commands_out(` ${label.padEnd(12)} ${address} ${how}`);
|
|
5485
|
+
}
|
|
5486
|
+
v2_commands_out(` paused ${await rpc_read(net, POOL_ADDR, chain_POOL.paused)}`), v2_commands_out(`entrypoint ${ENTRYPOINT_ADDR}`), v2_commands_out(` poolVault ${await rpc_read(net, ENTRYPOINT_ADDR, chain_ENTRYPOINT.poolVault)}`), v2_commands_out(`keystore ${KEYSTORE_ADDR}`), v2_commands_out(` currentRoot ${hex32(await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.currentRoot))}`), v2_commands_out(`aspRegistry ${ASP_REGISTRY}`), v2_commands_out(` latestRoot ${hex32(await rpc_read(net, ASP_REGISTRY, ASP.latestASPRoot))}`), v2_commands_out(`asp ${ASP_PUBLIC_KEY} (X25519)`), v2_commands_out(`relay ${RELAY_ADDR}`);
|
|
5269
5487
|
}
|
|
5270
5488
|
async function commands_trees() {
|
|
5271
5489
|
let net = await commands_connect(), ev = await sync(net, v2_commands_log), state = await chain_stateTree(net, ev);
|
|
5272
5490
|
v2_commands_out(`state tree ${state.size} leaves, depth ${state.depth}, root ${hex32(state.root)} (the pool knows it)`);
|
|
5273
5491
|
let ks = await keystoreTree(net, ev);
|
|
5274
5492
|
v2_commands_out(`keystore tree ${ks.size} leaves, depth ${ks.depth}, root ${hex32(ks.root)} (the keystore knows it)`);
|
|
5275
|
-
let asp = await chain_aspSet(net);
|
|
5493
|
+
let asp = await chain_aspSet(net, v2_commands_log);
|
|
5276
5494
|
v2_commands_out(`association ${asp.tree.size} leaves, root ${hex32(asp.root)} (the registry published it)`);
|
|
5277
5495
|
}
|
|
5278
5496
|
async function commands_run(cmd, rest, v, c) {
|
|
5497
|
+
void 0 !== v.chain && function(id) {
|
|
5498
|
+
if (!DEPLOYMENTS[id]) {
|
|
5499
|
+
let known = Object.keys(DEPLOYMENTS).map((k)=>`${chainName(Number(k))} (${k})`).join(', ');
|
|
5500
|
+
throw new config_UsageError(`no Privacy Pools V2 on ${chainName(id)} -- supported: ${known}`);
|
|
5501
|
+
}
|
|
5502
|
+
selected = id;
|
|
5503
|
+
}(parseChain(v.chain));
|
|
5279
5504
|
let commands = {
|
|
5280
5505
|
setup: ()=>commands_setup(rest),
|
|
5281
5506
|
init: ()=>commands_init({
|
|
@@ -5317,6 +5542,10 @@ let HOME_ROOT = process.env.MONEYSURFER_HOME ?? join(homedir(), '.local/share/mo
|
|
|
5317
5542
|
rpc: 'https://optimism.gateway.tenderly.co',
|
|
5318
5543
|
safe: 'oeth'
|
|
5319
5544
|
},
|
|
5545
|
+
56: {
|
|
5546
|
+
name: 'BNB',
|
|
5547
|
+
safe: 'bnb'
|
|
5548
|
+
},
|
|
5320
5549
|
42161: {
|
|
5321
5550
|
name: 'Arbitrum',
|
|
5322
5551
|
rpc: 'https://arbitrum.gateway.tenderly.co',
|
|
@@ -11905,7 +12134,7 @@ let SEED_CONTEXT = 'privacy-pools/wallet-seed:v2', ENCODERS = abi_createContract
|
|
|
11905
12134
|
relayFeeBPS
|
|
11906
12135
|
}).slice(4), MISSES = 10, spendable = (a)=>a.note.value > 0n && !a.ragequit, symbolKey = (symbol, address)=>symbol.toLowerCase().replace(/₮/g, 't').replace(/[^a-z0-9._-]/g, '') || address.slice(0, 8).toLowerCase();
|
|
11907
12136
|
entrypoints_namespaceObject = JSON.parse('{"1":{"address":"0x6818809EefCe719E480a7526D76bD3e561526b46","deployedBlock":22153713,"native":"ETH","relayers":["https://fastrelay.xyz/relayer","https://api.clkd.xyz/relayer"]},"10":{"address":"0x44192215FEd782896BE2CE24E0Bfbf0BF825d15E","deployedBlock":144288142,"native":"ETH","relayers":["https://fastrelay.xyz/relayer"]},"42161":{"address":"0x44192215FEd782896BE2CE24E0Bfbf0BF825d15E","deployedBlock":404391809,"native":"ETH","relayers":["https://fastrelay.xyz/relayer"]}}');
|
|
11908
|
-
let ASSETS = ASSETS_ROOT, HOME = HOME_ROOT, ARTIFACT_URL = 'https://privacypools.com/artifacts', ARTIFACTS = {
|
|
12137
|
+
let ASSETS = ASSETS_ROOT, HOME = HOME_ROOT, ARTIFACT_URL = 'https://v1.privacypools.com/artifacts', ARTIFACTS = {
|
|
11909
12138
|
'withdraw.wasm': '36cda22791def3d520a55c0fc808369cd5849532a75fab65686e666ed3d55c10',
|
|
11910
12139
|
'withdraw.zkey': '2a893b42174c813566e5c40c715a8b90cd49fc4ecf384e3a6024158c3d6de677',
|
|
11911
12140
|
'commitment.wasm': '254d2130607182fd6fd1aee67971526b13cfe178c88e360da96dce92663828d8',
|
|
@@ -13359,7 +13588,7 @@ let commands_hex = (b)=>`0x${utils_bytesToHex(b)}`, shortLabel = (label)=>`0x${l
|
|
|
13359
13588
|
setup fetch the circuits, check their pinned sha256
|
|
13360
13589
|
init make a new mnemonic (the one secret behind every note)
|
|
13361
13590
|
--import ... or take one on stdin
|
|
13362
|
-
--from-wallet ... or derive privacypools.com's from your wallet's signature
|
|
13591
|
+
--from-wallet ... or derive v1.privacypools.com's from your wallet's signature
|
|
13363
13592
|
pools every pool the Entrypoints registered: minimum deposit, fee, size
|
|
13364
13593
|
balance your accounts and what each holds
|
|
13365
13594
|
sync pull every pool's events into the cache
|
|
@@ -14139,39 +14368,50 @@ class crypto_LeanIMT {
|
|
|
14139
14368
|
};
|
|
14140
14369
|
}
|
|
14141
14370
|
}
|
|
14142
|
-
let APP_IDENTIFIER = 'TODO-privacy-pools-v2', ROOT_DERIVATION_INFO = 'Standardized-Secret-Derivation-v1-Root', PP_V2 = 'PP_V2', IDENTITY = 'IDENTITY', VIEWING = 'VIEWING', NULLIFYING = 'NULLIFYING', REVOCABLE = 'AUTH0:REVOCABLE', VIEWING_KEY = 'VIEWING_KEY', SECRET_DERIVATION_PURPOSE = "This signature is used to deterministically derive application-specific secrets from your master seed. It is not a transaction and will not cost any gas.", appSecretFrom = (rootSecret)=>hkdf_hkdf(sha2_sha256, rootSecret, utils_utf8ToBytes(APP_IDENTIFIER), utils_utf8ToBytes('Standardized-Secret-Derivation-v1-App'), 32), NOTE_INFO = 'moneysurfer2/v1:', crypto_depositSecrets = (rootSecret, tokenId, index)=>
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14371
|
+
let APP_IDENTIFIER = 'TODO-privacy-pools-v2', ROOT_DERIVATION_INFO = 'Standardized-Secret-Derivation-v1-Root', PP_V2 = 'PP_V2', IDENTITY = 'IDENTITY', VIEWING = 'VIEWING', NULLIFYING = 'NULLIFYING', REVOCABLE = 'AUTH0:REVOCABLE', VIEWING_KEY = 'VIEWING_KEY', SECRET_DERIVATION_PURPOSE = "This signature is used to deterministically derive application-specific secrets from your master seed. It is not a transaction and will not cost any gas.", appSecretFrom = (rootSecret)=>hkdf_hkdf(sha2_sha256, rootSecret, utils_utf8ToBytes(APP_IDENTIFIER), utils_utf8ToBytes('Standardized-Secret-Derivation-v1-App'), 32), NOTE_INFO = 'moneysurfer2/v1:', crypto_depositSecrets = (rootSecret, tokenId, index, chainId)=>{
|
|
14372
|
+
let on = 1 === chainId ? '' : `@${chainId}`;
|
|
14373
|
+
return {
|
|
14374
|
+
noteSecret: noteScalar(rootSecret, `note${on}`, BigInt(tokenId.toLowerCase()), index),
|
|
14375
|
+
depositSecret: noteScalar(rootSecret, `deposit${on}`, BigInt(tokenId.toLowerCase()), index)
|
|
14376
|
+
};
|
|
14377
|
+
}, changeSecret = (rootSecret, label, index)=>noteScalar(rootSecret, 'change', label, index), reduce = (b)=>v2_crypto_Fr.create(utils_utils_bytesToNumberBE(b)), crypto_word = (n)=>utils_hexToBytes(n.toString(16).padStart(64, '0')), PAYOUT_ROUTING = {
|
|
14378
|
+
name: 'routing',
|
|
14379
|
+
type: 'tuple',
|
|
14380
|
+
components: [
|
|
14381
|
+
{
|
|
14382
|
+
name: 'recipient',
|
|
14383
|
+
type: 'address'
|
|
14384
|
+
},
|
|
14385
|
+
{
|
|
14386
|
+
name: 'feeRecipient',
|
|
14387
|
+
type: 'address'
|
|
14388
|
+
},
|
|
14389
|
+
{
|
|
14390
|
+
name: 'feeAmount',
|
|
14391
|
+
type: 'uint256'
|
|
14392
|
+
},
|
|
14393
|
+
{
|
|
14394
|
+
name: 'nativeGas',
|
|
14395
|
+
type: 'uint256'
|
|
14396
|
+
}
|
|
14397
|
+
]
|
|
14398
|
+
}, ROUTING = abi_createContract([
|
|
14146
14399
|
{
|
|
14147
14400
|
type: 'function',
|
|
14148
14401
|
name: 'payoutRouting',
|
|
14149
14402
|
inputs: [
|
|
14150
|
-
|
|
14151
|
-
name: 'routing',
|
|
14152
|
-
type: 'tuple',
|
|
14153
|
-
components: [
|
|
14154
|
-
{
|
|
14155
|
-
name: 'recipient',
|
|
14156
|
-
type: 'address'
|
|
14157
|
-
},
|
|
14158
|
-
{
|
|
14159
|
-
name: 'feeRecipient',
|
|
14160
|
-
type: 'address'
|
|
14161
|
-
},
|
|
14162
|
-
{
|
|
14163
|
-
name: 'feeAmount',
|
|
14164
|
-
type: 'uint256'
|
|
14165
|
-
},
|
|
14166
|
-
{
|
|
14167
|
-
name: 'nativeGas',
|
|
14168
|
-
type: 'uint256'
|
|
14169
|
-
}
|
|
14170
|
-
]
|
|
14171
|
-
}
|
|
14403
|
+
PAYOUT_ROUTING
|
|
14172
14404
|
],
|
|
14173
14405
|
outputs: []
|
|
14174
14406
|
},
|
|
14407
|
+
{
|
|
14408
|
+
type: 'function',
|
|
14409
|
+
name: 'readRouting',
|
|
14410
|
+
inputs: [],
|
|
14411
|
+
outputs: [
|
|
14412
|
+
PAYOUT_ROUTING
|
|
14413
|
+
]
|
|
14414
|
+
},
|
|
14175
14415
|
{
|
|
14176
14416
|
type: 'function',
|
|
14177
14417
|
name: 'transactContext',
|
|
@@ -14207,41 +14447,64 @@ let APP_IDENTIFIER = 'TODO-privacy-pools-v2', ROOT_DERIVATION_INFO = 'Standardiz
|
|
|
14207
14447
|
],
|
|
14208
14448
|
outputs: []
|
|
14209
14449
|
}
|
|
14210
|
-
]), payoutRouting = (r)=>ROUTING.payoutRouting.encodeInput(r).slice(4), account_MISSES = 10, account_spendable = (a)=>a.note.value > 0n && !a.ragequit && !a.lost, noteCommitment = (owner, n)=>crypto_commitment(v2_crypto_precommitment(crypto_noteAddressHash(owner, n.noteSecret), n.tokenId, n.value), n.label);
|
|
14211
|
-
circuit_artifacts_namespaceObject = JSON.parse('{"deposit":{"wasm":"QmbFwUiZywpkCd9AYr3xiVJN2K99ma7raz5FvAS8A8j8DD","wasmSha256":"833e7b3c44a900a95496009a36284e11f57ba0385fab6b63f92075750817550a","provingKey":"QmapgvDJc2ZSA3FLi9YwA7vd7QNThD2LKa17Zyn4pnDQ6S","provingKeySha256":"0e64b6d15ea540b3ab04d5596ab45d1ed6df0872e0261a850039372104837b30","verificationKey":"QmPiRu7icgKrxer7DRHwiWHwpyT2UxCfm475FSA5z8APuM","verificationKeySha256":"cc0c1647983f2ca75b192e5c671b9b2932fd690709922bf32443a4053cd0912a"},"ragequit":{"wasm":"QmfJSLSutPLJgRbtmothHAn3jFpKmXUwFnAdjecCEmJFQz","wasmSha256":"95108046f922d9cb08a1d4e42c88708af03233551a5e13a7118d7a6eff5d31c4","provingKey":"Qmeqe43QyQcASay6pkAw66N3ceSWNipVYShbd2hLvHxfZD","provingKeySha256":"3b0d2c3fdf26363be409dc4f01f5beb1c3cbc3b07a0c1ddb9e825e22e46d9bf4","verificationKey":"QmP46yuoVXH2KyqMBkkCviTzDqUELiRmAPJDic6P4oUeEn","verificationKeySha256":"d285bf7a8f2e38d206c5513771d80816969c75b87558df194c1804ed1ec484d7"},"transact_1x1":{"wasm":"QmYLFBpsJzeKXDfxcKdwz4rrhZTDoWiYyHNkDyreFrFrau","wasmSha256":"bd13ab4130320f095cdee83b42e27877fc6c17f18be3fbdfc55436d33689d262","provingKey":"QmTwJqccgYF7bVvVDVHFGnB96tXQLyhRLohaFm3drKs1hr","provingKeySha256":"ba00dc63d1ef0b09a49dbf9348430362ef18dca5309ad5b6f06a896349c4c80a","verificationKey":"QmfN4QBhkz5NAoo9yd4L8gKjNkap2R4LSKE6yVNS26m4Rh","verificationKeySha256":"e429d3e895de5cc9d2839a3fd8303fadd30be3759bac06ce7fb063ceda198308"},"transact_1x2":{"wasm":"QmYmzdZR25VGfXnfsKY3tjm4ymjbCt67pgnhdqDBDwvxPR","wasmSha256":"71ffcdc53e5808c89ebf735ef45d0ffabfce9e6f640d565adc4f02e36ad1a72e","provingKey":"QmUrciJbUu12kwTPxJEwPHmBT9pgeLkxeG1y4agCuMpFFu","provingKeySha256":"f107598438dee56e053d76724500a58f91457fec14df0f4ee057042a1025bf07","verificationKey":"QmRyrzFTq7gGcTcBtAnvA6WLBpX1Csi6SZSSJDgDQLjXFi","verificationKeySha256":"3bb6f18aa4fec0961151fdc21a74ad9ca7326356cd4a4151b3e808dc12e30ad4"},"transact_1x3":{"wasm":"QmWQb92RQwmycPnfF1zGREU5Ss6N1wEx1e3nm47vioNcqB","wasmSha256":"730ae4756ba37489137ac82e117e1169f6cc8137a17f4733c779dddc69de1158","provingKey":"QmZbWNwb34sv8a3cZ6fjCNHqbCoDoHgPRep7En11ocbqqF","provingKeySha256":"55341d648bbf61e896f9a5b80bfd3c873a271eb515b77575a78a079c5b772e35","verificationKey":"QmRzofJFYKQWLrRzRwi3gfygVDSFqS5QrW8Vnurtm75MAq","verificationKeySha256":"08f505c4899958c9f0a4b7b131d20223f5e4da0cac0fdb0da22b51e84d1515c9"},"transact_1x4":{"wasm":"QmS3DpwFrttLtbHzW995ifAgeXiuL2QHzABE9v8DZ7FG1v","wasmSha256":"9da4a23f8fdf1bd22db6f2a06ee3b26d6058451eecf0fba99707df14bd7d5d4f","provingKey":"Qmaqv6cKbtbV7Y9a55mx9cAzXqQ1dBALVMXbzaLpxftMWU","provingKeySha256":"866d2aad434ff2dff38774a6d82afeb71046eb73be87ea3ffb35401d94080d02","verificationKey":"QmSxB8KzLiY78xQjhKp5XTLwSwAzVdraG5q7pKYJ2znCXr","verificationKeySha256":"68418087e3ecdc7d43d3db0c8684e689d5e2f4f16d12047c7403baffffa054f7"},"transact_1x5":{"wasm":"QmNwpbM9sX62pTLRrZnvBvRmjos57dm6ZGqkVLdXdqQW9v","wasmSha256":"d18ce1511bc8a3e80229381e7b3b2f226106fc044579b2460a3bf2d4dcfe415e","provingKey":"QmdPdM8t6muNkrALfQjhW5ctpGTLjiYY7fhwebnwuTa4zS","provingKeySha256":"de372dce472d9794dfd1ceac28bd3252dfe6b4eb233074d5d9f9ac1e42c45bfe","verificationKey":"QmRt6cSCwDQ7kVJEJ1Tr2yyFxWQSiji3kt3GkH22qmqdut","verificationKeySha256":"009e6668a8063a8ffcad41fd3baff9ee7296de0f234522b41f4490ab11986c57"},"transact_2x1":{"wasm":"QmUYpWth4Mu9LTziML5sqFpVixkWAYbricd6o5Xid1ksrW","wasmSha256":"a1fa16ad0824fe40df716e8bfd0716effad68dcb1ce81f108db596e6a752f15c","provingKey":"QmS2fG8MQhFQVKiRt29dBCSyGNipNspn5kz4T6D6689E8N","provingKeySha256":"add0ae7441be69dc7d25cc76fe8afb43c47511c134834ecbf76eff4451e6e1b2","verificationKey":"QmZn6fcEYdLtzWGr94B3WjdFfwhR9JcafRib7kzeM1sgoG","verificationKeySha256":"4c5e51b308829a549b54d6d898556a3bf8e40656173919597564cd674997c333"},"transact_2x2":{"wasm":"QmZCCa4bMxB4XesiRQ8Nnxz3PHCdqR9wB14NYz1aaoGmGt","wasmSha256":"578a1241233edffba81ca58c2fd0af48aa6434bd5a667caf02a5e3393a1b3664","provingKey":"QmYu1XoUzMAjH4JdUiXdSiRTfgpEDVRceHohhLGigMK8b4","provingKeySha256":"f7c133fd906dae36c88e1052777f03747288c9d4bec2023bf5cd37d315f83355","verificationKey":"QmTTH1rkq5TVa4z1KQVL3RqvDJhF7xcbbYHARKrCHidGE3","verificationKeySha256":"73bc886a46bf4b27e84955960964bc6b622c751504baeb49825de4f6eda8b0ca"},"transact_2x3":{"wasm":"QmcoUX2PMzpjE5DEWhMcnfvAZ9tyJVH7RYMkZC6Sf1cSib","wasmSha256":"54b9f706c15eb91ea8b2012c6ebac1eb6b4e1a4ff8ce299d039aaeda57e52ff5","provingKey":"QmXUmyag1w7iwGu44tWe1LBeLBirAwPVQReUL6LpfUm4rE","provingKeySha256":"c713b515a2caaa10129aaf32862eaf1f791531d2f0ededcdf8532cc5aae5ce71","verificationKey":"Qmb9K98pEGjW9F8utif3p55jzDrpg3Uzt1k8BxnuSfGrAP","verificationKeySha256":"a1ea01f4164790f6073f93d0f7875b8fba536373ad441fa7db08d6539dc09a0d"},"transact_2x4":{"wasm":"QmWmTFCKyTNKkZB9FJBUBsysQkpwWzYFpXZrbLu2takMFG","wasmSha256":"fe2ae55994b8cca10f27d821ca9551507351cac6960c435e6cca9d643df6a749","provingKey":"QmeYshTAGnkcNd7dLcvSy1VxfwNNnWQw6PFmnfX24P5jQZ","provingKeySha256":"a7ca0b0fbe6fb057d288d504aefdf58efae82dddfcb9c53055f7c1016c8455db","verificationKey":"QmZ1VRBgPF9tcYiKWwrCBndYEYi9ADH6uQ738yuTkEzRxQ","verificationKeySha256":"39da36ea93eadc618934f63028e44f2f7d2ce0019d5e123e46351ccf0abe74bb"},"transact_2x5":{"wasm":"QmQJdT6WVZjGopELtWZKXNSEzSBgNizPjMh9dG4FysN3CJ","wasmSha256":"c3e4aab1bc435fd6a4dbbd18c4f26a38efba01412e1f8e675aa2d6ba82fc62ce","provingKey":"QmYqAUJ3sjtbbKtmXuQuiVCBwsfg2x9yuDDH7qJR9AzDMT","provingKeySha256":"c26d09d6c257998d9a71c254ebb2081557e12047db40bc7bd1352bb8177aa588","verificationKey":"QmY8qxktGku4rZDKMyaUNJgksWTyJGRhxAxB9yVQjgvDz3","verificationKeySha256":"d8c7afa6e39bfdedcb3cad4dcc525f1b8aa9e31058c3810df6d17e7dc209b922"},"transact_3x1":{"wasm":"QmNvWa2CbCwETuCn8nJhGTYuV23X5P6D1HjHKvZsNH6c1c","wasmSha256":"eac116e10e378f20d5e21d2bba6cd202e0a74706be3a21582b7681b9d197bc63","provingKey":"QmNQSgwBV9dvqX4a61auUNENwabrvzi8jH1Zq9ekyRqztG","provingKeySha256":"fb8088772dc632cae1fe10e5eb91138364c7769641684efa75491cfc68c9c940","verificationKey":"QmS6AErmyaXRoXw8E5XzWBBGQRi4wwXbr97kwgRDRzctEX","verificationKeySha256":"eec06c6c929c97db7ad7824d0ed6c52bb786a760362e063b8375810c0389236d"},"transact_3x2":{"wasm":"QmQc3n5zGPHZGq3nCqPd94QChQFam86GcfEj7ojWmH8p1X","wasmSha256":"6b195b1419c9ff97e66958d694c0441aa4a9d44afa09bccb43ed1a6a5addcbfa","provingKey":"QmTpuhSmXSovjXc7i8sgc5K6ygQife8hZNxJnXUKHHJT28","provingKeySha256":"8e7e260ee5fd54eb8a7de7836a2747487078096d5acd65bdccd806468521bc64","verificationKey":"QmVdCWHT1ybdA4pMSMLtjBHnzUdWLZ9FKi12zVB7hKqbwn","verificationKeySha256":"d1232a8bf31390df81f9a65df4f524c40b19430f3b703842f76b76bce0f403a0"},"transact_3x3":{"wasm":"Qmcw59WSBfL3spdia8cyX5QhFJCjW8rPpHPkNQryCSuVhz","wasmSha256":"2d4fb8533f62944433ebb58063172ee112580f419291b222037ec7c4e8542552","provingKey":"QmS93hHQnpAsYPQG7Jiw2zWJBS5HwzzVHn3JE4KS29cge8","provingKeySha256":"aa6d8ba5aa947a773c68c93ba575007c5b4f6dce3c6dbafca4284a365a013159","verificationKey":"QmPZM7fgpTds5xocL9pcKy2zKtG5MopstXJcpUe2V14mPJ","verificationKeySha256":"d1a0bcc9c52e92d13aa84d4bee51a02e4808779015a5e45ddcdab97c2e9d2fd6"},"transact_3x4":{"wasm":"QmboCMo6BrSDWcpAPWnZCW2aj25y4eKRwQbM3h7zf4CZi9","wasmSha256":"66e48b0228c1c54ce720b9b2cf8ec0ac0c8ce877fc4806323e58c7b6bfff23fd","provingKey":"QmTfzhkm2vQWFMSvHbRScfCNDbZa1v5p6NNqCYsaHPTMTJ","provingKeySha256":"f01bf123b98e827efda24ca17f620904ad31b79bd1730b9d2e60c119a425a406","verificationKey":"QmfXbSExDAzCej8PREQEo5c5Dea4to7T5cQVGwzbnDQXnF","verificationKeySha256":"9be6797e352e4e2b0f7a5ea3f4419555aca61abbc157dddd21c1ab8fa1eaa27a"},"transact_3x5":{"wasm":"QmQZiYCCNEBD7KfHdChDt8ynMEsppi3SiM5ARiZqdca6aM","wasmSha256":"6f9dad7ebae38dec783bea9a9bd30059739a9cbce0591a3699d4415f2b723927","provingKey":"QmcodnexWuqmPhTjWTEVZuBkgQzCdvtG44BTHYXj3XELxY","provingKeySha256":"f64f99b2f7e4cdc5069f6b3dd9ebd9b903b14dc53fcf197a53317998312a3345","verificationKey":"QmPc9UvfyYRv4UcM5xvJgMb5z5qyQpmMt7EwVAXmdnJ1jW","verificationKeySha256":"76ce8edf07ec6ada81ebb14f0c2a37c7d2af1ca076c432274433b83dde6971c6"},"transact_4x1":{"wasm":"QmPUqbuZfj23dDNH8PEF5kT3Fkr4yrzEhF7vZf6Jt5ryj3","wasmSha256":"750789200ed6a56222cf99c80af9ddccaa76081745375a008b0daa7f93345ac1","provingKey":"QmWtXsV6WCAHgME8ebxaeoV2Rd9HHFTcHD7beVXZT7tnpg","provingKeySha256":"848392fb4a9f17b40f26ef03a166e4e8bf47b9fe0ca6abf28c9fc75130324f9e","verificationKey":"Qme4sqejTEH8dP7u6XJ9rPVuAey2XaXC6A4qHeJi8DY76M","verificationKeySha256":"23df18b1458bce6c3d0548a19b2b190b1a189e18404f3eb5948208d07646a7ef"},"transact_4x2":{"wasm":"Qme6URSD5ndGEN7ApHyPzqAk9sh2Xn1DLq67aarVjmTACN","wasmSha256":"04aa1d270a361fbc7dc97d67204ec661599a70b9306739ae4b242a2b7e1cf086","provingKey":"QmZLyCwrMcfRwBkVEJasKjVxmLXJPuDsfxZUPJrnBLQygc","provingKeySha256":"46fdf80212238d9c29bf4b1d07c9388eef5acdf1d7fa9a39facb52fa13709870","verificationKey":"QmeRVAqhopEjhQoJ7PTRDtnR1DUViGmUaskzSxrSBLMkhj","verificationKeySha256":"7b0812c2eb2c06762f2c87bb2da39567274c300db13cf23f53f6e67e8b8f0d37"},"transact_4x3":{"wasm":"QmP3QzYZL1sWeZdPz8xSkSTvEhBF9mNZL1qs5jAXM3pjD4","wasmSha256":"34e52ec95243118e558985eb6e671f0c03cac2feac517125f7a12eb3c85f5b37","provingKey":"QmT951angX69LcajUQvjfyv4sDmmwfHTLEztgTUezi7UCa","provingKeySha256":"eea45acc23672f44c772a82801fad75f534f78e89af5530db6077bb1eb486998","verificationKey":"QmeyWrDGPNqTKSxJxcAtGVrAaPsFLaM6yXBHBniGbqW7V6","verificationKeySha256":"cf41e31009b034ec296220e7ea08f8f9b4d3c2b78d4bb11434a2f41c62c59913"},"transact_4x4":{"wasm":"QmSQzARopjufLCiJJm7UwoQesBykfAPp3hgggoNexvT9Xj","wasmSha256":"9d300515c9d1eb894ba14de0d336602c5abfcf8dc3aba058fb80e94be63e8278","provingKey":"QmZ9aRCDKVXhbyXqnnkwhc81tCXZjEcjGgvwCeTRDt7YYj","provingKeySha256":"6eac71fe752e456a6796499608174bd4a43e103a4e6236f1d4cf00d1581fd114","verificationKey":"QmarUMB5vVxeFarf3bn4vNx4e7voP9YvuiMzVuF7fq2DS1","verificationKeySha256":"31e31961239ae864e6c2f9a36d8aa8b719fb6e6dee28f0b916e071f7d255c476"},"transact_4x5":{"wasm":"QmdvSCBYp8KmQn1fXoXVCoSNnRK48YW3tPugwbu4cmqtst","wasmSha256":"6b0fa46c5281c542cdd03967a61e35be33b5b26368d1e0c0758c8e760a4f336d","provingKey":"QmevaJ6MBUbAKgRu5aeRquPfURE8iCH3MTLnZh5o3TGQVm","provingKeySha256":"11a537dd541eb978ec62a000c0603fecc5a977d68b23714dd0f5c0b280dc0320","verificationKey":"QmcZqn1otFFLsHhYYc3B6U7HH1Kg4vrSUPd2w3yqtfpYLe","verificationKeySha256":"c914523b571766f6e9b2476e6f2ec626f09cffcdcf1f67736f80b83b1e5c227a"},"transact_5x1":{"wasm":"QmSLhAjbPvZnmsKw6rdFKLkxSRRybQ7qC9ad4tJc71sCZD","wasmSha256":"97bcc3a093377fb05284c1fa4f4bf767cd31ff65b37a9939e3bf11490c2f3ea5","provingKey":"QmR3hcRgSAVDoLMd4S9653HFAHk1MhnwBGWPY9J2Qs8kEj","provingKeySha256":"ce4d5c3262e75cd62a13981ec296d20cd02c636f05b708041add8662e1b4ff4f","verificationKey":"QmZo9os8UUB4Q4qjDUh1U47w6gSEDNfPWWim8DrLaypiwk","verificationKeySha256":"257bcbe7d6f2d7b34e6b85b588bd735a644d3692239f90709ec473dd7e5b91d6"},"transact_5x2":{"wasm":"QmafBCp4q6JBi32nf3mh9vRQweawDUinsnbE22LucwNdpX","wasmSha256":"0f17ff4ef508e5270445d8e31ba02a62e2f3a2641315de1fa3fc867d0204d3f3","provingKey":"QmSKkMCAQtocRa7fPALqjZZQV3LasANWmXijHedkyvq5Ry","provingKeySha256":"6ecc00526cbd5853f2d3403235260e60c4c01912c4d06a9b857a39ab14ca37a0","verificationKey":"QmbEvCLzYCBkSGeyKHWrB7NubZhNcPcq3uSjiTu6KZNVRH","verificationKeySha256":"1e20af3646579b56fae94a5f392eec5191ceb70cd4743759fa7d0fa0763d8e38"},"transact_5x3":{"wasm":"Qmef2WUpyDhR5D7zKfuL1E5B74j6aULwy8LMjPoTqG7T8s","wasmSha256":"d81f31dbdf4fc280b0ef623aa59f7f9de654d5c823ddbf42a2887a48e867edfe","provingKey":"QmT2U9WHbbQEYTngAG3gMzwvrapQLQkFA9tewLUpB4bpfi","provingKeySha256":"ceb8bec785c9fef33ce420f104ae81edf838880eff9eca879ece98abef028bea","verificationKey":"QmcU2FE2x5eCriztMbJk1N7GaA3TN8Xru4FJiNHEGudzyJ","verificationKeySha256":"280fd06395ef063acef95fd1d65c82a9be5bb07242873a80c37678dd48626c35"},"transact_5x4":{"wasm":"QmVCaAbfa2X3kKwSdspdWsbxaymk9KGnR3CqD7M3sP5ysm","wasmSha256":"919b0f67f716b3ea8ad0ea193d99a780a9d0fea1f4061eab9a2a19002970ea73","provingKey":"QmcqjypfSkMjwwgAGEBhg6vv8jZBWfMwDKJs1sSg5syjSU","provingKeySha256":"887189fd878d023ed1d4af3ef4fb375224a81a890adc42283bdba6f2efb3aeb4","verificationKey":"QmSHCy7CEUsGJzbz51M1PDUQbK95DKAMPu78BXAUedEFBr","verificationKeySha256":"d39e30582223d89efb4811e95e79584061e7b4a8ab3ce9f6665162d6cacedfc0"},"transact_5x5":{"wasm":"QmT75hGWy2nHwzKytai279ZjAATiry6azbh2zra8dH7rva","wasmSha256":"b6c7632afb0624f09f1bd1c0a75e345a105a00e48ad4b545c03085292e37a188","provingKey":"QmcBjkr4V7cr1mygwcQHS2cE7LM1joTQ1UV5WsvEuH5GWQ","provingKeySha256":"b9bd7851765a209ed74456492b94e5b9f8d57b0899aa0f52113035761ee752ba","verificationKey":"QmbqqapZKBeQgCFuLUMwTLSTp5qQenRuTwyxZdrCMqWi61","verificationKeySha256":"3f3dde610b5ade3ffb10b2fb0b716c717ddc1f90b1811dc1aaada9437f869cfe"}}');
|
|
14212
|
-
let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2'), POOL_ADDR = '0x0Eb42804BF897662aF851370eaeAdcDBEC1b97ed', KEYSTORE_ADDR = '0x6E463391c79b7e1A88eF26E0B023f9A6C9938a71', ASP_REGISTRY = '0x259C0BEa1d783c202509BD3b2688d23b8AEf58B0', ENTRYPOINT_ADDR = '0xca1e072236D231130059eeA6Bfceb7F4e9a1F0C3',
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14450
|
+
]), payoutRouting = (r)=>ROUTING.payoutRouting.encodeInput(r).slice(4), decodePayoutRouting = (data)=>ROUTING.readRouting.decodeOutput(data), account_MISSES = 10, account_spendable = (a)=>a.note.value > 0n && !a.ragequit && !a.lost, noteCommitment = (owner, n)=>crypto_commitment(v2_crypto_precommitment(crypto_noteAddressHash(owner, n.noteSecret), n.tokenId, n.value), n.label);
|
|
14451
|
+
circuit_artifacts_namespaceObject = JSON.parse('{"deposit":{"wasmSha256":"833e7b3c44a900a95496009a36284e11f57ba0385fab6b63f92075750817550a","provingKeySha256":"e6fb5283c7b7511b0422a773d9f054925969e47e8ddf55a6b38b590c951a73a4","verificationKeySha256":"923f71ca381d6f8ee07c18807f738c4b2617494388efc4b1f914c3253f01da86"},"ragequit":{"wasmSha256":"95108046f922d9cb08a1d4e42c88708af03233551a5e13a7118d7a6eff5d31c4","provingKeySha256":"044abe871b1b79fecb6b4ca6128d08a142d7ce8665f439032953bae92f6ab076","verificationKeySha256":"ea987f112952f0eda4acd5cfe76ea6a3e8114467b1159207b1aedd8b1c631913"},"transact_1x1":{"wasmSha256":"bd13ab4130320f095cdee83b42e27877fc6c17f18be3fbdfc55436d33689d262","provingKeySha256":"e92ad88f417c034f073580658839b64fdd1ad3c89a86a9faa926728f80351121","verificationKeySha256":"6541ab63bd3859452637989aabfc62949b94952bcdc9dd70ef1d38a4e838c155"},"transact_1x2":{"wasmSha256":"71ffcdc53e5808c89ebf735ef45d0ffabfce9e6f640d565adc4f02e36ad1a72e","provingKeySha256":"996b738388d50b8e85fa1c84b0733ac70ad3c2f320e226037d91ad8c8bf1335f","verificationKeySha256":"9d272d508ac04695a99cd89fa93e5fcc979fb8ad9a8db919ea28afd3de7e277e"},"transact_1x3":{"wasmSha256":"730ae4756ba37489137ac82e117e1169f6cc8137a17f4733c779dddc69de1158","provingKeySha256":"6e6e697f672a35770d2d9f49588bc841b943ff7c10a6afed07b6627d5f62fd3f","verificationKeySha256":"f755f07f5e281e04bb16214b7ad0a8ddb8cf4fb0bf18093ad97962bdab38614e"},"transact_1x4":{"wasmSha256":"9da4a23f8fdf1bd22db6f2a06ee3b26d6058451eecf0fba99707df14bd7d5d4f","provingKeySha256":"5ddee0a56c6ffc09c3f1f4ac4be78fe54b5c2b626a922eaec14e848558f91542","verificationKeySha256":"68aba7cc58d9012d2fb61d6db6c2f31577996e204c334ace0a9893f48697fbdb"},"transact_1x5":{"wasmSha256":"d18ce1511bc8a3e80229381e7b3b2f226106fc044579b2460a3bf2d4dcfe415e","provingKeySha256":"eeb45b1fd355d87a4975341b70982f993215370efec45c8b13bb065c6d9145c1","verificationKeySha256":"d6cf1310f5de3c90735de976f3fe07f8e22d435043fe68aab80cef822b8f6b09"},"transact_2x1":{"wasmSha256":"a1fa16ad0824fe40df716e8bfd0716effad68dcb1ce81f108db596e6a752f15c","provingKeySha256":"3afe537fd4762cb6957f1c8532049879a4f29ed7c54ef893a8299dabf68d9ea5","verificationKeySha256":"eac99f1b7cdf1ee7949a6288151278565af02ee14cec10f0f16ed9aa59302781"},"transact_2x2":{"wasmSha256":"578a1241233edffba81ca58c2fd0af48aa6434bd5a667caf02a5e3393a1b3664","provingKeySha256":"2083cba8cbeba5eb56756331fc01ce1849ebbec7bc64aaeb7a58a7417264f391","verificationKeySha256":"71f00aab9752367a94373831c17e8227dd538dfb1bbc3226d5fa0359746a0f32"},"transact_2x3":{"wasmSha256":"54b9f706c15eb91ea8b2012c6ebac1eb6b4e1a4ff8ce299d039aaeda57e52ff5","provingKeySha256":"b22cc9171ce8c86b00aa95d095c4ed9eb9d5a97df1e2c2d5ee3257b37946b28f","verificationKeySha256":"41fba209a25f2884d7fa998f4657276206cd7ce07cb5cf2ac39a9b690fae4586"},"transact_2x4":{"wasmSha256":"fe2ae55994b8cca10f27d821ca9551507351cac6960c435e6cca9d643df6a749","provingKeySha256":"b816f6391e06595e714840d66f59a8757541f7eb3160fc92e78275ffad544ccd","verificationKeySha256":"801a32a20f19315ecc070e56ff0f8c7ea3afecb95ab16efecbfa9e71a86e0301"},"transact_2x5":{"wasmSha256":"c3e4aab1bc435fd6a4dbbd18c4f26a38efba01412e1f8e675aa2d6ba82fc62ce","provingKeySha256":"259a99de8620a1020680a3eb501b9f2c489cd2a6a0abff0d68967eb76ce937f0","verificationKeySha256":"593167b2c4eac43b237f6ee9814e7ebe5e02ff91fe9002b3bda84c5e0a0f51e1"},"transact_3x1":{"wasmSha256":"eac116e10e378f20d5e21d2bba6cd202e0a74706be3a21582b7681b9d197bc63","provingKeySha256":"cb03d64333509767bf1a7cff131e2d790f15afe9dfd74e942398e451d24f754e","verificationKeySha256":"01d1c8b0bd42e549d3f726a722056e1d3339b992fd52dd1acdf99fe1794fe8c6"},"transact_3x2":{"wasmSha256":"6b195b1419c9ff97e66958d694c0441aa4a9d44afa09bccb43ed1a6a5addcbfa","provingKeySha256":"e342328a03523b693462d75e96de5da6ddf8094940007a09ab38ca394540e707","verificationKeySha256":"068fd751e29d2377b81dab01f0db806162109d5f9a998cbe152140ba8a2a81a0"},"transact_3x3":{"wasmSha256":"2d4fb8533f62944433ebb58063172ee112580f419291b222037ec7c4e8542552","provingKeySha256":"e1d7ce07915fad1d8d6562ef166a2fce981bdf211827a81f2ba3e029f7b01268","verificationKeySha256":"c221a2f3744780cb1222f5cdbedb753fbf5db07d6409bef87898afb084d8a56c"},"transact_3x4":{"wasmSha256":"66e48b0228c1c54ce720b9b2cf8ec0ac0c8ce877fc4806323e58c7b6bfff23fd","provingKeySha256":"83475261ec0e8125651e3672491d27318cec1db42cadce4cb2db7ab6b907fdc3","verificationKeySha256":"44be2e4bcd75a58ac3284100230ef6ff847850fa2203141e43b81035539b6e4a"},"transact_3x5":{"wasmSha256":"6f9dad7ebae38dec783bea9a9bd30059739a9cbce0591a3699d4415f2b723927","provingKeySha256":"f1816f47842fa384592241e962a46f3938ff8fb931c42b6c5a1021d4ff1481ab","verificationKeySha256":"cfa1576df1f77684f518577db62413be57dd03b3eb37bef2f92a7ded77e5daa2"},"transact_4x1":{"wasmSha256":"750789200ed6a56222cf99c80af9ddccaa76081745375a008b0daa7f93345ac1","provingKeySha256":"6c9a5eaea3f44de8a16de1436839721c3c1a3f92c5746719a6e1d0bf27b7fed8","verificationKeySha256":"123bd5234fe613b531e4c2a394f7c88f609139ed029817dec51b3dfef6cc1e0b"},"transact_4x2":{"wasmSha256":"04aa1d270a361fbc7dc97d67204ec661599a70b9306739ae4b242a2b7e1cf086","provingKeySha256":"211675e1dd535fd03e4ae923a13b186c28c2ba60fb1a1b502203979fc863e1cd","verificationKeySha256":"4207b3a6f096525413ddfce137fa0dfc1779af89ddd881fa9d474aea7608345b"},"transact_4x3":{"wasmSha256":"34e52ec95243118e558985eb6e671f0c03cac2feac517125f7a12eb3c85f5b37","provingKeySha256":"a9427d68a67b55a9d81c071fea3ffc52bafe4d2eadda0250c20708ab9db405d2","verificationKeySha256":"fb28caff6c39efbad62e97826314e5653a204661767a722a4f27c7e99e42c014"},"transact_4x4":{"wasmSha256":"9d300515c9d1eb894ba14de0d336602c5abfcf8dc3aba058fb80e94be63e8278","provingKeySha256":"3a8cdb10ede535c64303b198e2db9a4c8c9c5a49bb340c487a220dd64ee47c95","verificationKeySha256":"aafac3ff67eedcc985193ad7521a0ab3b7f414a4d44784d6e18ae5043a6baf8a"},"transact_4x5":{"wasmSha256":"6b0fa46c5281c542cdd03967a61e35be33b5b26368d1e0c0758c8e760a4f336d","provingKeySha256":"239041de4d4d28356afd61cffbd2b2e8909c7e843b923aed8d79c7364bda5345","verificationKeySha256":"39fe66bc2f4b593edab1d48adca7631fcda12649616c4d3eea416791f679a4a9"},"transact_5x1":{"wasmSha256":"97bcc3a093377fb05284c1fa4f4bf767cd31ff65b37a9939e3bf11490c2f3ea5","provingKeySha256":"895add3547d0d33eaae16287148a1596fc9ca6d61a7a5cdfc3461c1633e8736f","verificationKeySha256":"b798641ce2b9c702ce11449f051d8f936e328812695504fda4929f164a765d1d"},"transact_5x2":{"wasmSha256":"0f17ff4ef508e5270445d8e31ba02a62e2f3a2641315de1fa3fc867d0204d3f3","provingKeySha256":"e2f5f69e7365e63329fc840974b4a6b0c13553b9829dc4c95f45fd71fbc86baa","verificationKeySha256":"3c5e01915d911b871f6f0842282f104a0fded5c3bf62f7f847ba1dfda8e510e9"},"transact_5x3":{"wasmSha256":"d81f31dbdf4fc280b0ef623aa59f7f9de654d5c823ddbf42a2887a48e867edfe","provingKeySha256":"c9b2d185fea95ad798a6f8be531d7d4454aa5c4a6285a8c5ec1d9d4709487020","verificationKeySha256":"18737c2c6862859010489e7f4801ed66d6987dd07e70131036136226d26d1f7e"},"transact_5x4":{"wasmSha256":"919b0f67f716b3ea8ad0ea193d99a780a9d0fea1f4061eab9a2a19002970ea73","provingKeySha256":"3f974b64a084bfa5bcf2b1f700e643ea6b7bc37e35f30e588ef6b80e21d0ef5b","verificationKeySha256":"d042860c5b0f6125370cdc308ea8216ce8b29879b0f6951248704c1b4b9ee795"},"transact_5x5":{"wasmSha256":"b6c7632afb0624f09f1bd1c0a75e345a105a00e48ad4b545c03085292e37a188","provingKeySha256":"7c70692fc7e41e7dec43159d18ca8aef73891f945e09019e4ebe5d7ea0673ed5","verificationKeySha256":"8483810134671559f8ca3f35bb0da19e51feb6bc4efa573b44099789c07e33d9"}}');
|
|
14452
|
+
let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2'), POOL_ADDR = '0x0Eb42804BF897662aF851370eaeAdcDBEC1b97ed', KEYSTORE_ADDR = '0x6E463391c79b7e1A88eF26E0B023f9A6C9938a71', ASP_REGISTRY = '0x259C0BEa1d783c202509BD3b2688d23b8AEf58B0', ENTRYPOINT_ADDR = '0xca1e072236D231130059eeA6Bfceb7F4e9a1F0C3', RELAY_ADDR = '0x01a8Fa4dbb60187aD8d3c3d08E7Fb8C14198A461', ASP_PUBLIC_KEY = '0x3f651e2321b9b78c3690064b025b610942cbf755e28d44726378cf853cfd8f34', RELAYERS = [
|
|
14453
|
+
'https://relayer-v2-prod-149184580131.us-east1.run.app'
|
|
14454
|
+
], aspApi = ()=>process.env.MONEYSURFER_ASP ?? 'https://api-v2.0xbow.io', config_NATIVE = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', isNative = (a)=>a.toLowerCase() === config_NATIVE.toLowerCase(), PP_ETH = '0x66051920D25af4E3596A8a46309F4D045F9D83B7', PP_USDC = '0xC246aFb23482fF9596E9cee5f1f678eFe0EB1ad6', PP_USDT = '0xA4cF419558Ef36CC6FfB666195684dC963910426', USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7', BNB_PP_USDT = '0x6C17bE9c864254CA4b2d36223f31AdE94B4d64c2', BNB_USDT = '0x55d398326f99059fF775485246999027B3197955', DEPLOYMENTS = {
|
|
14455
|
+
1: {
|
|
14456
|
+
deployedBlock: 25884231,
|
|
14457
|
+
native: 'ETH',
|
|
14458
|
+
rpc: CHAINS["1"].rpc,
|
|
14459
|
+
tokens: [
|
|
14460
|
+
config_NATIVE,
|
|
14461
|
+
PP_ETH,
|
|
14462
|
+
PP_USDC,
|
|
14463
|
+
PP_USDT,
|
|
14464
|
+
USDC,
|
|
14465
|
+
USDT
|
|
14466
|
+
],
|
|
14467
|
+
routers: {
|
|
14468
|
+
[PP_ETH.toLowerCase()]: {
|
|
14469
|
+
address: '0x77613D670BB9fD48A9898D0eac8ebf21B566F960',
|
|
14470
|
+
underlying: config_NATIVE,
|
|
14471
|
+
native: !0
|
|
14472
|
+
},
|
|
14473
|
+
[PP_USDC.toLowerCase()]: {
|
|
14474
|
+
address: '0xe76E793d776c1e207aD7a7fa7C57d27420d85110',
|
|
14475
|
+
underlying: USDC,
|
|
14476
|
+
native: !1
|
|
14477
|
+
},
|
|
14478
|
+
[PP_USDT.toLowerCase()]: {
|
|
14479
|
+
address: '0x13a0b86bac3e0C29bd64fED7BCD2EE84f371f41C',
|
|
14480
|
+
underlying: USDT,
|
|
14481
|
+
native: !1
|
|
14482
|
+
}
|
|
14483
|
+
}
|
|
14484
|
+
},
|
|
14485
|
+
56: {
|
|
14486
|
+
deployedBlock: 119401450,
|
|
14487
|
+
native: 'BNB',
|
|
14488
|
+
tokens: [
|
|
14489
|
+
config_NATIVE,
|
|
14490
|
+
BNB_PP_USDT,
|
|
14491
|
+
'0xc5f0f7b66764F6ec8C8Dff7BA683102295E16409',
|
|
14492
|
+
BNB_USDT
|
|
14493
|
+
],
|
|
14494
|
+
routers: {
|
|
14495
|
+
[BNB_PP_USDT.toLowerCase()]: {
|
|
14496
|
+
address: '0x9929Ad2Edc2E0B5D59C3f5b2910812D0c8b84E16',
|
|
14497
|
+
underlying: BNB_USDT,
|
|
14498
|
+
native: !1
|
|
14499
|
+
}
|
|
14500
|
+
}
|
|
14501
|
+
}
|
|
14502
|
+
}, selected = 1, config_chainId = ()=>selected, deployment = ()=>DEPLOYMENTS[selected], routerFor = (tokenId)=>deployment().routers[tokenId.toLowerCase()], config_IPFS_GATEWAYS = [
|
|
14236
14503
|
'https://gateway.pinata.cloud',
|
|
14237
14504
|
'https://dweb.link',
|
|
14238
14505
|
'https://ipfs.io',
|
|
14239
14506
|
'https://w3s.link'
|
|
14240
|
-
], CIRCUITS = circuit_artifacts_namespaceObject,
|
|
14241
|
-
wasm: 'wasm',
|
|
14242
|
-
zkey: 'provingKey',
|
|
14243
|
-
vkey: 'verificationKey'
|
|
14244
|
-
}, artifacts_path = (circuit, kind)=>join(config_ASSETS, `${circuit}.${kind}`), have = (circuit, kind)=>existsSync(artifacts_path(circuit, kind)), chain_u256 = (name)=>({
|
|
14507
|
+
], ARTIFACTS_URL = 'https://artifacts.privacypools.com/artifacts/0b62f6b7e5eb', CIRCUITS = circuit_artifacts_namespaceObject, remote = (circuit, kind)=>'wasm' === kind ? `${circuit}/${circuit}_js/${circuit}.wasm` : `${circuit}/${'zkey' === kind ? 'groth16_pkey.zkey' : 'groth16_vkey.json'}`, artifacts_path = (circuit, kind)=>join(config_ASSETS, `${circuit}.${kind}`), have = (circuit, kind)=>existsSync(artifacts_path(circuit, kind)), artifacts_current = (circuit, kind)=>have(circuit, kind) && utils_bytesToHex(sha2_sha256(readFileSync(artifacts_path(circuit, kind)))) === pinned(circuit, kind), chain_u256 = (name)=>({
|
|
14245
14508
|
name,
|
|
14246
14509
|
type: 'uint256'
|
|
14247
14510
|
}), chain_addr = (name)=>({
|
|
@@ -14809,7 +15072,7 @@ let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2')
|
|
|
14809
15072
|
ASPRootUpdated: chain_topicOf('ASPRootUpdated(uint256,bytes)'),
|
|
14810
15073
|
LabelRegistered: chain_topicOf('LabelRegistered(bytes)')
|
|
14811
15074
|
}, chain_hexNum = (n)=>`0x${n.toString(16)}`, chain_REORG_BLOCKS = 2000, chain_empty = ()=>({
|
|
14812
|
-
block:
|
|
15075
|
+
block: deployment().deployedBlock - 1,
|
|
14813
15076
|
deposits: [],
|
|
14814
15077
|
ragequits: [],
|
|
14815
15078
|
transacts: [],
|
|
@@ -14817,10 +15080,7 @@ let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2')
|
|
|
14817
15080
|
leaves: [],
|
|
14818
15081
|
keystoreLeaves: [],
|
|
14819
15082
|
aspRoots: []
|
|
14820
|
-
}), chain_cacheFile = ()=>join(config_HOME, 'cache',
|
|
14821
|
-
symbol: 'ETH',
|
|
14822
|
-
decimals: 18
|
|
14823
|
-
}, underlyingKey = (a)=>a.router ? symbolKey(a.router.underlyingSymbol, a.router.underlying) : void 0, encodeStr = (str)=>Uint8Array.from(str.split(''), (c)=>c.charCodeAt(0)), sigma16_32 = ciphers_utils_swap32IfBE(ciphers_utils_u32(encodeStr('expand 16-byte k'))), sigma32_32 = ciphers_utils_swap32IfBE(ciphers_utils_u32(encodeStr('expand 32-byte k'))), U32_EMPTY = Uint32Array.of();
|
|
15083
|
+
}), chain_cacheFile = ()=>join(config_HOME, 'cache', `${config_chainId()}-${POOL_ADDR.toLowerCase()}.json`), revive = (_k, v)=>'string' == typeof v && /^\d+n$/.test(v) ? BigInt(v.slice(0, -1)) : v, replace = (_k, v)=>'bigint' == typeof v ? `${v}n` : v, chain_aspCache = (root)=>join(config_HOME, 'cache', `asp-${config_chainId()}-${root}.json`), underlyingKey = (a)=>a.router ? symbolKey(a.router.underlyingSymbol, a.router.underlying) : void 0, encodeStr = (str)=>Uint8Array.from(str.split(''), (c)=>c.charCodeAt(0)), sigma16_32 = ciphers_utils_swap32IfBE(ciphers_utils_u32(encodeStr('expand 16-byte k'))), sigma32_32 = ciphers_utils_swap32IfBE(ciphers_utils_u32(encodeStr('expand 32-byte k'))), U32_EMPTY = Uint32Array.of();
|
|
14824
15084
|
class Poly1305 {
|
|
14825
15085
|
blockLen = 16;
|
|
14826
15086
|
outputLen = 16;
|
|
@@ -15098,7 +15358,13 @@ let poly1305 = (macCons = (key)=>new Poly1305(key), getArgs = ()=>[], (macC = (m
|
|
|
15098
15358
|
})), prover_prove = (circuit, input, threads)=>prover_prover.prove(circuit, input, threads), NO_NOTE = {
|
|
15099
15359
|
hint: `0x${'00'.repeat(32)}`,
|
|
15100
15360
|
ciphertext: new Uint8Array(0)
|
|
15101
|
-
}, msgValue = (tokenId, value, vettingFeeBPS)=>isNative(tokenId) ? value + value * vettingFeeBPS / 10000n : 0n,
|
|
15361
|
+
}, msgValue = (tokenId, value, vettingFeeBPS)=>isNative(tokenId) ? value + value * vettingFeeBPS / 10000n : 0n, CHAIN_TYPE = 'evm', RELAY = abi_createContract([
|
|
15362
|
+
{
|
|
15363
|
+
...chain_POOL_ABI["2"],
|
|
15364
|
+
name: 'relay',
|
|
15365
|
+
stateMutability: 'payable'
|
|
15366
|
+
}
|
|
15367
|
+
]), zap_u256 = (name)=>({
|
|
15102
15368
|
name,
|
|
15103
15369
|
type: 'uint256'
|
|
15104
15370
|
}), DEPOSIT_PROOF = {
|
|
@@ -15282,24 +15548,30 @@ let poly1305 = (macCons = (key)=>new Poly1305(key), getArgs = ()=>[], (macC = (m
|
|
|
15282
15548
|
} : a, commands_amountOf = (a, v)=>`${formatUnits(v, a.decimals)} ${a.symbol}`, spendOf = (a, v)=>`${formatUnits(v, units(a).decimals)} ${units(a).symbol}`, commands_MNEMONIC_FILE = join(config_HOME, 'mnemonic'), signerFor = (net, c, owner)=>c.dryRun ? Promise.resolve({
|
|
15283
15549
|
address: owner,
|
|
15284
15550
|
send: ()=>Promise.reject(Error('dry run'))
|
|
15285
|
-
}) : makeSigner(net,
|
|
15551
|
+
}) : makeSigner(net, config_chainId(), c.sig), spendUnitsNote = (a)=>a.router ? `amounts for ${a.key} are in ${units(a).symbol} -- ` : '', commands_sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms)), commands_HELP = `moneysurfer v2 -- Privacy Pools V2 from the command line
|
|
15286
15552
|
|
|
15287
15553
|
v2 setup [circuit...] fetch the circuits, check their pinned sha256
|
|
15288
15554
|
v2 init make a new seed (the one secret behind every note)
|
|
15289
15555
|
--import ... or take one on stdin
|
|
15290
|
-
--from-wallet ... or derive
|
|
15556
|
+
--from-wallet ... or derive privacypools.com's from your wallet
|
|
15291
15557
|
v2 register put this address in the Keystore -- required before spending
|
|
15292
15558
|
v2 pools every asset the Entrypoint takes: minimum, fee, notes
|
|
15293
15559
|
v2 balance your notes and what each holds
|
|
15294
15560
|
v2 sync pull the pool, keystore and ASP events into the cache
|
|
15295
15561
|
v2 deposit <asset> <amount> deposit from your wallet (a token is approved first, exactly)
|
|
15296
|
-
v2 withdraw <asset> <amount|all> <to> spend privately
|
|
15562
|
+
v2 withdraw <asset> <amount|all> <to> spend privately, through a relayer that pays the gas;
|
|
15563
|
+
<to> gets <amount> less its fee
|
|
15297
15564
|
--id N from account #N (default: the first that can)
|
|
15565
|
+
--relayer URL use this relayer instead of 0xbow's
|
|
15298
15566
|
--self | --safe SAFE submit and pay gas yourself, or have a Safe submit it
|
|
15567
|
+
<to> has to be the submitter then: the pool pays msg.sender
|
|
15299
15568
|
v2 ragequit <asset> --id N take a note back publicly, to the owning address
|
|
15300
15569
|
v2 status | trees the deployment, and both trees rebuilt from logs
|
|
15301
15570
|
|
|
15302
|
-
--
|
|
15571
|
+
--chain CHAIN ethereum (default) or bnb; each chain has its own notes.
|
|
15572
|
+
bnb needs --rpc-url: no public BNB RPC serves old logs
|
|
15573
|
+
--max-fee-percent N on withdraw, refuse a relayer fee above N% (default 1);
|
|
15574
|
+
on deposit, how far over the wrapping quote you will go
|
|
15303
15575
|
(default 0.0001, one part per million)
|
|
15304
15576
|
|
|
15305
15577
|
amounts are human units of what you spend. For a wrapped asset (usdc, usdt) a deposit spends
|
|
@@ -15308,7 +15580,8 @@ more than a dollar, so 10 USDC buys under 10 ppUSDC and falls below the minimum.
|
|
|
15308
15580
|
10.02 usdc is the real floor; the error says so with the number of the day. A withdrawal
|
|
15309
15581
|
spends the note, so its amount is in shares, and shares are what it pays out.
|
|
15310
15582
|
|
|
15311
|
-
|
|
15583
|
+
A relayer's fee is mostly the gas of the withdrawal, not a share of it, so the 1% default
|
|
15584
|
+
refuses the smallest ones; the error says what was asked.
|
|
15312
15585
|
|
|
15313
15586
|
env: MONEYSURFER_MNEMONIC, MONEYSURFER_RPC, MONEYSURFER_ASP`, cli_log = (s)=>process.stderr.write(`${s}\n`);
|
|
15314
15587
|
process.stdout.on('error', (e)=>{
|
|
@@ -15419,12 +15692,7 @@ try {
|
|
|
15419
15692
|
}
|
|
15420
15693
|
for (let { flag, why } of ({
|
|
15421
15694
|
v1: [],
|
|
15422
|
-
v2: [
|
|
15423
|
-
{
|
|
15424
|
-
flag: 'chain',
|
|
15425
|
-
why: 'V2 is one deployment on Ethereum mainnet'
|
|
15426
|
-
}
|
|
15427
|
-
]
|
|
15695
|
+
v2: []
|
|
15428
15696
|
})[protocol])if (void 0 !== v[flag]) throw new config_UsageError(`${protocol} takes no --${flag}: ${why}`);
|
|
15429
15697
|
rpcOverride = v['rpc-url'];
|
|
15430
15698
|
let threads = void 0 === v.threads ? availableParallelism() : Number(v.threads);
|