moneysurfer 0.1.2 → 0.2.1
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 -4
- package/dist/cli.js +549 -301
- 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);
|
|
@@ -4395,7 +4378,7 @@ function chain_writeCache(file, json) {
|
|
|
4395
4378
|
}), writeFileSync(`${file}.tmp`, json), renameSync(`${file}.tmp`, file);
|
|
4396
4379
|
}
|
|
4397
4380
|
async function sync(net, log) {
|
|
4398
|
-
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(
|
|
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);
|
|
4399
4382
|
ev.deposits = keep(ev.deposits), ev.ragequits = keep(ev.ragequits), ev.transacts = keep(ev.transacts), ev.notes = keep(ev.notes);
|
|
4400
4383
|
let addresses = [
|
|
4401
4384
|
POOL_ADDR,
|
|
@@ -4498,7 +4481,7 @@ async function chain_aspSet(net, log) {
|
|
|
4498
4481
|
return save(tree), done(tree, `IPFS ${cid} via ${gw}`);
|
|
4499
4482
|
} catch {}
|
|
4500
4483
|
log?.(`no IPFS gateway served ${cid}; asking the ASP's API instead (it sees your IP, not your notes)`);
|
|
4501
|
-
let url = `${aspApi()}/association-set/leaves?chainId
|
|
4484
|
+
let url = `${aspApi()}/association-set/leaves?chainId=${config_chainId()}&entrypoint=${ENTRYPOINT_ADDR}`, res = await fetch(url, {
|
|
4502
4485
|
signal: AbortSignal.timeout(60000)
|
|
4503
4486
|
});
|
|
4504
4487
|
if (!res.ok) throw Error(`${url}: HTTP ${res.status}`);
|
|
@@ -4507,7 +4490,10 @@ async function chain_aspSet(net, log) {
|
|
|
4507
4490
|
return save(tree), done(tree, url);
|
|
4508
4491
|
}
|
|
4509
4492
|
async function tokenMeta(net, token) {
|
|
4510
|
-
if (isNative(token)) return
|
|
4493
|
+
if (isNative(token)) return {
|
|
4494
|
+
symbol: deployment().native,
|
|
4495
|
+
decimals: 18
|
|
4496
|
+
};
|
|
4511
4497
|
let [symbol, decimals] = await Promise.all([
|
|
4512
4498
|
rpc_read(net, token, v2_chain_ERC20.symbol),
|
|
4513
4499
|
rpc_read(net, token, v2_chain_ERC20.decimals)
|
|
@@ -4518,7 +4504,7 @@ async function tokenMeta(net, token) {
|
|
|
4518
4504
|
};
|
|
4519
4505
|
}
|
|
4520
4506
|
async function assets(net) {
|
|
4521
|
-
let found = await Promise.all(
|
|
4507
|
+
let found = await Promise.all(deployment().tokens.map(async (tokenId)=>{
|
|
4522
4508
|
let [meta, cfg] = await Promise.all([
|
|
4523
4509
|
tokenMeta(net, tokenId),
|
|
4524
4510
|
rpc_read(net, ENTRYPOINT_ADDR, chain_ENTRYPOINT.assets, tokenId)
|
|
@@ -4623,6 +4609,95 @@ async function buildDeposit(p) {
|
|
|
4623
4609
|
proof
|
|
4624
4610
|
};
|
|
4625
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
|
+
}
|
|
4626
4701
|
async function zap_quote(net, router, value, ppm) {
|
|
4627
4702
|
let q = await rpc_read(net, router, ROUTER.quote, value);
|
|
4628
4703
|
return {
|
|
@@ -4655,8 +4730,12 @@ async function assertRouter(net, router, vault, entrypoint) {
|
|
|
4655
4730
|
if (gotEntrypoint.toLowerCase() !== entrypoint.toLowerCase()) throw new config_UsageError(`router ${router} deposits into ${gotEntrypoint}, not ${entrypoint} -- refusing to use it`);
|
|
4656
4731
|
}
|
|
4657
4732
|
async function commands_connect() {
|
|
4658
|
-
let net = rpc(
|
|
4659
|
-
|
|
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;
|
|
4660
4739
|
}
|
|
4661
4740
|
function commands_saveMnemonic(words) {
|
|
4662
4741
|
mkdirSync(dirname(commands_MNEMONIC_FILE), {
|
|
@@ -4682,7 +4761,7 @@ async function commands_init(o) {
|
|
|
4682
4761
|
}
|
|
4683
4762
|
if (o.fromWallet) {
|
|
4684
4763
|
var address, address1;
|
|
4685
|
-
let signer = await makeSigner(await commands_connect(),
|
|
4764
|
+
let signer = await makeSigner(await commands_connect(), config_chainId(), o.sig);
|
|
4686
4765
|
v2_commands_log(`asking ${signer.address} to sign the secret-derivation message, twice ...`);
|
|
4687
4766
|
let typed = (address = signer.address, {
|
|
4688
4767
|
types: {
|
|
@@ -4731,19 +4810,19 @@ async function commands_init(o) {
|
|
|
4731
4810
|
await signer.signTyped(typed)
|
|
4732
4811
|
];
|
|
4733
4812
|
if (a !== b) throw Error('the wallet signed the same message differently twice; it cannot derive a stable seed');
|
|
4734
|
-
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.');
|
|
4735
4814
|
return;
|
|
4736
4815
|
}
|
|
4737
4816
|
let words = generateMnemonic(english_wordlist, 256);
|
|
4738
4817
|
commands_saveMnemonic(words), v2_commands_out(words);
|
|
4739
4818
|
}
|
|
4740
|
-
async function commands_account(net, c) {
|
|
4819
|
+
async function commands_account(net, c, as) {
|
|
4741
4820
|
let root = function() {
|
|
4742
4821
|
let m = process.env.MONEYSURFER_MNEMONIC ?? (existsSync(commands_MNEMONIC_FILE) ? readFileSync(commands_MNEMONIC_FILE, 'utf8') : void 0);
|
|
4743
4822
|
if (!m) throw new config_UsageError('no seed -- run `moneysurfer v2 init` first, or set MONEYSURFER_MNEMONIC');
|
|
4744
4823
|
if (!validateMnemonic(m.trim(), english_wordlist)) throw new config_UsageError('the seed is not a valid BIP-39 phrase');
|
|
4745
4824
|
return mnemonicToEntropy(m.trim(), english_wordlist);
|
|
4746
|
-
}(), owner = c.safe ?? c.sig.from ?? (await makeSigner(net,
|
|
4825
|
+
}(), owner = as ?? c.safe ?? c.sig.from ?? (await makeSigner(net, config_chainId(), c.sig)).address;
|
|
4747
4826
|
return {
|
|
4748
4827
|
keys: function(rootSecret, revocableKeyIndex = 0n) {
|
|
4749
4828
|
var salt;
|
|
@@ -4778,11 +4857,11 @@ async function commands_setup(which) {
|
|
|
4778
4857
|
'zkey',
|
|
4779
4858
|
'vkey'
|
|
4780
4859
|
]){
|
|
4781
|
-
if (
|
|
4860
|
+
if (artifacts_current(c, kind)) {
|
|
4782
4861
|
v2_commands_log(`have ${c}.${kind}`);
|
|
4783
4862
|
continue;
|
|
4784
4863
|
}
|
|
4785
|
-
v2_commands_log(
|
|
4864
|
+
v2_commands_log(`${have(c, kind) ? 'replacing an out-of-date' : 'downloading'} ${c}.${kind} ...`);
|
|
4786
4865
|
let bytes = await fetchArtifact(c, kind);
|
|
4787
4866
|
v2_commands_log(` ${bytes.length} bytes, sha256 ${pinned(c, kind)} matches`);
|
|
4788
4867
|
}
|
|
@@ -4800,7 +4879,7 @@ async function commands_poolsCmd() {
|
|
|
4800
4879
|
async function v2_commands_balance(c) {
|
|
4801
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, [
|
|
4802
4881
|
...new Set(all.map((a)=>a.tokenId))
|
|
4803
|
-
], ev);
|
|
4882
|
+
], ev, config_chainId());
|
|
4804
4883
|
if (!accounts.length) return v2_commands_log(`no notes found for this seed at ${owner}`);
|
|
4805
4884
|
let asp = await chain_aspSet(net, v2_commands_log), registered = await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.nullifyingKeys, owner) !== 0n;
|
|
4806
4885
|
v2_commands_out(`${owner}${registered ? '' : ' NOT REGISTERED -- `moneysurfer v2 register` before spending'}`);
|
|
@@ -4844,7 +4923,7 @@ async function register(c) {
|
|
|
4844
4923
|
})
|
|
4845
4924
|
}), !calls.length) return v2_commands_log('already registered; nothing to do');
|
|
4846
4925
|
if (0n !== nullifying && nullifying !== wantNullifying) throw new config_UsageError(`${owner} is registered with a different nullifying key (${hex32(nullifying)}). That is another seed's account -- registering again would orphan its notes`);
|
|
4847
|
-
if (v2_commands_log('this is public:
|
|
4926
|
+
if (v2_commands_log('this is public: anyone can see this address registered with Privacy Pools, but not its deposits or withdrawals'), c.safe) return proposeCalls(net, c, calls, 'the registration');
|
|
4848
4927
|
let signer = await signerFor(net, c, owner);
|
|
4849
4928
|
for (let call of calls){
|
|
4850
4929
|
if (await commands_simulate(net, signer.address, call), c.dryRun) {
|
|
@@ -4912,7 +4991,7 @@ async function v2_commands_deposit(key, amountArg, c) {
|
|
|
4912
4991
|
}
|
|
4913
4992
|
let ev = await sync(net), { nextIndex } = account_recover(keys, root, owner, [
|
|
4914
4993
|
asset.tokenId
|
|
4915
|
-
], 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) {
|
|
4916
4995
|
let tok = BigInt(tokenId).toString(16).padStart(64, '0'), found = [];
|
|
4917
4996
|
for (let { data } of q.queued)for(let i = data.indexOf(tok); -1 !== i; i = data.indexOf(tok, i + 1)){
|
|
4918
4997
|
let before = data.slice(i - 64, i), after = data.slice(i + 64, i + 128);
|
|
@@ -4924,13 +5003,13 @@ async function v2_commands_deposit(key, amountArg, c) {
|
|
|
4924
5003
|
return found;
|
|
4925
5004
|
}(queue, asset.tokenId) : [], index = nextIndex.get(asset.tokenId.toLowerCase()) ?? 0n;
|
|
4926
5005
|
for(;;){
|
|
4927
|
-
let s = crypto_depositSecrets(root, asset.tokenId, index);
|
|
5006
|
+
let s = crypto_depositSecrets(root, asset.tokenId, index, config_chainId());
|
|
4928
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;
|
|
4929
5008
|
index++;
|
|
4930
5009
|
}
|
|
4931
5010
|
let fee = value * asset.vettingFeeBPS / 10000n;
|
|
4932
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}`);
|
|
4933
|
-
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();
|
|
4934
5013
|
v2_commands_log(`proving on ${c.threads} threads ...`);
|
|
4935
5014
|
let dep = await buildDeposit({
|
|
4936
5015
|
owner,
|
|
@@ -5041,13 +5120,13 @@ async function commands_simulate(net, from, call, asset) {
|
|
|
5041
5120
|
throw new config_UsageError(`it would revert, nothing was sent: ${why}`);
|
|
5042
5121
|
}
|
|
5043
5122
|
async function commands_spendNonce(net, safe, a, privateNullifyingKey) {
|
|
5044
|
-
let q = await safeQueue(net,
|
|
5123
|
+
let q = await safeQueue(net, config_chainId(), safe), same = queuedWith(q, nullifier(privateNullifyingKey, a.note.commitment));
|
|
5045
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);
|
|
5046
5125
|
}
|
|
5047
5126
|
async function proposeCalls(net, c, calls, what, at) {
|
|
5048
|
-
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];
|
|
5049
5128
|
if (c.dryRun) {
|
|
5050
|
-
let { safeTxHash } = await prepareSafeTx(net,
|
|
5129
|
+
let { safeTxHash } = await prepareSafeTx(net, config_chainId(), safe, call, nonce);
|
|
5051
5130
|
v2_commands_out(JSON.stringify({
|
|
5052
5131
|
safe,
|
|
5053
5132
|
safeTxHash,
|
|
@@ -5057,11 +5136,11 @@ async function proposeCalls(net, c, calls, what, at) {
|
|
|
5057
5136
|
}, null, 2));
|
|
5058
5137
|
return;
|
|
5059
5138
|
}
|
|
5060
|
-
let signer = await makeSigner(net,
|
|
5139
|
+
let signer = await makeSigner(net, config_chainId(), c.sig);
|
|
5061
5140
|
v2_commands_log(`proposing ${what} to Safe ${safe} as ${signer.address}${calls.length > 1 ? ', batched with the approval' : ''}`);
|
|
5062
5141
|
let { safeTxHash, queue } = await proposeSafeTx({
|
|
5063
5142
|
net,
|
|
5064
|
-
chainId:
|
|
5143
|
+
chainId: config_chainId(),
|
|
5065
5144
|
safe,
|
|
5066
5145
|
signer,
|
|
5067
5146
|
call,
|
|
@@ -5069,23 +5148,49 @@ async function proposeCalls(net, c, calls, what, at) {
|
|
|
5069
5148
|
});
|
|
5070
5149
|
v2_commands_log(`proposed ${safeTxHash} at nonce ${nonce}; the owners confirm and execute it at ${queue}`);
|
|
5071
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
|
+
}
|
|
5072
5179
|
async function commands_withdraw(key, amountArg, to, v, c) {
|
|
5073
|
-
var signals;
|
|
5074
|
-
let tail;
|
|
5075
5180
|
if (!key || !amountArg || !to) throw new config_UsageError('usage: moneysurfer v2 withdraw <asset> <amount|all> <recipient>');
|
|
5076
5181
|
if ([
|
|
5077
5182
|
v.relayer,
|
|
5078
5183
|
v.self,
|
|
5079
5184
|
c.safe
|
|
5080
5185
|
].filter(Boolean).length > 1) throw new config_UsageError('--relayer, --self and --safe are exclusive');
|
|
5081
|
-
if (
|
|
5082
|
-
|
|
5083
|
-
or --safe SAFE to have a Safe submit it.`);
|
|
5084
|
-
let recipient = flags_checksummed(to), net = await commands_connect(), asset = pickAsset(await assets(net), key), { keys, root, owner } = await commands_account(net, c);
|
|
5186
|
+
if (c.owner && !c.safe) throw new config_UsageError('--owner needs --safe: it names whose notes the Safe spends');
|
|
5187
|
+
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, c.owner);
|
|
5085
5188
|
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`);
|
|
5189
|
+
let signer = relayed ? void 0 : await signerFor(net, c, owner), processor = relayed ? RELAY_ADDR : c.safe ?? signer.address;
|
|
5190
|
+
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.`);
|
|
5086
5191
|
let ev = await sync(net, v2_commands_log), { accounts } = account_recover(keys, root, owner, [
|
|
5087
5192
|
asset.tokenId
|
|
5088
|
-
], ev), amount = 'all' === amountArg ? 'all' : parseUnits(amountArg, asset.decimals), a = function(accounts, amount, id) {
|
|
5193
|
+
], ev, config_chainId()), amount = 'all' === amountArg ? 'all' : parseUnits(amountArg, asset.decimals), a = function(accounts, amount, id) {
|
|
5089
5194
|
if (void 0 !== id) {
|
|
5090
5195
|
let a = accounts.find((x)=>String(Number(x.index) + 1) === id.replace(/^#/, ''));
|
|
5091
5196
|
if (!a) throw new config_UsageError(`no account #${id} (see: moneysurfer v2 balance)`);
|
|
@@ -5116,126 +5221,177 @@ async function commands_withdraw(key, amountArg, to, v, c) {
|
|
|
5116
5221
|
}(state, commitmentLeaf(a.note.commitment, timestamp)), function(set, lbl) {
|
|
5117
5222
|
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`);
|
|
5118
5223
|
}(asp, a.label);
|
|
5119
|
-
let
|
|
5120
|
-
recipient,
|
|
5121
|
-
feeRecipient: recipient,
|
|
5122
|
-
feeAmount: 0n,
|
|
5123
|
-
nativeGas: 0n
|
|
5124
|
-
}), notes = [
|
|
5224
|
+
let notes = [
|
|
5125
5225
|
NO_NOTE
|
|
5126
|
-
],
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
{
|
|
5226
|
+
], proveSpend = (amountOut, data)=>{
|
|
5227
|
+
let outputs = [
|
|
5228
|
+
{
|
|
5229
|
+
owner,
|
|
5230
|
+
noteSecret: changeSecret(root, a.label, BigInt(a.spends.length)),
|
|
5231
|
+
value: a.note.value - amountOut,
|
|
5232
|
+
label: a.label
|
|
5233
|
+
}
|
|
5234
|
+
];
|
|
5235
|
+
v2_commands_log(`proving ${transactCircuit(1, 1)} on ${c.threads} threads ...`);
|
|
5236
|
+
let t = function(account, notes, outputs, trees, { amountOut = 0n, context }) {
|
|
5237
|
+
if (!notes.length) throw new config_UsageError('a transact spends at least one note');
|
|
5238
|
+
let tokenId = notes[0].tokenId;
|
|
5239
|
+
if (notes.some((n)=>n.tokenId !== tokenId)) throw new config_UsageError('every note in one transact shares a tokenId');
|
|
5240
|
+
let inValue = notes.reduce((a, n)=>a + n.value, 0n), outValue = outputs.reduce((a, o)=>a + o.value, 0n);
|
|
5241
|
+
if (inValue !== outValue + amountOut) throw new config_UsageError(`value does not balance: ${inValue} in, ${outValue} out plus ${amountOut} withdrawn`);
|
|
5242
|
+
let perLabel = new Map();
|
|
5243
|
+
for (let n of notes)perLabel.set(n.label, (perLabel.get(n.label) ?? 0n) + n.value);
|
|
5244
|
+
for (let o of outputs){
|
|
5245
|
+
let left = perLabel.get(o.label);
|
|
5246
|
+
if (void 0 === left) throw new config_UsageError(`output label 0x${o.label.toString(16)} is not inherited from an input`);
|
|
5247
|
+
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}`);
|
|
5248
|
+
perLabel.set(o.label, left - o.value);
|
|
5249
|
+
}
|
|
5250
|
+
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'));
|
|
5251
|
+
return {
|
|
5252
|
+
circuit: transactCircuit(notes.length, outputs.length),
|
|
5253
|
+
nullifiers: notes.map((n)=>noteNullifier(n, account.privateNullifyingKey)),
|
|
5254
|
+
commitments: outputs.map((o)=>crypto_commitment(v2_crypto_precommitment(crypto_noteAddressHash(o.owner, o.noteSecret), tokenId, o.value), o.label)),
|
|
5255
|
+
input: {
|
|
5256
|
+
tokenId: BigInt(tokenId),
|
|
5257
|
+
context,
|
|
5258
|
+
value: notes.map((n)=>n.value),
|
|
5259
|
+
noteSecret: notes.map((n)=>n.noteSecret),
|
|
5260
|
+
label: notes.map((n)=>n.label),
|
|
5261
|
+
timestamp: notes.map((n)=>n.timestamp),
|
|
5262
|
+
ownerAddress: BigInt(account.owner),
|
|
5263
|
+
privateNullifyingKey: account.privateNullifyingKey,
|
|
5264
|
+
privateRevocableKey: account.privateRevocableKey,
|
|
5265
|
+
keystoreRoot: trees.keystore.root,
|
|
5266
|
+
keystoreLeafIndex: BigInt(kp.index),
|
|
5267
|
+
keystoreTreeDepth: BigInt(kp.siblings.length),
|
|
5268
|
+
keystoreSiblings: notes_pad(kp.siblings, 18),
|
|
5269
|
+
stateRoot: trees.state.root,
|
|
5270
|
+
stateLeafIndex: sp.map((p)=>BigInt(p.index)),
|
|
5271
|
+
stateTreeDepth: sp.map((p)=>BigInt(p.siblings.length)),
|
|
5272
|
+
stateSiblings: sp.flatMap((p)=>notes_pad(p.siblings, 22)),
|
|
5273
|
+
associationSetRoot: trees.asp.root,
|
|
5274
|
+
associationSetLeafIndex: ap.map((p)=>BigInt(p.index)),
|
|
5275
|
+
associationSetTreeDepth: ap.map((p)=>BigInt(p.siblings.length)),
|
|
5276
|
+
associationSetSiblings: ap.flatMap((p)=>notes_pad(p.siblings, 18)),
|
|
5277
|
+
amountOut,
|
|
5278
|
+
tokenIdOut: BigInt(tokenId),
|
|
5279
|
+
outputNoteAddressHash: outputs.map((o)=>crypto_noteAddressHash(o.owner, o.noteSecret)),
|
|
5280
|
+
outputValue: outputs.map((o)=>o.value),
|
|
5281
|
+
outputLabel: outputs.map((o)=>o.label)
|
|
5282
|
+
}
|
|
5283
|
+
};
|
|
5284
|
+
}({
|
|
5137
5285
|
owner,
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5286
|
+
privateNullifyingKey: keys.privateNullifyingKey,
|
|
5287
|
+
privateRevocableKey: keys.privateRevocableKey
|
|
5288
|
+
}, [
|
|
5289
|
+
note
|
|
5290
|
+
], outputs, {
|
|
5291
|
+
state,
|
|
5292
|
+
keystore: ks,
|
|
5293
|
+
asp: asp.tree
|
|
5294
|
+
}, {
|
|
5295
|
+
amountOut,
|
|
5296
|
+
context: utils_utils_bytesToNumberBE(sha3_keccak_256(ROUTING.transactContext.encodeInput({
|
|
5297
|
+
transactParams: {
|
|
5298
|
+
processor: processor,
|
|
5299
|
+
data: data
|
|
5300
|
+
},
|
|
5301
|
+
notes: notes.map((n)=>({
|
|
5302
|
+
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5303
|
+
data: n.ciphertext
|
|
5304
|
+
}))
|
|
5305
|
+
}).slice(4))) % crypto_SNARK_FIELD
|
|
5306
|
+
});
|
|
5307
|
+
return prover_prove(t.circuit, t.input, c.threads);
|
|
5308
|
+
}, transactArgs = (proof, data)=>{
|
|
5309
|
+
var signals;
|
|
5310
|
+
let tail, s = solidityProof(proof);
|
|
5159
5311
|
return {
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
stateSiblings: sp.flatMap((p)=>notes_pad(p.siblings, 22)),
|
|
5181
|
-
associationSetRoot: trees.asp.root,
|
|
5182
|
-
associationSetLeafIndex: ap.map((p)=>BigInt(p.index)),
|
|
5183
|
-
associationSetTreeDepth: ap.map((p)=>BigInt(p.siblings.length)),
|
|
5184
|
-
associationSetSiblings: ap.flatMap((p)=>notes_pad(p.siblings, 18)),
|
|
5185
|
-
amountOut,
|
|
5186
|
-
tokenIdOut: BigInt(tokenId),
|
|
5187
|
-
outputNoteAddressHash: outputs.map((o)=>crypto_noteAddressHash(o.owner, o.noteSecret)),
|
|
5188
|
-
outputValue: outputs.map((o)=>o.value),
|
|
5189
|
-
outputLabel: outputs.map((o)=>o.label)
|
|
5190
|
-
}
|
|
5312
|
+
proof: {
|
|
5313
|
+
pA: s.pA,
|
|
5314
|
+
pB: s.pB,
|
|
5315
|
+
pC: s.pC,
|
|
5316
|
+
pubSignals: (signals = proof.publicSignals, tail = 2, [
|
|
5317
|
+
signals.slice(0, 1),
|
|
5318
|
+
signals.slice(1, tail),
|
|
5319
|
+
...signals.slice(tail, tail + 6).map((x)=>[
|
|
5320
|
+
x
|
|
5321
|
+
])
|
|
5322
|
+
])
|
|
5323
|
+
},
|
|
5324
|
+
transactParams: {
|
|
5325
|
+
processooor: processor,
|
|
5326
|
+
data
|
|
5327
|
+
},
|
|
5328
|
+
notes: notes.map((n)=>({
|
|
5329
|
+
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5330
|
+
ciphertext: n.ciphertext
|
|
5331
|
+
}))
|
|
5191
5332
|
};
|
|
5192
|
-
}({
|
|
5193
|
-
owner,
|
|
5194
|
-
privateNullifyingKey: keys.privateNullifyingKey,
|
|
5195
|
-
privateRevocableKey: keys.privateRevocableKey
|
|
5196
|
-
}, [
|
|
5197
|
-
note
|
|
5198
|
-
], outputs, {
|
|
5199
|
-
state,
|
|
5200
|
-
keystore: ks,
|
|
5201
|
-
asp: asp.tree
|
|
5202
|
-
}, {
|
|
5203
|
-
amountOut: value,
|
|
5204
|
-
context
|
|
5205
|
-
}), proof = await prover_prove(t.circuit, t.input, c.threads), s = solidityProof(proof), calldata = chain_POOL.transact.encodeInput({
|
|
5206
|
-
proof: {
|
|
5207
|
-
pA: s.pA,
|
|
5208
|
-
pB: s.pB,
|
|
5209
|
-
pC: s.pC,
|
|
5210
|
-
pubSignals: (signals = proof.publicSignals, tail = 2, [
|
|
5211
|
-
signals.slice(0, 1),
|
|
5212
|
-
signals.slice(1, tail),
|
|
5213
|
-
...signals.slice(tail, tail + 6).map((x)=>[
|
|
5214
|
-
x
|
|
5215
|
-
])
|
|
5216
|
-
])
|
|
5217
|
-
},
|
|
5218
|
-
transactParams: {
|
|
5219
|
-
processooor: processor,
|
|
5220
|
-
data
|
|
5221
|
-
},
|
|
5222
|
-
notes: notes.map((n)=>({
|
|
5223
|
-
hint: utils_hexToBytes(n.hint.slice(2)),
|
|
5224
|
-
ciphertext: n.ciphertext
|
|
5225
|
-
}))
|
|
5226
|
-
}), call = {
|
|
5227
|
-
to: POOL_ADDR,
|
|
5228
|
-
value: 0n,
|
|
5229
|
-
data: calldata
|
|
5230
5333
|
};
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5334
|
+
if (!relayed) {
|
|
5335
|
+
let data = payoutRouting({
|
|
5336
|
+
recipient,
|
|
5337
|
+
feeRecipient: recipient,
|
|
5338
|
+
feeAmount: 0n,
|
|
5339
|
+
nativeGas: 0n
|
|
5340
|
+
});
|
|
5341
|
+
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`);
|
|
5342
|
+
let proof = await proveSpend(value, data), calldata = chain_POOL.transact.encodeInput(transactArgs(proof, data)), call = {
|
|
5343
|
+
to: POOL_ADDR,
|
|
5344
|
+
value: 0n,
|
|
5345
|
+
data: calldata
|
|
5346
|
+
};
|
|
5347
|
+
return c.safe ? proposeCalls(net, c, [
|
|
5348
|
+
call
|
|
5349
|
+
], '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({
|
|
5350
|
+
to: call.to,
|
|
5351
|
+
data: v2_commands_hex(calldata),
|
|
5352
|
+
recipient,
|
|
5353
|
+
amountOut: String(value)
|
|
5354
|
+
}, 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)}`));
|
|
5355
|
+
}
|
|
5356
|
+
let maxPercent = c.maxFeePercent ?? 1, r = await commands_pickRelayer(v.relayer ? [
|
|
5357
|
+
v.relayer
|
|
5358
|
+
] : RELAYERS, asset, recipient, value, maxPercent);
|
|
5359
|
+
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`);
|
|
5360
|
+
let proof = await proveSpend(r.quote.amountSent, r.quote.data);
|
|
5361
|
+
for(let tries = 0; Date.now() > r.quote.expiration - 5000; tries++){
|
|
5362
|
+
if (3 === tries) throw Error("the relayer's quote keeps expiring before the proof is ready -- try more --threads");
|
|
5363
|
+
v2_commands_log('the quote expired while proving; asking again');
|
|
5364
|
+
let q = await quoteGross(r.base, asset.tokenId, recipient, value), why = tooDear(asset, q, value, maxPercent);
|
|
5365
|
+
if (why) throw new config_UsageError(`the relayer now ${why}`);
|
|
5366
|
+
let same = q.amountSent === r.quote.amountSent && utils_bytesToHex(q.data) === utils_bytesToHex(r.quote.data);
|
|
5367
|
+
r = {
|
|
5368
|
+
...r,
|
|
5369
|
+
quote: q
|
|
5370
|
+
}, same || (v2_commands_log(` the fee moved to ${commands_amountOf(asset, q.feeAmount)}`), proof = await proveSpend(q.amountSent, q.data));
|
|
5371
|
+
}
|
|
5372
|
+
let calldata = RELAY.relay.encodeInput(transactArgs(proof, r.quote.data)), sim = await net.dryRun({
|
|
5373
|
+
from: r.details.relayerAddress,
|
|
5374
|
+
to: RELAY_ADDR,
|
|
5375
|
+
data: v2_commands_hex(calldata)
|
|
5376
|
+
});
|
|
5377
|
+
if (!sim.success) throw new config_UsageError(`it would revert, nothing was sent: ${sim.reason}`);
|
|
5378
|
+
if (v2_commands_log('simulated: the relay accepts it'), c.dryRun) return void v2_commands_out(JSON.stringify({
|
|
5379
|
+
relayer: r.base,
|
|
5380
|
+
to: RELAY_ADDR,
|
|
5235
5381
|
data: v2_commands_hex(calldata),
|
|
5236
5382
|
recipient,
|
|
5237
|
-
amountOut: String(
|
|
5238
|
-
|
|
5383
|
+
amountOut: String(r.quote.amountSent),
|
|
5384
|
+
fee: String(r.quote.feeAmount)
|
|
5385
|
+
}, null, 2));
|
|
5386
|
+
let spent = nullifier(keys.privateNullifyingKey, a.note.commitment), tx = await relay(r.base, {
|
|
5387
|
+
quote: r.quote,
|
|
5388
|
+
proof,
|
|
5389
|
+
notes,
|
|
5390
|
+
inputs: 1
|
|
5391
|
+
});
|
|
5392
|
+
v2_commands_log(`relayer sent ${tx} -- waiting for the chain`);
|
|
5393
|
+
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}`);
|
|
5394
|
+
throw Error('not confirmed within 15 minutes -- check `moneysurfer v2 balance` before trying again');
|
|
5239
5395
|
}
|
|
5240
5396
|
async function v2_commands_ragequit(key, v, c) {
|
|
5241
5397
|
var account, note, trees;
|
|
@@ -5243,7 +5399,7 @@ async function v2_commands_ragequit(key, v, c) {
|
|
|
5243
5399
|
if (!key || void 0 === v.id) throw new config_UsageError('usage: moneysurfer v2 ragequit <asset> --id N');
|
|
5244
5400
|
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, [
|
|
5245
5401
|
asset.tokenId
|
|
5246
|
-
], ev), a = accounts.find((x)=>String(Number(x.index) + 1) === v.id.replace(/^#/, ''));
|
|
5402
|
+
], ev, config_chainId()), a = accounts.find((x)=>String(Number(x.index) + 1) === v.id.replace(/^#/, ''));
|
|
5247
5403
|
if (!a) throw new config_UsageError(`no account #${v.id} (see: moneysurfer v2 balance)`);
|
|
5248
5404
|
if (!account_spendable(a)) throw new config_UsageError(`account #${v.id} has nothing left`);
|
|
5249
5405
|
let ks = await keystoreTree(net, ev), timestamp = await rpc_read(net, POOL_ADDR, chain_POOL.commitments, a.note.commitment);
|
|
@@ -5297,7 +5453,38 @@ async function v2_commands_ragequit(key, v, c) {
|
|
|
5297
5453
|
}
|
|
5298
5454
|
async function commands_status() {
|
|
5299
5455
|
let net = await commands_connect();
|
|
5300
|
-
v2_commands_out(`
|
|
5456
|
+
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)}`);
|
|
5457
|
+
let transactKey = sha3_keccak_256(utils_hexToBytes(`${'0'.repeat(63)}1`.repeat(2)));
|
|
5458
|
+
for (let [label, circuit, at] of [
|
|
5459
|
+
[
|
|
5460
|
+
'depositVk',
|
|
5461
|
+
'deposit',
|
|
5462
|
+
rpc_read(net, POOL_ADDR, chain_POOL.depositVerifier)
|
|
5463
|
+
],
|
|
5464
|
+
[
|
|
5465
|
+
'ragequitVk',
|
|
5466
|
+
'ragequit',
|
|
5467
|
+
rpc_read(net, POOL_ADDR, chain_POOL.ragequitVerifier)
|
|
5468
|
+
],
|
|
5469
|
+
[
|
|
5470
|
+
'transactVk',
|
|
5471
|
+
'transact_1x1',
|
|
5472
|
+
rpc_read(net, POOL_ADDR, chain_POOL.verifiers, transactKey).then((v)=>v.verifier)
|
|
5473
|
+
]
|
|
5474
|
+
]){
|
|
5475
|
+
let address = await at, how = artifacts_current(circuit, 'vkey') ? !function(code, circuit) {
|
|
5476
|
+
let j, hay = code.toLowerCase();
|
|
5477
|
+
return [
|
|
5478
|
+
...(j = JSON.parse(new TextDecoder().decode(artifacts_load(circuit, 'vkey')))).vk_delta_2.slice(0, 2).flat(),
|
|
5479
|
+
...j.IC.flatMap((p)=>p.slice(0, 2))
|
|
5480
|
+
].map((w)=>{
|
|
5481
|
+
let hex;
|
|
5482
|
+
return (hex = BigInt(w).toString(16)).length % 2 && (hex = `0${hex}`), `${(0x5f + hex.length / 2).toString(16)}${hex}`;
|
|
5483
|
+
}).every((p)=>hay.includes(p));
|
|
5484
|
+
}(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`;
|
|
5485
|
+
v2_commands_out(` ${label.padEnd(12)} ${address} ${how}`);
|
|
5486
|
+
}
|
|
5487
|
+
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}`);
|
|
5301
5488
|
}
|
|
5302
5489
|
async function commands_trees() {
|
|
5303
5490
|
let net = await commands_connect(), ev = await sync(net, v2_commands_log), state = await chain_stateTree(net, ev);
|
|
@@ -5308,6 +5495,13 @@ async function commands_trees() {
|
|
|
5308
5495
|
v2_commands_out(`association ${asp.tree.size} leaves, root ${hex32(asp.root)} (the registry published it)`);
|
|
5309
5496
|
}
|
|
5310
5497
|
async function commands_run(cmd, rest, v, c) {
|
|
5498
|
+
void 0 !== v.chain && function(id) {
|
|
5499
|
+
if (!DEPLOYMENTS[id]) {
|
|
5500
|
+
let known = Object.keys(DEPLOYMENTS).map((k)=>`${chainName(Number(k))} (${k})`).join(', ');
|
|
5501
|
+
throw new config_UsageError(`no Privacy Pools V2 on ${chainName(id)} -- supported: ${known}`);
|
|
5502
|
+
}
|
|
5503
|
+
selected = id;
|
|
5504
|
+
}(parseChain(v.chain));
|
|
5311
5505
|
let commands = {
|
|
5312
5506
|
setup: ()=>commands_setup(rest),
|
|
5313
5507
|
init: ()=>commands_init({
|
|
@@ -5326,6 +5520,7 @@ async function commands_run(cmd, rest, v, c) {
|
|
|
5326
5520
|
trees: ()=>commands_trees()
|
|
5327
5521
|
};
|
|
5328
5522
|
if (!Object.hasOwn(commands, cmd)) throw new config_UsageError(`unknown v2 command '${cmd}'\n\n${commands_HELP}`);
|
|
5523
|
+
if (c.owner && 'withdraw' !== cmd) throw new config_UsageError('only withdraw takes --owner');
|
|
5329
5524
|
await commands[cmd]();
|
|
5330
5525
|
}
|
|
5331
5526
|
import { availableParallelism, homedir } from "node:os";
|
|
@@ -5349,6 +5544,10 @@ let HOME_ROOT = process.env.MONEYSURFER_HOME ?? join(homedir(), '.local/share/mo
|
|
|
5349
5544
|
rpc: 'https://optimism.gateway.tenderly.co',
|
|
5350
5545
|
safe: 'oeth'
|
|
5351
5546
|
},
|
|
5547
|
+
56: {
|
|
5548
|
+
name: 'BNB',
|
|
5549
|
+
safe: 'bnb'
|
|
5550
|
+
},
|
|
5352
5551
|
42161: {
|
|
5353
5552
|
name: 'Arbitrum',
|
|
5354
5553
|
rpc: 'https://arbitrum.gateway.tenderly.co',
|
|
@@ -11937,7 +12136,7 @@ let SEED_CONTEXT = 'privacy-pools/wallet-seed:v2', ENCODERS = abi_createContract
|
|
|
11937
12136
|
relayFeeBPS
|
|
11938
12137
|
}).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();
|
|
11939
12138
|
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"]}}');
|
|
11940
|
-
let ASSETS = ASSETS_ROOT, HOME = HOME_ROOT, ARTIFACT_URL = 'https://privacypools.com/artifacts', ARTIFACTS = {
|
|
12139
|
+
let ASSETS = ASSETS_ROOT, HOME = HOME_ROOT, ARTIFACT_URL = 'https://v1.privacypools.com/artifacts', ARTIFACTS = {
|
|
11941
12140
|
'withdraw.wasm': '36cda22791def3d520a55c0fc808369cd5849532a75fab65686e666ed3d55c10',
|
|
11942
12141
|
'withdraw.zkey': '2a893b42174c813566e5c40c715a8b90cd49fc4ecf384e3a6024158c3d6de677',
|
|
11943
12142
|
'commitment.wasm': '254d2130607182fd6fd1aee67971526b13cfe178c88e360da96dce92663828d8',
|
|
@@ -13391,7 +13590,7 @@ let commands_hex = (b)=>`0x${utils_bytesToHex(b)}`, shortLabel = (label)=>`0x${l
|
|
|
13391
13590
|
setup fetch the circuits, check their pinned sha256
|
|
13392
13591
|
init make a new mnemonic (the one secret behind every note)
|
|
13393
13592
|
--import ... or take one on stdin
|
|
13394
|
-
--from-wallet ... or derive privacypools.com's from your wallet's signature
|
|
13593
|
+
--from-wallet ... or derive v1.privacypools.com's from your wallet's signature
|
|
13395
13594
|
pools every pool the Entrypoints registered: minimum deposit, fee, size
|
|
13396
13595
|
balance your accounts and what each holds
|
|
13397
13596
|
sync pull every pool's events into the cache
|
|
@@ -14171,39 +14370,50 @@ class crypto_LeanIMT {
|
|
|
14171
14370
|
};
|
|
14172
14371
|
}
|
|
14173
14372
|
}
|
|
14174
|
-
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)=>
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14373
|
+
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)=>{
|
|
14374
|
+
let on = 1 === chainId ? '' : `@${chainId}`;
|
|
14375
|
+
return {
|
|
14376
|
+
noteSecret: noteScalar(rootSecret, `note${on}`, BigInt(tokenId.toLowerCase()), index),
|
|
14377
|
+
depositSecret: noteScalar(rootSecret, `deposit${on}`, BigInt(tokenId.toLowerCase()), index)
|
|
14378
|
+
};
|
|
14379
|
+
}, 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 = {
|
|
14380
|
+
name: 'routing',
|
|
14381
|
+
type: 'tuple',
|
|
14382
|
+
components: [
|
|
14383
|
+
{
|
|
14384
|
+
name: 'recipient',
|
|
14385
|
+
type: 'address'
|
|
14386
|
+
},
|
|
14387
|
+
{
|
|
14388
|
+
name: 'feeRecipient',
|
|
14389
|
+
type: 'address'
|
|
14390
|
+
},
|
|
14391
|
+
{
|
|
14392
|
+
name: 'feeAmount',
|
|
14393
|
+
type: 'uint256'
|
|
14394
|
+
},
|
|
14395
|
+
{
|
|
14396
|
+
name: 'nativeGas',
|
|
14397
|
+
type: 'uint256'
|
|
14398
|
+
}
|
|
14399
|
+
]
|
|
14400
|
+
}, ROUTING = abi_createContract([
|
|
14178
14401
|
{
|
|
14179
14402
|
type: 'function',
|
|
14180
14403
|
name: 'payoutRouting',
|
|
14181
14404
|
inputs: [
|
|
14182
|
-
|
|
14183
|
-
name: 'routing',
|
|
14184
|
-
type: 'tuple',
|
|
14185
|
-
components: [
|
|
14186
|
-
{
|
|
14187
|
-
name: 'recipient',
|
|
14188
|
-
type: 'address'
|
|
14189
|
-
},
|
|
14190
|
-
{
|
|
14191
|
-
name: 'feeRecipient',
|
|
14192
|
-
type: 'address'
|
|
14193
|
-
},
|
|
14194
|
-
{
|
|
14195
|
-
name: 'feeAmount',
|
|
14196
|
-
type: 'uint256'
|
|
14197
|
-
},
|
|
14198
|
-
{
|
|
14199
|
-
name: 'nativeGas',
|
|
14200
|
-
type: 'uint256'
|
|
14201
|
-
}
|
|
14202
|
-
]
|
|
14203
|
-
}
|
|
14405
|
+
PAYOUT_ROUTING
|
|
14204
14406
|
],
|
|
14205
14407
|
outputs: []
|
|
14206
14408
|
},
|
|
14409
|
+
{
|
|
14410
|
+
type: 'function',
|
|
14411
|
+
name: 'readRouting',
|
|
14412
|
+
inputs: [],
|
|
14413
|
+
outputs: [
|
|
14414
|
+
PAYOUT_ROUTING
|
|
14415
|
+
]
|
|
14416
|
+
},
|
|
14207
14417
|
{
|
|
14208
14418
|
type: 'function',
|
|
14209
14419
|
name: 'transactContext',
|
|
@@ -14239,41 +14449,64 @@ let APP_IDENTIFIER = 'TODO-privacy-pools-v2', ROOT_DERIVATION_INFO = 'Standardiz
|
|
|
14239
14449
|
],
|
|
14240
14450
|
outputs: []
|
|
14241
14451
|
}
|
|
14242
|
-
]), 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);
|
|
14243
|
-
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"}}');
|
|
14244
|
-
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',
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14452
|
+
]), 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);
|
|
14453
|
+
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"}}');
|
|
14454
|
+
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 = [
|
|
14455
|
+
'https://relayer-v2-prod-149184580131.us-east1.run.app'
|
|
14456
|
+
], 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 = {
|
|
14457
|
+
1: {
|
|
14458
|
+
deployedBlock: 25884231,
|
|
14459
|
+
native: 'ETH',
|
|
14460
|
+
rpc: CHAINS["1"].rpc,
|
|
14461
|
+
tokens: [
|
|
14462
|
+
config_NATIVE,
|
|
14463
|
+
PP_ETH,
|
|
14464
|
+
PP_USDC,
|
|
14465
|
+
PP_USDT,
|
|
14466
|
+
USDC,
|
|
14467
|
+
USDT
|
|
14468
|
+
],
|
|
14469
|
+
routers: {
|
|
14470
|
+
[PP_ETH.toLowerCase()]: {
|
|
14471
|
+
address: '0x77613D670BB9fD48A9898D0eac8ebf21B566F960',
|
|
14472
|
+
underlying: config_NATIVE,
|
|
14473
|
+
native: !0
|
|
14474
|
+
},
|
|
14475
|
+
[PP_USDC.toLowerCase()]: {
|
|
14476
|
+
address: '0xe76E793d776c1e207aD7a7fa7C57d27420d85110',
|
|
14477
|
+
underlying: USDC,
|
|
14478
|
+
native: !1
|
|
14479
|
+
},
|
|
14480
|
+
[PP_USDT.toLowerCase()]: {
|
|
14481
|
+
address: '0x13a0b86bac3e0C29bd64fED7BCD2EE84f371f41C',
|
|
14482
|
+
underlying: USDT,
|
|
14483
|
+
native: !1
|
|
14484
|
+
}
|
|
14485
|
+
}
|
|
14486
|
+
},
|
|
14487
|
+
56: {
|
|
14488
|
+
deployedBlock: 119401450,
|
|
14489
|
+
native: 'BNB',
|
|
14490
|
+
tokens: [
|
|
14491
|
+
config_NATIVE,
|
|
14492
|
+
BNB_PP_USDT,
|
|
14493
|
+
'0xc5f0f7b66764F6ec8C8Dff7BA683102295E16409',
|
|
14494
|
+
BNB_USDT
|
|
14495
|
+
],
|
|
14496
|
+
routers: {
|
|
14497
|
+
[BNB_PP_USDT.toLowerCase()]: {
|
|
14498
|
+
address: '0x9929Ad2Edc2E0B5D59C3f5b2910812D0c8b84E16',
|
|
14499
|
+
underlying: BNB_USDT,
|
|
14500
|
+
native: !1
|
|
14501
|
+
}
|
|
14502
|
+
}
|
|
14503
|
+
}
|
|
14504
|
+
}, selected = 1, config_chainId = ()=>selected, deployment = ()=>DEPLOYMENTS[selected], routerFor = (tokenId)=>deployment().routers[tokenId.toLowerCase()], config_IPFS_GATEWAYS = [
|
|
14268
14505
|
'https://gateway.pinata.cloud',
|
|
14269
14506
|
'https://dweb.link',
|
|
14270
14507
|
'https://ipfs.io',
|
|
14271
14508
|
'https://w3s.link'
|
|
14272
|
-
], CIRCUITS = circuit_artifacts_namespaceObject,
|
|
14273
|
-
wasm: 'wasm',
|
|
14274
|
-
zkey: 'provingKey',
|
|
14275
|
-
vkey: 'verificationKey'
|
|
14276
|
-
}, artifacts_path = (circuit, kind)=>join(config_ASSETS, `${circuit}.${kind}`), have = (circuit, kind)=>existsSync(artifacts_path(circuit, kind)), chain_u256 = (name)=>({
|
|
14509
|
+
], 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)=>({
|
|
14277
14510
|
name,
|
|
14278
14511
|
type: 'uint256'
|
|
14279
14512
|
}), chain_addr = (name)=>({
|
|
@@ -14841,7 +15074,7 @@ let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2')
|
|
|
14841
15074
|
ASPRootUpdated: chain_topicOf('ASPRootUpdated(uint256,bytes)'),
|
|
14842
15075
|
LabelRegistered: chain_topicOf('LabelRegistered(bytes)')
|
|
14843
15076
|
}, chain_hexNum = (n)=>`0x${n.toString(16)}`, chain_REORG_BLOCKS = 2000, chain_empty = ()=>({
|
|
14844
|
-
block:
|
|
15077
|
+
block: deployment().deployedBlock - 1,
|
|
14845
15078
|
deposits: [],
|
|
14846
15079
|
ragequits: [],
|
|
14847
15080
|
transacts: [],
|
|
@@ -14849,10 +15082,7 @@ let config_ASSETS = join(ASSETS_ROOT, 'v2'), config_HOME = join(HOME_ROOT, 'v2')
|
|
|
14849
15082
|
leaves: [],
|
|
14850
15083
|
keystoreLeaves: [],
|
|
14851
15084
|
aspRoots: []
|
|
14852
|
-
}), chain_cacheFile = ()=>join(config_HOME, 'cache',
|
|
14853
|
-
symbol: 'ETH',
|
|
14854
|
-
decimals: 18
|
|
14855
|
-
}, 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();
|
|
15085
|
+
}), 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();
|
|
14856
15086
|
class Poly1305 {
|
|
14857
15087
|
blockLen = 16;
|
|
14858
15088
|
outputLen = 16;
|
|
@@ -15130,7 +15360,13 @@ let poly1305 = (macCons = (key)=>new Poly1305(key), getArgs = ()=>[], (macC = (m
|
|
|
15130
15360
|
})), prover_prove = (circuit, input, threads)=>prover_prover.prove(circuit, input, threads), NO_NOTE = {
|
|
15131
15361
|
hint: `0x${'00'.repeat(32)}`,
|
|
15132
15362
|
ciphertext: new Uint8Array(0)
|
|
15133
|
-
}, msgValue = (tokenId, value, vettingFeeBPS)=>isNative(tokenId) ? value + value * vettingFeeBPS / 10000n : 0n,
|
|
15363
|
+
}, msgValue = (tokenId, value, vettingFeeBPS)=>isNative(tokenId) ? value + value * vettingFeeBPS / 10000n : 0n, CHAIN_TYPE = 'evm', RELAY = abi_createContract([
|
|
15364
|
+
{
|
|
15365
|
+
...chain_POOL_ABI["2"],
|
|
15366
|
+
name: 'relay',
|
|
15367
|
+
stateMutability: 'payable'
|
|
15368
|
+
}
|
|
15369
|
+
]), zap_u256 = (name)=>({
|
|
15134
15370
|
name,
|
|
15135
15371
|
type: 'uint256'
|
|
15136
15372
|
}), DEPOSIT_PROOF = {
|
|
@@ -15314,24 +15550,31 @@ let poly1305 = (macCons = (key)=>new Poly1305(key), getArgs = ()=>[], (macC = (m
|
|
|
15314
15550
|
} : 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({
|
|
15315
15551
|
address: owner,
|
|
15316
15552
|
send: ()=>Promise.reject(Error('dry run'))
|
|
15317
|
-
}) : makeSigner(net,
|
|
15553
|
+
}) : 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
|
|
15318
15554
|
|
|
15319
15555
|
v2 setup [circuit...] fetch the circuits, check their pinned sha256
|
|
15320
15556
|
v2 init make a new seed (the one secret behind every note)
|
|
15321
15557
|
--import ... or take one on stdin
|
|
15322
|
-
--from-wallet ... or derive
|
|
15558
|
+
--from-wallet ... or derive privacypools.com's from your wallet
|
|
15323
15559
|
v2 register put this address in the Keystore -- required before spending
|
|
15324
15560
|
v2 pools every asset the Entrypoint takes: minimum, fee, notes
|
|
15325
15561
|
v2 balance your notes and what each holds
|
|
15326
15562
|
v2 sync pull the pool, keystore and ASP events into the cache
|
|
15327
15563
|
v2 deposit <asset> <amount> deposit from your wallet (a token is approved first, exactly)
|
|
15328
|
-
v2 withdraw <asset> <amount|all> <to> spend privately
|
|
15564
|
+
v2 withdraw <asset> <amount|all> <to> spend privately, through a relayer that pays the gas;
|
|
15565
|
+
<to> gets <amount> less its fee
|
|
15329
15566
|
--id N from account #N (default: the first that can)
|
|
15567
|
+
--relayer URL use this relayer instead of 0xbow's
|
|
15330
15568
|
--self | --safe SAFE submit and pay gas yourself, or have a Safe submit it
|
|
15569
|
+
<to> has to be the submitter then: the pool pays msg.sender
|
|
15570
|
+
--owner ADDR with --safe: spend ADDR's notes, not the Safe's
|
|
15331
15571
|
v2 ragequit <asset> --id N take a note back publicly, to the owning address
|
|
15332
15572
|
v2 status | trees the deployment, and both trees rebuilt from logs
|
|
15333
15573
|
|
|
15334
|
-
--
|
|
15574
|
+
--chain CHAIN ethereum (default) or bnb; each chain has its own notes.
|
|
15575
|
+
bnb needs --rpc-url: no public BNB RPC serves old logs
|
|
15576
|
+
--max-fee-percent N on withdraw, refuse a relayer fee above N% (default 1);
|
|
15577
|
+
on deposit, how far over the wrapping quote you will go
|
|
15335
15578
|
(default 0.0001, one part per million)
|
|
15336
15579
|
|
|
15337
15580
|
amounts are human units of what you spend. For a wrapped asset (usdc, usdt) a deposit spends
|
|
@@ -15340,7 +15583,8 @@ more than a dollar, so 10 USDC buys under 10 ppUSDC and falls below the minimum.
|
|
|
15340
15583
|
10.02 usdc is the real floor; the error says so with the number of the day. A withdrawal
|
|
15341
15584
|
spends the note, so its amount is in shares, and shares are what it pays out.
|
|
15342
15585
|
|
|
15343
|
-
|
|
15586
|
+
A relayer's fee is mostly the gas of the withdrawal, not a share of it, so the 1% default
|
|
15587
|
+
refuses the smallest ones; the error says what was asked.
|
|
15344
15588
|
|
|
15345
15589
|
env: MONEYSURFER_MNEMONIC, MONEYSURFER_RPC, MONEYSURFER_ASP`, cli_log = (s)=>process.stderr.write(`${s}\n`);
|
|
15346
15590
|
process.stdout.on('error', (e)=>{
|
|
@@ -15418,6 +15662,9 @@ try {
|
|
|
15418
15662
|
from: {
|
|
15419
15663
|
type: 'string'
|
|
15420
15664
|
},
|
|
15665
|
+
owner: {
|
|
15666
|
+
type: 'string'
|
|
15667
|
+
},
|
|
15421
15668
|
help: {
|
|
15422
15669
|
type: 'boolean',
|
|
15423
15670
|
short: 'h'
|
|
@@ -15450,13 +15697,13 @@ try {
|
|
|
15450
15697
|
s = explicit ? `${'v2' === protocol ? commands_HELP : HELP}\n\n${SHARED}` : cli_HELP, process.stdout.write(`${s}\n`), process.exit(0);
|
|
15451
15698
|
}
|
|
15452
15699
|
for (let { flag, why } of ({
|
|
15453
|
-
v1: [
|
|
15454
|
-
v2: [
|
|
15700
|
+
v1: [
|
|
15455
15701
|
{
|
|
15456
|
-
flag: '
|
|
15457
|
-
why: '
|
|
15702
|
+
flag: 'owner',
|
|
15703
|
+
why: 'a V1 note has no owner address; the seed alone spends it'
|
|
15458
15704
|
}
|
|
15459
|
-
]
|
|
15705
|
+
],
|
|
15706
|
+
v2: []
|
|
15460
15707
|
})[protocol])if (void 0 !== v[flag]) throw new config_UsageError(`${protocol} takes no --${flag}: ${why}`);
|
|
15461
15708
|
rpcOverride = v['rpc-url'];
|
|
15462
15709
|
let threads = void 0 === v.threads ? availableParallelism() : Number(v.threads);
|
|
@@ -15466,6 +15713,7 @@ try {
|
|
|
15466
15713
|
let common = {
|
|
15467
15714
|
threads,
|
|
15468
15715
|
safe: void 0 === v.safe ? void 0 : flags_checksummed(v.safe),
|
|
15716
|
+
owner: void 0 === v.owner ? void 0 : flags_checksummed(v.owner),
|
|
15469
15717
|
maxFeePercent,
|
|
15470
15718
|
dryRun: v['dry-run'] ?? !1,
|
|
15471
15719
|
sig: {
|