@thesingularitynetwork/darkswap-sdk 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +662 -609
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +662 -609
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +668 -609
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/proof/pro/orders/swapProof.d.ts +1 -0
- package/dist/types/src/proof/retail/depositOrderProof.d.ts +1 -1
- package/dist/types/src/proof/retail/swapProof.d.ts +0 -2
- package/dist/types/src/services/agent/index.d.ts +1 -0
- package/dist/types/src/services/agent/retailSwap.d.ts +25 -0
- package/dist/types/src/services/pro/index.d.ts +0 -1
- package/dist/types/src/services/pro/proSwap.d.ts +6 -1
- package/dist/types/src/services/pro/swapMessage.d.ts +2 -2
- package/dist/types/src/types.d.ts +2 -0
- package/dist/types/test/services/pro/proSwap.test.d.ts +1 -0
- package/dist/types/test/utils/helpers.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/proof/pro/orders/swapProof.ts +8 -11
- package/src/proof/retail/depositOrderProof.ts +6 -3
- package/src/proof/retail/swapProof.ts +5 -10
- package/src/services/agent/index.ts +1 -0
- package/src/services/agent/retailSwap.ts +116 -0
- package/src/services/pro/cancelOrder.ts +1 -1
- package/src/services/pro/createOrder.ts +2 -2
- package/src/services/pro/index.ts +1 -2
- package/src/services/pro/proSwap.ts +53 -16
- package/src/services/retail/depositAndCreateOrder.ts +1 -1
- package/src/types.ts +2 -0
- package/src/utils/swapUtils.ts +20 -5
- package/src/services/pro/swapMessage.ts +0 -13
package/dist/index.esm.js
CHANGED
|
@@ -744,6 +744,12 @@ else {
|
|
|
744
744
|
}
|
|
745
745
|
const DOMAIN_NOTE = 2n;
|
|
746
746
|
const DOMAIN_ORDER_NOTE = 3n;
|
|
747
|
+
const EMPTY_NOTE = {
|
|
748
|
+
rho: 0n,
|
|
749
|
+
note: 0n,
|
|
750
|
+
amount: 0n,
|
|
751
|
+
asset: '0x0000000000000000000000000000000000000000'
|
|
752
|
+
};
|
|
747
753
|
function createNote(address, asset, amount, fuzkPubKey) {
|
|
748
754
|
const rho = generateRho();
|
|
749
755
|
const footer = getNoteFooter(rho, fuzkPubKey);
|
|
@@ -4247,367 +4253,73 @@ class TripleJoinService extends BaseContractService {
|
|
|
4247
4253
|
}
|
|
4248
4254
|
}
|
|
4249
4255
|
|
|
4250
|
-
var
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4256
|
+
var noir_version$4 = "1.0.0-beta.6+e796dfd67726cbc28eb9991782533b211025928d";
|
|
4257
|
+
var hash$4 = "3522014172221315185";
|
|
4258
|
+
var abi$5 = {
|
|
4259
|
+
parameters: [
|
|
4260
|
+
{
|
|
4261
|
+
name: "merkle_root",
|
|
4262
|
+
type: {
|
|
4263
|
+
kind: "field"
|
|
4257
4264
|
},
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4265
|
+
visibility: "public"
|
|
4266
|
+
},
|
|
4267
|
+
{
|
|
4268
|
+
name: "merkle_index",
|
|
4269
|
+
type: {
|
|
4270
|
+
kind: "array",
|
|
4271
|
+
length: 32,
|
|
4272
|
+
type: {
|
|
4273
|
+
kind: "integer",
|
|
4274
|
+
sign: "unsigned",
|
|
4275
|
+
width: 1
|
|
4276
|
+
}
|
|
4262
4277
|
},
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
inputs: [
|
|
4274
|
-
{
|
|
4275
|
-
internalType: "address",
|
|
4276
|
-
name: "owner",
|
|
4277
|
-
type: "address"
|
|
4278
|
-
}
|
|
4279
|
-
],
|
|
4280
|
-
name: "OwnableInvalidOwner",
|
|
4281
|
-
type: "error"
|
|
4282
|
-
},
|
|
4283
|
-
{
|
|
4284
|
-
inputs: [
|
|
4285
|
-
{
|
|
4286
|
-
internalType: "address",
|
|
4287
|
-
name: "account",
|
|
4288
|
-
type: "address"
|
|
4289
|
-
}
|
|
4290
|
-
],
|
|
4291
|
-
name: "OwnableUnauthorizedAccount",
|
|
4292
|
-
type: "error"
|
|
4293
|
-
},
|
|
4294
|
-
{
|
|
4295
|
-
inputs: [
|
|
4296
|
-
{
|
|
4297
|
-
internalType: "address",
|
|
4298
|
-
name: "token",
|
|
4299
|
-
type: "address"
|
|
4300
|
-
}
|
|
4301
|
-
],
|
|
4302
|
-
name: "SafeERC20FailedOperation",
|
|
4303
|
-
type: "error"
|
|
4304
|
-
},
|
|
4305
|
-
{
|
|
4306
|
-
anonymous: false,
|
|
4307
|
-
inputs: [
|
|
4308
|
-
{
|
|
4309
|
-
indexed: true,
|
|
4310
|
-
internalType: "address",
|
|
4311
|
-
name: "previousOwner",
|
|
4312
|
-
type: "address"
|
|
4278
|
+
visibility: "private"
|
|
4279
|
+
},
|
|
4280
|
+
{
|
|
4281
|
+
name: "merkle_path",
|
|
4282
|
+
type: {
|
|
4283
|
+
kind: "array",
|
|
4284
|
+
length: 32,
|
|
4285
|
+
type: {
|
|
4286
|
+
kind: "field"
|
|
4287
|
+
}
|
|
4313
4288
|
},
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
],
|
|
4321
|
-
name: "OwnershipTransferred",
|
|
4322
|
-
type: "event"
|
|
4323
|
-
},
|
|
4324
|
-
{
|
|
4325
|
-
stateMutability: "payable",
|
|
4326
|
-
type: "fallback"
|
|
4327
|
-
},
|
|
4328
|
-
{
|
|
4329
|
-
inputs: [
|
|
4330
|
-
{
|
|
4331
|
-
internalType: "address",
|
|
4332
|
-
name: "_wallet",
|
|
4333
|
-
type: "address"
|
|
4289
|
+
visibility: "private"
|
|
4290
|
+
},
|
|
4291
|
+
{
|
|
4292
|
+
name: "address",
|
|
4293
|
+
type: {
|
|
4294
|
+
kind: "field"
|
|
4334
4295
|
},
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
name: "addMarketMaker",
|
|
4342
|
-
outputs: [
|
|
4343
|
-
],
|
|
4344
|
-
stateMutability: "nonpayable",
|
|
4345
|
-
type: "function"
|
|
4346
|
-
},
|
|
4347
|
-
{
|
|
4348
|
-
inputs: [
|
|
4349
|
-
{
|
|
4350
|
-
internalType: "address",
|
|
4351
|
-
name: "wallet",
|
|
4352
|
-
type: "address"
|
|
4296
|
+
visibility: "public"
|
|
4297
|
+
},
|
|
4298
|
+
{
|
|
4299
|
+
name: "out_note",
|
|
4300
|
+
type: {
|
|
4301
|
+
kind: "field"
|
|
4353
4302
|
},
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
name: "calculateFee",
|
|
4361
|
-
outputs: [
|
|
4362
|
-
{
|
|
4363
|
-
internalType: "uint256",
|
|
4364
|
-
name: "",
|
|
4365
|
-
type: "uint256"
|
|
4303
|
+
visibility: "private"
|
|
4304
|
+
},
|
|
4305
|
+
{
|
|
4306
|
+
name: "out_rho",
|
|
4307
|
+
type: {
|
|
4308
|
+
kind: "field"
|
|
4366
4309
|
},
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
stateMutability: "view",
|
|
4374
|
-
type: "function"
|
|
4375
|
-
},
|
|
4376
|
-
{
|
|
4377
|
-
inputs: [
|
|
4378
|
-
{
|
|
4379
|
-
internalType: "address",
|
|
4380
|
-
name: "asset",
|
|
4381
|
-
type: "address"
|
|
4310
|
+
visibility: "private"
|
|
4311
|
+
},
|
|
4312
|
+
{
|
|
4313
|
+
name: "out_nullifier",
|
|
4314
|
+
type: {
|
|
4315
|
+
kind: "field"
|
|
4382
4316
|
},
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
name: "claimFee",
|
|
4390
|
-
outputs: [
|
|
4391
|
-
],
|
|
4392
|
-
stateMutability: "nonpayable",
|
|
4393
|
-
type: "function"
|
|
4394
|
-
},
|
|
4395
|
-
{
|
|
4396
|
-
inputs: [
|
|
4397
|
-
{
|
|
4398
|
-
internalType: "address",
|
|
4399
|
-
name: "_wallet",
|
|
4400
|
-
type: "address"
|
|
4401
|
-
}
|
|
4402
|
-
],
|
|
4403
|
-
name: "getMaketMakerRegistration",
|
|
4404
|
-
outputs: [
|
|
4405
|
-
{
|
|
4406
|
-
internalType: "uint8",
|
|
4407
|
-
name: "",
|
|
4408
|
-
type: "uint8"
|
|
4409
|
-
}
|
|
4410
|
-
],
|
|
4411
|
-
stateMutability: "view",
|
|
4412
|
-
type: "function"
|
|
4413
|
-
},
|
|
4414
|
-
{
|
|
4415
|
-
inputs: [
|
|
4416
|
-
{
|
|
4417
|
-
internalType: "address",
|
|
4418
|
-
name: "wallet",
|
|
4419
|
-
type: "address"
|
|
4420
|
-
}
|
|
4421
|
-
],
|
|
4422
|
-
name: "getServiceFeePercentage",
|
|
4423
|
-
outputs: [
|
|
4424
|
-
{
|
|
4425
|
-
internalType: "uint256",
|
|
4426
|
-
name: "",
|
|
4427
|
-
type: "uint256"
|
|
4428
|
-
}
|
|
4429
|
-
],
|
|
4430
|
-
stateMutability: "view",
|
|
4431
|
-
type: "function"
|
|
4432
|
-
},
|
|
4433
|
-
{
|
|
4434
|
-
inputs: [
|
|
4435
|
-
],
|
|
4436
|
-
name: "owner",
|
|
4437
|
-
outputs: [
|
|
4438
|
-
{
|
|
4439
|
-
internalType: "address",
|
|
4440
|
-
name: "",
|
|
4441
|
-
type: "address"
|
|
4442
|
-
}
|
|
4443
|
-
],
|
|
4444
|
-
stateMutability: "view",
|
|
4445
|
-
type: "function"
|
|
4446
|
-
},
|
|
4447
|
-
{
|
|
4448
|
-
inputs: [
|
|
4449
|
-
{
|
|
4450
|
-
internalType: "address",
|
|
4451
|
-
name: "asset",
|
|
4452
|
-
type: "address"
|
|
4453
|
-
},
|
|
4454
|
-
{
|
|
4455
|
-
internalType: "address",
|
|
4456
|
-
name: "to",
|
|
4457
|
-
type: "address"
|
|
4458
|
-
},
|
|
4459
|
-
{
|
|
4460
|
-
internalType: "uint256",
|
|
4461
|
-
name: "amount",
|
|
4462
|
-
type: "uint256"
|
|
4463
|
-
}
|
|
4464
|
-
],
|
|
4465
|
-
name: "releaseFee",
|
|
4466
|
-
outputs: [
|
|
4467
|
-
],
|
|
4468
|
-
stateMutability: "nonpayable",
|
|
4469
|
-
type: "function"
|
|
4470
|
-
},
|
|
4471
|
-
{
|
|
4472
|
-
inputs: [
|
|
4473
|
-
{
|
|
4474
|
-
internalType: "address",
|
|
4475
|
-
name: "_wallet",
|
|
4476
|
-
type: "address"
|
|
4477
|
-
}
|
|
4478
|
-
],
|
|
4479
|
-
name: "removeMarketMaker",
|
|
4480
|
-
outputs: [
|
|
4481
|
-
],
|
|
4482
|
-
stateMutability: "nonpayable",
|
|
4483
|
-
type: "function"
|
|
4484
|
-
},
|
|
4485
|
-
{
|
|
4486
|
-
inputs: [
|
|
4487
|
-
],
|
|
4488
|
-
name: "renounceOwnership",
|
|
4489
|
-
outputs: [
|
|
4490
|
-
],
|
|
4491
|
-
stateMutability: "nonpayable",
|
|
4492
|
-
type: "function"
|
|
4493
|
-
},
|
|
4494
|
-
{
|
|
4495
|
-
inputs: [
|
|
4496
|
-
{
|
|
4497
|
-
internalType: "uint8",
|
|
4498
|
-
name: "level",
|
|
4499
|
-
type: "uint8"
|
|
4500
|
-
},
|
|
4501
|
-
{
|
|
4502
|
-
internalType: "uint256",
|
|
4503
|
-
name: "feePercent",
|
|
4504
|
-
type: "uint256"
|
|
4505
|
-
}
|
|
4506
|
-
],
|
|
4507
|
-
name: "setServiceFeePercent",
|
|
4508
|
-
outputs: [
|
|
4509
|
-
],
|
|
4510
|
-
stateMutability: "nonpayable",
|
|
4511
|
-
type: "function"
|
|
4512
|
-
},
|
|
4513
|
-
{
|
|
4514
|
-
inputs: [
|
|
4515
|
-
{
|
|
4516
|
-
internalType: "address",
|
|
4517
|
-
name: "newOwner",
|
|
4518
|
-
type: "address"
|
|
4519
|
-
}
|
|
4520
|
-
],
|
|
4521
|
-
name: "transferOwnership",
|
|
4522
|
-
outputs: [
|
|
4523
|
-
],
|
|
4524
|
-
stateMutability: "nonpayable",
|
|
4525
|
-
type: "function"
|
|
4526
|
-
},
|
|
4527
|
-
{
|
|
4528
|
-
stateMutability: "payable",
|
|
4529
|
-
type: "receive"
|
|
4530
|
-
}
|
|
4531
|
-
];
|
|
4532
|
-
var DarkSwapFeeAssetManagerAbi = {
|
|
4533
|
-
abi: abi$5};
|
|
4534
|
-
|
|
4535
|
-
function getContract(address, darkSwap) {
|
|
4536
|
-
const provider = darkSwap.provider;
|
|
4537
|
-
return new ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4538
|
-
}
|
|
4539
|
-
async function getFeeRatio(wallet, darkSwap) {
|
|
4540
|
-
const contract = getContract(darkSwap.contracts.darkSwapFeeAssetManager, darkSwap);
|
|
4541
|
-
return await contract.getServiceFeePercentage(wallet);
|
|
4542
|
-
}
|
|
4543
|
-
|
|
4544
|
-
var noir_version$4 = "1.0.0-beta.6+e796dfd67726cbc28eb9991782533b211025928d";
|
|
4545
|
-
var hash$4 = "3522014172221315185";
|
|
4546
|
-
var abi$4 = {
|
|
4547
|
-
parameters: [
|
|
4548
|
-
{
|
|
4549
|
-
name: "merkle_root",
|
|
4550
|
-
type: {
|
|
4551
|
-
kind: "field"
|
|
4552
|
-
},
|
|
4553
|
-
visibility: "public"
|
|
4554
|
-
},
|
|
4555
|
-
{
|
|
4556
|
-
name: "merkle_index",
|
|
4557
|
-
type: {
|
|
4558
|
-
kind: "array",
|
|
4559
|
-
length: 32,
|
|
4560
|
-
type: {
|
|
4561
|
-
kind: "integer",
|
|
4562
|
-
sign: "unsigned",
|
|
4563
|
-
width: 1
|
|
4564
|
-
}
|
|
4565
|
-
},
|
|
4566
|
-
visibility: "private"
|
|
4567
|
-
},
|
|
4568
|
-
{
|
|
4569
|
-
name: "merkle_path",
|
|
4570
|
-
type: {
|
|
4571
|
-
kind: "array",
|
|
4572
|
-
length: 32,
|
|
4573
|
-
type: {
|
|
4574
|
-
kind: "field"
|
|
4575
|
-
}
|
|
4576
|
-
},
|
|
4577
|
-
visibility: "private"
|
|
4578
|
-
},
|
|
4579
|
-
{
|
|
4580
|
-
name: "address",
|
|
4581
|
-
type: {
|
|
4582
|
-
kind: "field"
|
|
4583
|
-
},
|
|
4584
|
-
visibility: "public"
|
|
4585
|
-
},
|
|
4586
|
-
{
|
|
4587
|
-
name: "out_note",
|
|
4588
|
-
type: {
|
|
4589
|
-
kind: "field"
|
|
4590
|
-
},
|
|
4591
|
-
visibility: "private"
|
|
4592
|
-
},
|
|
4593
|
-
{
|
|
4594
|
-
name: "out_rho",
|
|
4595
|
-
type: {
|
|
4596
|
-
kind: "field"
|
|
4597
|
-
},
|
|
4598
|
-
visibility: "private"
|
|
4599
|
-
},
|
|
4600
|
-
{
|
|
4601
|
-
name: "out_nullifier",
|
|
4602
|
-
type: {
|
|
4603
|
-
kind: "field"
|
|
4604
|
-
},
|
|
4605
|
-
visibility: "public"
|
|
4606
|
-
},
|
|
4607
|
-
{
|
|
4608
|
-
name: "out_amount",
|
|
4609
|
-
type: {
|
|
4610
|
-
kind: "field"
|
|
4317
|
+
visibility: "public"
|
|
4318
|
+
},
|
|
4319
|
+
{
|
|
4320
|
+
name: "out_amount",
|
|
4321
|
+
type: {
|
|
4322
|
+
kind: "field"
|
|
4611
4323
|
},
|
|
4612
4324
|
visibility: "private"
|
|
4613
4325
|
},
|
|
@@ -4794,7 +4506,7 @@ var brillig_names$4 = [
|
|
|
4794
4506
|
var proCreateOrderCircuit = {
|
|
4795
4507
|
noir_version: noir_version$4,
|
|
4796
4508
|
hash: hash$4,
|
|
4797
|
-
abi: abi$
|
|
4509
|
+
abi: abi$5,
|
|
4798
4510
|
bytecode: bytecode$4,
|
|
4799
4511
|
debug_symbols: debug_symbols$4,
|
|
4800
4512
|
file_map: file_map$4,
|
|
@@ -4868,6 +4580,300 @@ async function generateProCreateOrderProof(param) {
|
|
|
4868
4580
|
};
|
|
4869
4581
|
}
|
|
4870
4582
|
|
|
4583
|
+
var abi$4 = [
|
|
4584
|
+
{
|
|
4585
|
+
inputs: [
|
|
4586
|
+
{
|
|
4587
|
+
internalType: "address",
|
|
4588
|
+
name: "assetPoolERC20",
|
|
4589
|
+
type: "address"
|
|
4590
|
+
},
|
|
4591
|
+
{
|
|
4592
|
+
internalType: "address",
|
|
4593
|
+
name: "assetPoolETH",
|
|
4594
|
+
type: "address"
|
|
4595
|
+
},
|
|
4596
|
+
{
|
|
4597
|
+
internalType: "address",
|
|
4598
|
+
name: "initialOwner",
|
|
4599
|
+
type: "address"
|
|
4600
|
+
}
|
|
4601
|
+
],
|
|
4602
|
+
stateMutability: "nonpayable",
|
|
4603
|
+
type: "constructor"
|
|
4604
|
+
},
|
|
4605
|
+
{
|
|
4606
|
+
inputs: [
|
|
4607
|
+
{
|
|
4608
|
+
internalType: "address",
|
|
4609
|
+
name: "owner",
|
|
4610
|
+
type: "address"
|
|
4611
|
+
}
|
|
4612
|
+
],
|
|
4613
|
+
name: "OwnableInvalidOwner",
|
|
4614
|
+
type: "error"
|
|
4615
|
+
},
|
|
4616
|
+
{
|
|
4617
|
+
inputs: [
|
|
4618
|
+
{
|
|
4619
|
+
internalType: "address",
|
|
4620
|
+
name: "account",
|
|
4621
|
+
type: "address"
|
|
4622
|
+
}
|
|
4623
|
+
],
|
|
4624
|
+
name: "OwnableUnauthorizedAccount",
|
|
4625
|
+
type: "error"
|
|
4626
|
+
},
|
|
4627
|
+
{
|
|
4628
|
+
inputs: [
|
|
4629
|
+
{
|
|
4630
|
+
internalType: "address",
|
|
4631
|
+
name: "token",
|
|
4632
|
+
type: "address"
|
|
4633
|
+
}
|
|
4634
|
+
],
|
|
4635
|
+
name: "SafeERC20FailedOperation",
|
|
4636
|
+
type: "error"
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
anonymous: false,
|
|
4640
|
+
inputs: [
|
|
4641
|
+
{
|
|
4642
|
+
indexed: true,
|
|
4643
|
+
internalType: "address",
|
|
4644
|
+
name: "previousOwner",
|
|
4645
|
+
type: "address"
|
|
4646
|
+
},
|
|
4647
|
+
{
|
|
4648
|
+
indexed: true,
|
|
4649
|
+
internalType: "address",
|
|
4650
|
+
name: "newOwner",
|
|
4651
|
+
type: "address"
|
|
4652
|
+
}
|
|
4653
|
+
],
|
|
4654
|
+
name: "OwnershipTransferred",
|
|
4655
|
+
type: "event"
|
|
4656
|
+
},
|
|
4657
|
+
{
|
|
4658
|
+
stateMutability: "payable",
|
|
4659
|
+
type: "fallback"
|
|
4660
|
+
},
|
|
4661
|
+
{
|
|
4662
|
+
inputs: [
|
|
4663
|
+
{
|
|
4664
|
+
internalType: "address",
|
|
4665
|
+
name: "_wallet",
|
|
4666
|
+
type: "address"
|
|
4667
|
+
},
|
|
4668
|
+
{
|
|
4669
|
+
internalType: "uint8",
|
|
4670
|
+
name: "level",
|
|
4671
|
+
type: "uint8"
|
|
4672
|
+
}
|
|
4673
|
+
],
|
|
4674
|
+
name: "addMarketMaker",
|
|
4675
|
+
outputs: [
|
|
4676
|
+
],
|
|
4677
|
+
stateMutability: "nonpayable",
|
|
4678
|
+
type: "function"
|
|
4679
|
+
},
|
|
4680
|
+
{
|
|
4681
|
+
inputs: [
|
|
4682
|
+
{
|
|
4683
|
+
internalType: "address",
|
|
4684
|
+
name: "wallet",
|
|
4685
|
+
type: "address"
|
|
4686
|
+
},
|
|
4687
|
+
{
|
|
4688
|
+
internalType: "uint256",
|
|
4689
|
+
name: "amount",
|
|
4690
|
+
type: "uint256"
|
|
4691
|
+
}
|
|
4692
|
+
],
|
|
4693
|
+
name: "calculateFee",
|
|
4694
|
+
outputs: [
|
|
4695
|
+
{
|
|
4696
|
+
internalType: "uint256",
|
|
4697
|
+
name: "",
|
|
4698
|
+
type: "uint256"
|
|
4699
|
+
},
|
|
4700
|
+
{
|
|
4701
|
+
internalType: "uint256",
|
|
4702
|
+
name: "",
|
|
4703
|
+
type: "uint256"
|
|
4704
|
+
}
|
|
4705
|
+
],
|
|
4706
|
+
stateMutability: "view",
|
|
4707
|
+
type: "function"
|
|
4708
|
+
},
|
|
4709
|
+
{
|
|
4710
|
+
inputs: [
|
|
4711
|
+
{
|
|
4712
|
+
internalType: "address",
|
|
4713
|
+
name: "asset",
|
|
4714
|
+
type: "address"
|
|
4715
|
+
},
|
|
4716
|
+
{
|
|
4717
|
+
internalType: "uint256",
|
|
4718
|
+
name: "amount",
|
|
4719
|
+
type: "uint256"
|
|
4720
|
+
}
|
|
4721
|
+
],
|
|
4722
|
+
name: "claimFee",
|
|
4723
|
+
outputs: [
|
|
4724
|
+
],
|
|
4725
|
+
stateMutability: "nonpayable",
|
|
4726
|
+
type: "function"
|
|
4727
|
+
},
|
|
4728
|
+
{
|
|
4729
|
+
inputs: [
|
|
4730
|
+
{
|
|
4731
|
+
internalType: "address",
|
|
4732
|
+
name: "_wallet",
|
|
4733
|
+
type: "address"
|
|
4734
|
+
}
|
|
4735
|
+
],
|
|
4736
|
+
name: "getMaketMakerRegistration",
|
|
4737
|
+
outputs: [
|
|
4738
|
+
{
|
|
4739
|
+
internalType: "uint8",
|
|
4740
|
+
name: "",
|
|
4741
|
+
type: "uint8"
|
|
4742
|
+
}
|
|
4743
|
+
],
|
|
4744
|
+
stateMutability: "view",
|
|
4745
|
+
type: "function"
|
|
4746
|
+
},
|
|
4747
|
+
{
|
|
4748
|
+
inputs: [
|
|
4749
|
+
{
|
|
4750
|
+
internalType: "address",
|
|
4751
|
+
name: "wallet",
|
|
4752
|
+
type: "address"
|
|
4753
|
+
}
|
|
4754
|
+
],
|
|
4755
|
+
name: "getServiceFeePercentage",
|
|
4756
|
+
outputs: [
|
|
4757
|
+
{
|
|
4758
|
+
internalType: "uint256",
|
|
4759
|
+
name: "",
|
|
4760
|
+
type: "uint256"
|
|
4761
|
+
}
|
|
4762
|
+
],
|
|
4763
|
+
stateMutability: "view",
|
|
4764
|
+
type: "function"
|
|
4765
|
+
},
|
|
4766
|
+
{
|
|
4767
|
+
inputs: [
|
|
4768
|
+
],
|
|
4769
|
+
name: "owner",
|
|
4770
|
+
outputs: [
|
|
4771
|
+
{
|
|
4772
|
+
internalType: "address",
|
|
4773
|
+
name: "",
|
|
4774
|
+
type: "address"
|
|
4775
|
+
}
|
|
4776
|
+
],
|
|
4777
|
+
stateMutability: "view",
|
|
4778
|
+
type: "function"
|
|
4779
|
+
},
|
|
4780
|
+
{
|
|
4781
|
+
inputs: [
|
|
4782
|
+
{
|
|
4783
|
+
internalType: "address",
|
|
4784
|
+
name: "asset",
|
|
4785
|
+
type: "address"
|
|
4786
|
+
},
|
|
4787
|
+
{
|
|
4788
|
+
internalType: "address",
|
|
4789
|
+
name: "to",
|
|
4790
|
+
type: "address"
|
|
4791
|
+
},
|
|
4792
|
+
{
|
|
4793
|
+
internalType: "uint256",
|
|
4794
|
+
name: "amount",
|
|
4795
|
+
type: "uint256"
|
|
4796
|
+
}
|
|
4797
|
+
],
|
|
4798
|
+
name: "releaseFee",
|
|
4799
|
+
outputs: [
|
|
4800
|
+
],
|
|
4801
|
+
stateMutability: "nonpayable",
|
|
4802
|
+
type: "function"
|
|
4803
|
+
},
|
|
4804
|
+
{
|
|
4805
|
+
inputs: [
|
|
4806
|
+
{
|
|
4807
|
+
internalType: "address",
|
|
4808
|
+
name: "_wallet",
|
|
4809
|
+
type: "address"
|
|
4810
|
+
}
|
|
4811
|
+
],
|
|
4812
|
+
name: "removeMarketMaker",
|
|
4813
|
+
outputs: [
|
|
4814
|
+
],
|
|
4815
|
+
stateMutability: "nonpayable",
|
|
4816
|
+
type: "function"
|
|
4817
|
+
},
|
|
4818
|
+
{
|
|
4819
|
+
inputs: [
|
|
4820
|
+
],
|
|
4821
|
+
name: "renounceOwnership",
|
|
4822
|
+
outputs: [
|
|
4823
|
+
],
|
|
4824
|
+
stateMutability: "nonpayable",
|
|
4825
|
+
type: "function"
|
|
4826
|
+
},
|
|
4827
|
+
{
|
|
4828
|
+
inputs: [
|
|
4829
|
+
{
|
|
4830
|
+
internalType: "uint8",
|
|
4831
|
+
name: "level",
|
|
4832
|
+
type: "uint8"
|
|
4833
|
+
},
|
|
4834
|
+
{
|
|
4835
|
+
internalType: "uint256",
|
|
4836
|
+
name: "feePercent",
|
|
4837
|
+
type: "uint256"
|
|
4838
|
+
}
|
|
4839
|
+
],
|
|
4840
|
+
name: "setServiceFeePercent",
|
|
4841
|
+
outputs: [
|
|
4842
|
+
],
|
|
4843
|
+
stateMutability: "nonpayable",
|
|
4844
|
+
type: "function"
|
|
4845
|
+
},
|
|
4846
|
+
{
|
|
4847
|
+
inputs: [
|
|
4848
|
+
{
|
|
4849
|
+
internalType: "address",
|
|
4850
|
+
name: "newOwner",
|
|
4851
|
+
type: "address"
|
|
4852
|
+
}
|
|
4853
|
+
],
|
|
4854
|
+
name: "transferOwnership",
|
|
4855
|
+
outputs: [
|
|
4856
|
+
],
|
|
4857
|
+
stateMutability: "nonpayable",
|
|
4858
|
+
type: "function"
|
|
4859
|
+
},
|
|
4860
|
+
{
|
|
4861
|
+
stateMutability: "payable",
|
|
4862
|
+
type: "receive"
|
|
4863
|
+
}
|
|
4864
|
+
];
|
|
4865
|
+
var DarkSwapFeeAssetManagerAbi = {
|
|
4866
|
+
abi: abi$4};
|
|
4867
|
+
|
|
4868
|
+
function getContract(address, darkSwap) {
|
|
4869
|
+
const provider = darkSwap.provider;
|
|
4870
|
+
return new ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4871
|
+
}
|
|
4872
|
+
async function getFeeRatio(wallet, darkSwap) {
|
|
4873
|
+
const contract = getContract(darkSwap.contracts.darkSwapFeeAssetManager, darkSwap);
|
|
4874
|
+
return await contract.getServiceFeePercentage(wallet);
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4871
4877
|
class ProCreateOrderContext extends BaseContext {
|
|
4872
4878
|
constructor(signature) {
|
|
4873
4879
|
super(signature);
|
|
@@ -5472,7 +5478,7 @@ class ProCancelOrderService extends BaseContractService {
|
|
|
5472
5478
|
throw new DarkSwapError('Invalid context');
|
|
5473
5479
|
}
|
|
5474
5480
|
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5475
|
-
const tx = await contract.
|
|
5481
|
+
const tx = await contract.cancelOrder(context.merkleRoot, context.proof.orderNullifier, context.proof.oldBalanceNullifier, hexlify32(context.newBalance.note), context.proof.newBalanceNoteFooter, context.proof.proof);
|
|
5476
5482
|
await tx.wait();
|
|
5477
5483
|
return tx.hash;
|
|
5478
5484
|
}
|
|
@@ -5827,247 +5833,103 @@ var brillig_names$2 = [
|
|
|
5827
5833
|
"decompose_hint",
|
|
5828
5834
|
"lte_hint",
|
|
5829
5835
|
"__get_quotient",
|
|
5830
|
-
"__gt",
|
|
5831
|
-
"directive_invert",
|
|
5832
|
-
"directive_to_radix",
|
|
5833
|
-
"directive_integer_quotient"
|
|
5834
|
-
];
|
|
5835
|
-
var swapCircuit = {
|
|
5836
|
-
noir_version: noir_version$2,
|
|
5837
|
-
hash: hash$2,
|
|
5838
|
-
abi: abi$2,
|
|
5839
|
-
bytecode: bytecode$2,
|
|
5840
|
-
debug_symbols: debug_symbols$2,
|
|
5841
|
-
file_map: file_map$2,
|
|
5842
|
-
names: names$2,
|
|
5843
|
-
brillig_names: brillig_names$2
|
|
5844
|
-
};
|
|
5845
|
-
|
|
5846
|
-
async function generateProSwapProof(param) {
|
|
5847
|
-
if (param.aliceOrderNote.feeRatio < 0n
|
|
5848
|
-
|| param.bobMessage.orderNote.feeRatio < 0n) {
|
|
5849
|
-
throw new DarkSwapProofError("Invalid fee ratio");
|
|
5850
|
-
}
|
|
5851
|
-
if (param.aliceChangeNote.amount < 0n
|
|
5852
|
-
|| param.aliceOrderNote.amount <= 0n
|
|
5853
|
-
|| param.aliceInNote.amount <= 0n
|
|
5854
|
-
|| param.bobMessage.inNote.amount <= 0n
|
|
5855
|
-
|| param.bobMessage.orderNote.amount <= 0n) {
|
|
5856
|
-
throw new DarkSwapProofError("Invalid note amount");
|
|
5857
|
-
}
|
|
5858
|
-
if (param.aliceOrderNote.amount != param.aliceChangeNote.amount - param.bobMessage.inNote.amount
|
|
5859
|
-
|| param.bobMessage.orderNote.amount != param.aliceInNote.amount) {
|
|
5860
|
-
throw new DarkSwapProofError("Invalid order amount");
|
|
5861
|
-
}
|
|
5862
|
-
const aliceFeeAmount = param.aliceInNote.amount * param.aliceOrderNote.feeRatio / FEE_RATIO_PRECISION;
|
|
5863
|
-
const bobFeeAmount = param.bobMessage.inNote.amount * param.bobMessage.orderNote.feeRatio / FEE_RATIO_PRECISION;
|
|
5864
|
-
const [[fuzkPubKeyX, fuzkPubKeyY], fuzkPriKey] = await generateKeyPair(param.aliceSignedMessage);
|
|
5865
|
-
const aliceOrderNoteNullifier = calcNullifier(param.aliceOrderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5866
|
-
const aliceInNoteFooter = getNoteFooter(param.aliceInNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5867
|
-
const aliceChangeNoteFooter = getNoteFooter(param.aliceChangeNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5868
|
-
const bobOrderNoteNullifier = calcNullifier(param.bobMessage.orderNote.rho, param.bobMessage.publicKey);
|
|
5869
|
-
const bobInNoteFooter = getNoteFooter(param.bobMessage.inNote.rho, param.bobMessage.publicKey);
|
|
5870
|
-
const aliceAddressMod = encodeAddress(param.aliceAddress);
|
|
5871
|
-
const bobAddressMod = encodeAddress(param.bobAddress);
|
|
5872
|
-
const message = bn_to_hex(mimc_bn254([
|
|
5873
|
-
BigInt(PROOF_DOMAIN.PRO_SWAP),
|
|
5874
|
-
aliceOrderNoteNullifier,
|
|
5875
|
-
param.aliceOrderNote.feeRatio,
|
|
5876
|
-
param.bobMessage.orderNote.feeRatio,
|
|
5877
|
-
bobOrderNoteNullifier,
|
|
5878
|
-
param.aliceInNote.note,
|
|
5879
|
-
param.aliceChangeNote.note,
|
|
5880
|
-
param.bobMessage.inNote.note
|
|
5881
|
-
]));
|
|
5882
|
-
const signature = await signMessage(message, fuzkPriKey);
|
|
5883
|
-
const inputs = {
|
|
5884
|
-
merkle_root: param.merkleRoot,
|
|
5885
|
-
alice_merkle_index: param.aliceMerkleIndex,
|
|
5886
|
-
alice_merkle_path: param.aliceMerklePath,
|
|
5887
|
-
alice_address: bn_to_0xhex(aliceAddressMod),
|
|
5888
|
-
alice_out_note: bn_to_0xhex(param.aliceOrderNote.note),
|
|
5889
|
-
alice_out_rho: bn_to_0xhex(param.aliceOrderNote.rho),
|
|
5890
|
-
alice_out_nullifier: bn_to_0xhex(aliceOrderNoteNullifier),
|
|
5891
|
-
alice_out_amount: bn_to_0xhex(param.aliceOrderNote.amount),
|
|
5892
|
-
alice_fee_ratio: bn_to_0xhex(param.aliceOrderNote.feeRatio),
|
|
5893
|
-
alice_fee_amount: bn_to_0xhex(aliceFeeAmount),
|
|
5894
|
-
alice_in_note: bn_to_0xhex(param.aliceInNote.note),
|
|
5895
|
-
alice_in_rho: bn_to_0xhex(param.aliceInNote.rho),
|
|
5896
|
-
alice_in_note_footer: bn_to_0xhex(aliceInNoteFooter),
|
|
5897
|
-
alice_change_note: bn_to_0xhex(param.aliceChangeNote.note),
|
|
5898
|
-
alice_change_rho: bn_to_0xhex(param.aliceChangeNote.rho),
|
|
5899
|
-
alice_change_note_footer: bn_to_0xhex(aliceChangeNoteFooter),
|
|
5900
|
-
alice_pub_key: [fuzkPubKeyX.toString(), fuzkPubKeyY.toString()],
|
|
5901
|
-
alice_signature: uint8ArrayToNumberArray(signature),
|
|
5902
|
-
bob_out_asset: bn_to_0xhex(encodeAddress(param.bobMessage.orderNote.asset)),
|
|
5903
|
-
bob_out_amount: bn_to_0xhex(param.bobMessage.orderNote.amount),
|
|
5904
|
-
bob_in_asset: bn_to_0xhex(encodeAddress(param.bobMessage.inNote.asset)),
|
|
5905
|
-
bob_in_amount: bn_to_0xhex(param.bobMessage.inNote.amount),
|
|
5906
|
-
bob_merkle_index: param.bobMerkleIndex,
|
|
5907
|
-
bob_merkle_path: param.bobMerklePath,
|
|
5908
|
-
bob_address: bn_to_0xhex(bobAddressMod),
|
|
5909
|
-
bob_out_note: bn_to_0xhex(param.bobMessage.orderNote.note),
|
|
5910
|
-
bob_out_rho: bn_to_0xhex(param.bobMessage.orderNote.rho),
|
|
5911
|
-
bob_out_nullifier: bn_to_0xhex(bobOrderNoteNullifier),
|
|
5912
|
-
bob_fee_ratio: bn_to_0xhex(param.bobMessage.orderNote.feeRatio),
|
|
5913
|
-
bob_fee_amount: bn_to_0xhex(bobFeeAmount),
|
|
5914
|
-
bob_in_note: bn_to_0xhex(param.bobMessage.inNote.note),
|
|
5915
|
-
bob_in_rho: bn_to_0xhex(param.bobMessage.inNote.rho),
|
|
5916
|
-
bob_in_note_footer: bn_to_0xhex(bobInNoteFooter),
|
|
5917
|
-
bob_pub_key: [param.bobMessage.publicKey[0].toString(), param.bobMessage.publicKey[1].toString()],
|
|
5918
|
-
bob_signature: uint8ArrayToNumberArray(hexStringToSignature(param.bobMessage.signature)),
|
|
5919
|
-
};
|
|
5920
|
-
const proof = await generateProof(swapCircuit, inputs);
|
|
5921
|
-
return {
|
|
5922
|
-
...proof,
|
|
5923
|
-
aliceOutNullifier: inputs.alice_out_nullifier,
|
|
5924
|
-
aliceInNoteFooter: inputs.alice_in_note_footer,
|
|
5925
|
-
aliceChangeNoteFooter: inputs.alice_change_note_footer,
|
|
5926
|
-
bobOutNullifier: inputs.bob_out_nullifier,
|
|
5927
|
-
bobInNoteFooter: inputs.bob_in_note_footer,
|
|
5928
|
-
};
|
|
5929
|
-
}
|
|
5930
|
-
|
|
5931
|
-
class ProSwapContext extends BaseContext {
|
|
5932
|
-
constructor(signature) {
|
|
5933
|
-
super(signature);
|
|
5934
|
-
Object.defineProperty(this, "_orderNote", {
|
|
5935
|
-
enumerable: true,
|
|
5936
|
-
configurable: true,
|
|
5937
|
-
writable: true,
|
|
5938
|
-
value: void 0
|
|
5939
|
-
});
|
|
5940
|
-
Object.defineProperty(this, "_changeNote", {
|
|
5941
|
-
enumerable: true,
|
|
5942
|
-
configurable: true,
|
|
5943
|
-
writable: true,
|
|
5944
|
-
value: void 0
|
|
5945
|
-
});
|
|
5946
|
-
Object.defineProperty(this, "_swapInNote", {
|
|
5947
|
-
enumerable: true,
|
|
5948
|
-
configurable: true,
|
|
5949
|
-
writable: true,
|
|
5950
|
-
value: void 0
|
|
5951
|
-
});
|
|
5952
|
-
Object.defineProperty(this, "_proof", {
|
|
5953
|
-
enumerable: true,
|
|
5954
|
-
configurable: true,
|
|
5955
|
-
writable: true,
|
|
5956
|
-
value: void 0
|
|
5957
|
-
});
|
|
5958
|
-
Object.defineProperty(this, "_bobAddress", {
|
|
5959
|
-
enumerable: true,
|
|
5960
|
-
configurable: true,
|
|
5961
|
-
writable: true,
|
|
5962
|
-
value: void 0
|
|
5963
|
-
});
|
|
5964
|
-
Object.defineProperty(this, "_bobSwapMessage", {
|
|
5965
|
-
enumerable: true,
|
|
5966
|
-
configurable: true,
|
|
5967
|
-
writable: true,
|
|
5968
|
-
value: void 0
|
|
5969
|
-
});
|
|
5970
|
-
}
|
|
5971
|
-
set orderNote(orderNote) {
|
|
5972
|
-
this._orderNote = orderNote;
|
|
5973
|
-
}
|
|
5974
|
-
get orderNote() {
|
|
5975
|
-
return this._orderNote;
|
|
5976
|
-
}
|
|
5977
|
-
set changeNote(changeNote) {
|
|
5978
|
-
this._changeNote = changeNote;
|
|
5979
|
-
}
|
|
5980
|
-
get changeNote() {
|
|
5981
|
-
return this._changeNote;
|
|
5982
|
-
}
|
|
5983
|
-
set swapInNote(swapInNote) {
|
|
5984
|
-
this._swapInNote = swapInNote;
|
|
5985
|
-
}
|
|
5986
|
-
get swapInNote() {
|
|
5987
|
-
return this._swapInNote;
|
|
5988
|
-
}
|
|
5989
|
-
set proof(proof) {
|
|
5990
|
-
this._proof = proof;
|
|
5991
|
-
}
|
|
5992
|
-
get proof() {
|
|
5993
|
-
return this._proof;
|
|
5994
|
-
}
|
|
5995
|
-
set bobSwapMessage(bobSwapMessage) {
|
|
5996
|
-
this._bobSwapMessage = bobSwapMessage;
|
|
5997
|
-
}
|
|
5998
|
-
get bobSwapMessage() {
|
|
5999
|
-
return this._bobSwapMessage;
|
|
6000
|
-
}
|
|
6001
|
-
set bobAddress(bobAddress) {
|
|
6002
|
-
this._bobAddress = bobAddress;
|
|
6003
|
-
}
|
|
6004
|
-
get bobAddress() {
|
|
6005
|
-
return this._bobAddress;
|
|
6006
|
-
}
|
|
6007
|
-
}
|
|
6008
|
-
class ProSwapService extends BaseContractService {
|
|
6009
|
-
constructor(_darkSwap) {
|
|
6010
|
-
super(_darkSwap);
|
|
6011
|
-
}
|
|
6012
|
-
async prepare(address, orderNote, swapOutAmount, swapInAmount, bobAddress, bobSwapMessage, signature) {
|
|
6013
|
-
const [pubKey, privKey] = await generateKeyPair(signature);
|
|
6014
|
-
const changeNote = createNote(address, orderNote.asset, orderNote.amount - swapOutAmount, pubKey);
|
|
6015
|
-
const swapInNote = createNote(address, bobSwapMessage.orderNote.asset, swapInAmount, pubKey);
|
|
6016
|
-
const context = new ProSwapContext(signature);
|
|
6017
|
-
context.orderNote = orderNote;
|
|
6018
|
-
context.swapInNote = swapInNote;
|
|
6019
|
-
context.changeNote = changeNote;
|
|
6020
|
-
context.address = address;
|
|
6021
|
-
context.bobAddress = bobAddress;
|
|
6022
|
-
context.bobSwapMessage = bobSwapMessage;
|
|
6023
|
-
return { context, swapInNote, changeNote };
|
|
6024
|
-
}
|
|
6025
|
-
async generateProof(context) {
|
|
6026
|
-
if (!context
|
|
6027
|
-
|| !context.orderNote
|
|
6028
|
-
|| !context.swapInNote
|
|
6029
|
-
|| !context.changeNote
|
|
6030
|
-
|| !context.address
|
|
6031
|
-
|| !context.signature
|
|
6032
|
-
|| !context.bobSwapMessage
|
|
6033
|
-
|| !context.bobAddress) {
|
|
6034
|
-
throw new DarkSwapError('Invalid context');
|
|
6035
|
-
}
|
|
6036
|
-
const merklePathes = await multiGetMerklePathAndRoot([context.orderNote.note, context.bobSwapMessage.orderNote.note], this._darkSwap);
|
|
6037
|
-
const orderNotePath = merklePathes[0];
|
|
6038
|
-
const bobSwapMessagePath = merklePathes[1];
|
|
6039
|
-
const proof = await generateProSwapProof({
|
|
6040
|
-
merkleRoot: orderNotePath.root,
|
|
6041
|
-
aliceAddress: context.address,
|
|
6042
|
-
aliceMerkleIndex: orderNotePath.index,
|
|
6043
|
-
aliceMerklePath: orderNotePath.path,
|
|
6044
|
-
aliceOrderNote: context.orderNote,
|
|
6045
|
-
aliceChangeNote: context.changeNote,
|
|
6046
|
-
aliceInNote: context.swapInNote,
|
|
6047
|
-
aliceSignedMessage: context.signature,
|
|
6048
|
-
bobAddress: context.bobAddress,
|
|
6049
|
-
bobMerkleIndex: bobSwapMessagePath.index,
|
|
6050
|
-
bobMerklePath: bobSwapMessagePath.path,
|
|
6051
|
-
bobMessage: context.bobSwapMessage,
|
|
6052
|
-
});
|
|
6053
|
-
context.merkleRoot = orderNotePath.root;
|
|
6054
|
-
context.proof = proof;
|
|
5836
|
+
"__gt",
|
|
5837
|
+
"directive_invert",
|
|
5838
|
+
"directive_to_radix",
|
|
5839
|
+
"directive_integer_quotient"
|
|
5840
|
+
];
|
|
5841
|
+
var swapCircuit = {
|
|
5842
|
+
noir_version: noir_version$2,
|
|
5843
|
+
hash: hash$2,
|
|
5844
|
+
abi: abi$2,
|
|
5845
|
+
bytecode: bytecode$2,
|
|
5846
|
+
debug_symbols: debug_symbols$2,
|
|
5847
|
+
file_map: file_map$2,
|
|
5848
|
+
names: names$2,
|
|
5849
|
+
brillig_names: brillig_names$2
|
|
5850
|
+
};
|
|
5851
|
+
|
|
5852
|
+
async function generateProSwapProof(param) {
|
|
5853
|
+
if (param.aliceOrderNote.feeRatio < 0n
|
|
5854
|
+
|| param.bobMessage.orderNote.feeRatio < 0n) {
|
|
5855
|
+
throw new DarkSwapProofError("Invalid fee ratio");
|
|
6055
5856
|
}
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
}
|
|
6067
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6068
|
-
const tx = await contract.proSwap(context.proof.aliceOutNullifier, context.proof.aliceChangeNoteFooter, context.proof.aliceInNoteFooter, context.proof.bobOutNullifier, context.proof.bobInNoteFooter, context.proof.proof);
|
|
6069
|
-
return tx.hash;
|
|
5857
|
+
if (param.aliceChangeNote.amount < 0n
|
|
5858
|
+
|| param.aliceOrderNote.amount <= 0n
|
|
5859
|
+
|| param.aliceInNote.amount <= 0n
|
|
5860
|
+
|| param.bobMessage.inNote.amount <= 0n
|
|
5861
|
+
|| param.bobMessage.orderNote.amount <= 0n) {
|
|
5862
|
+
throw new DarkSwapProofError("Invalid note amount");
|
|
5863
|
+
}
|
|
5864
|
+
if (param.aliceOrderNote.amount != param.aliceChangeNote.amount + param.bobMessage.inNote.amount + param.bobMessage.feeAmount
|
|
5865
|
+
|| param.bobMessage.orderNote.amount != param.aliceInNote.amount + param.aliceFeeAmount) {
|
|
5866
|
+
throw new DarkSwapProofError("Invalid order amount");
|
|
6070
5867
|
}
|
|
5868
|
+
const [[fuzkPubKeyX, fuzkPubKeyY], fuzkPriKey] = await generateKeyPair(param.aliceSignedMessage);
|
|
5869
|
+
const aliceOrderNoteNullifier = calcNullifier(param.aliceOrderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5870
|
+
const aliceInNoteFooter = getNoteFooter(param.aliceInNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5871
|
+
const aliceChangeNoteFooter = param.aliceChangeNote.amount == 0n ? EMPTY_FOOTER : getNoteFooter(param.aliceChangeNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5872
|
+
const bobOrderNoteNullifier = calcNullifier(param.bobMessage.orderNote.rho, param.bobMessage.publicKey);
|
|
5873
|
+
const bobInNoteFooter = getNoteFooter(param.bobMessage.inNote.rho, param.bobMessage.publicKey);
|
|
5874
|
+
const aliceAddressMod = encodeAddress(param.aliceAddress);
|
|
5875
|
+
const bobAddressMod = encodeAddress(param.bobAddress);
|
|
5876
|
+
const message = bn_to_hex(mimc_bn254([
|
|
5877
|
+
BigInt(PROOF_DOMAIN.PRO_SWAP),
|
|
5878
|
+
aliceOrderNoteNullifier,
|
|
5879
|
+
param.aliceOrderNote.feeRatio,
|
|
5880
|
+
param.bobMessage.orderNote.feeRatio,
|
|
5881
|
+
bobOrderNoteNullifier,
|
|
5882
|
+
param.aliceInNote.note,
|
|
5883
|
+
param.aliceChangeNote.note,
|
|
5884
|
+
param.bobMessage.inNote.note
|
|
5885
|
+
]));
|
|
5886
|
+
const signature = await signMessage(message, fuzkPriKey);
|
|
5887
|
+
const inputs = {
|
|
5888
|
+
merkle_root: param.merkleRoot,
|
|
5889
|
+
alice_merkle_index: param.aliceMerkleIndex,
|
|
5890
|
+
alice_merkle_path: param.aliceMerklePath,
|
|
5891
|
+
alice_address: bn_to_0xhex(aliceAddressMod),
|
|
5892
|
+
alice_out_note: bn_to_0xhex(param.aliceOrderNote.note),
|
|
5893
|
+
alice_out_rho: bn_to_0xhex(param.aliceOrderNote.rho),
|
|
5894
|
+
alice_out_nullifier: bn_to_0xhex(aliceOrderNoteNullifier),
|
|
5895
|
+
alice_out_amount: bn_to_0xhex(param.aliceOrderNote.amount),
|
|
5896
|
+
alice_fee_ratio: bn_to_0xhex(param.aliceOrderNote.feeRatio),
|
|
5897
|
+
alice_fee_amount: bn_to_0xhex(param.aliceFeeAmount),
|
|
5898
|
+
alice_in_note: bn_to_0xhex(param.aliceInNote.note),
|
|
5899
|
+
alice_in_rho: bn_to_0xhex(param.aliceInNote.rho),
|
|
5900
|
+
alice_in_note_footer: bn_to_0xhex(aliceInNoteFooter),
|
|
5901
|
+
alice_change_note: bn_to_0xhex(param.aliceChangeNote.note),
|
|
5902
|
+
alice_change_rho: bn_to_0xhex(param.aliceChangeNote.rho),
|
|
5903
|
+
alice_change_note_footer: bn_to_0xhex(aliceChangeNoteFooter),
|
|
5904
|
+
alice_pub_key: [fuzkPubKeyX.toString(), fuzkPubKeyY.toString()],
|
|
5905
|
+
alice_signature: uint8ArrayToNumberArray(signature),
|
|
5906
|
+
bob_out_asset: bn_to_0xhex(encodeAddress(param.bobMessage.orderNote.asset)),
|
|
5907
|
+
bob_out_amount: bn_to_0xhex(param.bobMessage.orderNote.amount),
|
|
5908
|
+
bob_in_asset: bn_to_0xhex(encodeAddress(param.bobMessage.inNote.asset)),
|
|
5909
|
+
bob_in_amount: bn_to_0xhex(param.bobMessage.inNote.amount + param.bobMessage.feeAmount),
|
|
5910
|
+
bob_merkle_index: param.bobMerkleIndex,
|
|
5911
|
+
bob_merkle_path: param.bobMerklePath,
|
|
5912
|
+
bob_address: bn_to_0xhex(bobAddressMod),
|
|
5913
|
+
bob_out_note: bn_to_0xhex(param.bobMessage.orderNote.note),
|
|
5914
|
+
bob_out_rho: bn_to_0xhex(param.bobMessage.orderNote.rho),
|
|
5915
|
+
bob_out_nullifier: bn_to_0xhex(bobOrderNoteNullifier),
|
|
5916
|
+
bob_fee_ratio: bn_to_0xhex(param.bobMessage.orderNote.feeRatio),
|
|
5917
|
+
bob_fee_amount: bn_to_0xhex(param.bobMessage.feeAmount),
|
|
5918
|
+
bob_in_note: bn_to_0xhex(param.bobMessage.inNote.note),
|
|
5919
|
+
bob_in_rho: bn_to_0xhex(param.bobMessage.inNote.rho),
|
|
5920
|
+
bob_in_note_footer: bn_to_0xhex(bobInNoteFooter),
|
|
5921
|
+
bob_pub_key: [param.bobMessage.publicKey[0].toString(), param.bobMessage.publicKey[1].toString()],
|
|
5922
|
+
bob_signature: uint8ArrayToNumberArray(hexStringToSignature(param.bobMessage.signature)),
|
|
5923
|
+
};
|
|
5924
|
+
const proof = await generateProof(swapCircuit, inputs);
|
|
5925
|
+
return {
|
|
5926
|
+
...proof,
|
|
5927
|
+
aliceOutNullifier: inputs.alice_out_nullifier,
|
|
5928
|
+
aliceInNoteFooter: inputs.alice_in_note_footer,
|
|
5929
|
+
aliceChangeNoteFooter: inputs.alice_change_note_footer,
|
|
5930
|
+
bobOutNullifier: inputs.bob_out_nullifier,
|
|
5931
|
+
bobInNoteFooter: inputs.bob_in_note_footer,
|
|
5932
|
+
};
|
|
6071
5933
|
}
|
|
6072
5934
|
|
|
6073
5935
|
var noir_version$1 = "1.0.0-beta.6+e796dfd67726cbc28eb9991782533b211025928d";
|
|
@@ -6265,21 +6127,23 @@ var retailCreateOrderCircuit = {
|
|
|
6265
6127
|
brillig_names: brillig_names$1
|
|
6266
6128
|
};
|
|
6267
6129
|
|
|
6268
|
-
async function generateRetailSwapMessage(address, orderNote, swapInNote, pubKey, privKey) {
|
|
6130
|
+
async function generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey) {
|
|
6269
6131
|
const addressMod = encodeAddress(address);
|
|
6270
|
-
const orderNoteNullifier =
|
|
6132
|
+
const orderNoteNullifier = calcNullifier(orderNote.rho, pubKey);
|
|
6271
6133
|
const message = bn_to_hex(mimc_bn254([
|
|
6272
6134
|
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6273
6135
|
addressMod,
|
|
6274
|
-
|
|
6136
|
+
orderNoteNullifier,
|
|
6275
6137
|
orderNote.feeRatio,
|
|
6276
6138
|
swapInNote.note,
|
|
6277
6139
|
]));
|
|
6278
6140
|
const signature = await signMessage(message, privKey);
|
|
6279
6141
|
return {
|
|
6142
|
+
address: address,
|
|
6280
6143
|
orderNote: orderNote,
|
|
6281
|
-
orderNullifier: orderNoteNullifier,
|
|
6144
|
+
orderNullifier: bn_to_0xhex(orderNoteNullifier),
|
|
6282
6145
|
inNote: swapInNote,
|
|
6146
|
+
feeAmount: feeAmount,
|
|
6283
6147
|
publicKey: pubKey,
|
|
6284
6148
|
signature: signatureToHexString(signature),
|
|
6285
6149
|
};
|
|
@@ -6332,9 +6196,183 @@ async function generateRetailCreateOrderProof(param) {
|
|
|
6332
6196
|
};
|
|
6333
6197
|
}
|
|
6334
6198
|
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6199
|
+
class ProSwapContext extends BaseContext {
|
|
6200
|
+
constructor(signature) {
|
|
6201
|
+
super(signature);
|
|
6202
|
+
Object.defineProperty(this, "_orderNote", {
|
|
6203
|
+
enumerable: true,
|
|
6204
|
+
configurable: true,
|
|
6205
|
+
writable: true,
|
|
6206
|
+
value: void 0
|
|
6207
|
+
});
|
|
6208
|
+
Object.defineProperty(this, "_changeNote", {
|
|
6209
|
+
enumerable: true,
|
|
6210
|
+
configurable: true,
|
|
6211
|
+
writable: true,
|
|
6212
|
+
value: void 0
|
|
6213
|
+
});
|
|
6214
|
+
Object.defineProperty(this, "_swapInNote", {
|
|
6215
|
+
enumerable: true,
|
|
6216
|
+
configurable: true,
|
|
6217
|
+
writable: true,
|
|
6218
|
+
value: void 0
|
|
6219
|
+
});
|
|
6220
|
+
Object.defineProperty(this, "_proof", {
|
|
6221
|
+
enumerable: true,
|
|
6222
|
+
configurable: true,
|
|
6223
|
+
writable: true,
|
|
6224
|
+
value: void 0
|
|
6225
|
+
});
|
|
6226
|
+
Object.defineProperty(this, "_bobAddress", {
|
|
6227
|
+
enumerable: true,
|
|
6228
|
+
configurable: true,
|
|
6229
|
+
writable: true,
|
|
6230
|
+
value: void 0
|
|
6231
|
+
});
|
|
6232
|
+
Object.defineProperty(this, "_bobSwapMessage", {
|
|
6233
|
+
enumerable: true,
|
|
6234
|
+
configurable: true,
|
|
6235
|
+
writable: true,
|
|
6236
|
+
value: void 0
|
|
6237
|
+
});
|
|
6238
|
+
Object.defineProperty(this, "_aliceFeeAmount", {
|
|
6239
|
+
enumerable: true,
|
|
6240
|
+
configurable: true,
|
|
6241
|
+
writable: true,
|
|
6242
|
+
value: void 0
|
|
6243
|
+
});
|
|
6244
|
+
}
|
|
6245
|
+
set orderNote(orderNote) {
|
|
6246
|
+
this._orderNote = orderNote;
|
|
6247
|
+
}
|
|
6248
|
+
get orderNote() {
|
|
6249
|
+
return this._orderNote;
|
|
6250
|
+
}
|
|
6251
|
+
set changeNote(changeNote) {
|
|
6252
|
+
this._changeNote = changeNote;
|
|
6253
|
+
}
|
|
6254
|
+
get changeNote() {
|
|
6255
|
+
return this._changeNote;
|
|
6256
|
+
}
|
|
6257
|
+
set swapInNote(swapInNote) {
|
|
6258
|
+
this._swapInNote = swapInNote;
|
|
6259
|
+
}
|
|
6260
|
+
get swapInNote() {
|
|
6261
|
+
return this._swapInNote;
|
|
6262
|
+
}
|
|
6263
|
+
set aliceFeeAmount(aliceFeeAmount) {
|
|
6264
|
+
this._aliceFeeAmount = aliceFeeAmount;
|
|
6265
|
+
}
|
|
6266
|
+
get aliceFeeAmount() {
|
|
6267
|
+
return this._aliceFeeAmount;
|
|
6268
|
+
}
|
|
6269
|
+
set proof(proof) {
|
|
6270
|
+
this._proof = proof;
|
|
6271
|
+
}
|
|
6272
|
+
get proof() {
|
|
6273
|
+
return this._proof;
|
|
6274
|
+
}
|
|
6275
|
+
set bobSwapMessage(bobSwapMessage) {
|
|
6276
|
+
this._bobSwapMessage = bobSwapMessage;
|
|
6277
|
+
}
|
|
6278
|
+
get bobSwapMessage() {
|
|
6279
|
+
return this._bobSwapMessage;
|
|
6280
|
+
}
|
|
6281
|
+
set bobAddress(bobAddress) {
|
|
6282
|
+
this._bobAddress = bobAddress;
|
|
6283
|
+
}
|
|
6284
|
+
get bobAddress() {
|
|
6285
|
+
return this._bobAddress;
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6288
|
+
class ProSwapService extends BaseContractService {
|
|
6289
|
+
constructor(_darkSwap) {
|
|
6290
|
+
super(_darkSwap);
|
|
6291
|
+
}
|
|
6292
|
+
static async prepareProSwapMessageForBob(address, orderNote, swapInAmount, swapInAsset, signature) {
|
|
6293
|
+
const [pubKey, privKey] = await generateKeyPair(signature);
|
|
6294
|
+
const feeAmount = swapInAmount * orderNote.feeRatio / FEE_RATIO_PRECISION;
|
|
6295
|
+
const swapInNote = createNote(address, swapInAsset, swapInAmount - feeAmount, pubKey);
|
|
6296
|
+
const darkSwapMessage = await generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey);
|
|
6297
|
+
return darkSwapMessage;
|
|
6298
|
+
}
|
|
6299
|
+
async prepare(address, orderNote, bobAddress, bobSwapMessage, signature) {
|
|
6300
|
+
const [pubKey] = await generateKeyPair(signature);
|
|
6301
|
+
const swapOutAmount = bobSwapMessage.feeAmount + bobSwapMessage.inNote.amount;
|
|
6302
|
+
const swapInAmount = bobSwapMessage.orderNote.amount;
|
|
6303
|
+
const aliceFeeAmount = swapInAmount * orderNote.feeRatio / FEE_RATIO_PRECISION;
|
|
6304
|
+
const changeNote = createNote(address, orderNote.asset, orderNote.amount - swapOutAmount, pubKey);
|
|
6305
|
+
const swapInNote = createNote(address, bobSwapMessage.orderNote.asset, swapInAmount - aliceFeeAmount, pubKey);
|
|
6306
|
+
const context = new ProSwapContext(signature);
|
|
6307
|
+
context.orderNote = orderNote;
|
|
6308
|
+
context.swapInNote = swapInNote;
|
|
6309
|
+
context.changeNote = changeNote;
|
|
6310
|
+
context.aliceFeeAmount = aliceFeeAmount;
|
|
6311
|
+
context.address = address;
|
|
6312
|
+
context.bobAddress = bobAddress;
|
|
6313
|
+
context.bobSwapMessage = bobSwapMessage;
|
|
6314
|
+
return { context, swapInNote, changeNote, feeAmount: aliceFeeAmount };
|
|
6315
|
+
}
|
|
6316
|
+
async generateProof(context) {
|
|
6317
|
+
if (!context
|
|
6318
|
+
|| !context.orderNote
|
|
6319
|
+
|| !context.swapInNote
|
|
6320
|
+
|| !context.changeNote
|
|
6321
|
+
|| !context.address
|
|
6322
|
+
|| !context.signature
|
|
6323
|
+
|| !context.bobSwapMessage
|
|
6324
|
+
|| !context.bobAddress) {
|
|
6325
|
+
throw new DarkSwapError('Invalid context');
|
|
6326
|
+
}
|
|
6327
|
+
const merklePathes = await multiGetMerklePathAndRoot([context.orderNote.note, context.bobSwapMessage.orderNote.note], this._darkSwap);
|
|
6328
|
+
const orderNotePath = merklePathes[0];
|
|
6329
|
+
const bobOrderNotePath = merklePathes[1];
|
|
6330
|
+
const proof = await generateProSwapProof({
|
|
6331
|
+
merkleRoot: orderNotePath.root,
|
|
6332
|
+
aliceAddress: context.address,
|
|
6333
|
+
aliceMerkleIndex: orderNotePath.index,
|
|
6334
|
+
aliceMerklePath: orderNotePath.path,
|
|
6335
|
+
aliceOrderNote: context.orderNote,
|
|
6336
|
+
aliceChangeNote: context.changeNote,
|
|
6337
|
+
aliceInNote: context.swapInNote,
|
|
6338
|
+
aliceFeeAmount: context.aliceFeeAmount,
|
|
6339
|
+
aliceSignedMessage: context.signature,
|
|
6340
|
+
bobAddress: context.bobAddress,
|
|
6341
|
+
bobMerkleIndex: bobOrderNotePath.index,
|
|
6342
|
+
bobMerklePath: bobOrderNotePath.path,
|
|
6343
|
+
bobMessage: context.bobSwapMessage,
|
|
6344
|
+
});
|
|
6345
|
+
context.merkleRoot = orderNotePath.root;
|
|
6346
|
+
context.proof = proof;
|
|
6347
|
+
}
|
|
6348
|
+
async execute(context) {
|
|
6349
|
+
await this.generateProof(context);
|
|
6350
|
+
if (!context
|
|
6351
|
+
|| !context.orderNote
|
|
6352
|
+
|| !context.swapInNote
|
|
6353
|
+
|| !context.changeNote
|
|
6354
|
+
|| !context.proof
|
|
6355
|
+
|| !context.bobSwapMessage
|
|
6356
|
+
|| !context.bobAddress) {
|
|
6357
|
+
throw new DarkSwapError('Invalid context');
|
|
6358
|
+
}
|
|
6359
|
+
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6360
|
+
const tx = await contract.proSwap([
|
|
6361
|
+
context.merkleRoot,
|
|
6362
|
+
context.proof.aliceOutNullifier,
|
|
6363
|
+
hexlify32(context.orderNote.feeRatio),
|
|
6364
|
+
hexlify32(context.swapInNote.note),
|
|
6365
|
+
context.proof.aliceInNoteFooter,
|
|
6366
|
+
hexlify32(context.changeNote.note),
|
|
6367
|
+
context.proof.aliceChangeNoteFooter,
|
|
6368
|
+
context.proof.bobOutNullifier,
|
|
6369
|
+
hexlify32(context.bobSwapMessage.orderNote.feeRatio),
|
|
6370
|
+
hexlify32(context.bobSwapMessage.inNote.note),
|
|
6371
|
+
context.proof.bobInNoteFooter
|
|
6372
|
+
], context.proof.proof);
|
|
6373
|
+
await tx.wait();
|
|
6374
|
+
return tx.hash;
|
|
6375
|
+
}
|
|
6338
6376
|
}
|
|
6339
6377
|
|
|
6340
6378
|
var noir_version = "1.0.0-beta.6+e796dfd67726cbc28eb9991782533b211025928d";
|
|
@@ -6709,7 +6747,7 @@ class RetailCreateOrderService extends BaseContractService {
|
|
|
6709
6747
|
context.swapInNote = swapInNote;
|
|
6710
6748
|
context.feeAmount = feeAmount;
|
|
6711
6749
|
context.address = address;
|
|
6712
|
-
const swapMessage = await generateRetailSwapMessage(address, orderNote, swapInNote, pubKey, privKey);
|
|
6750
|
+
const swapMessage = await generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey);
|
|
6713
6751
|
context.swapMessage = swapMessage;
|
|
6714
6752
|
return { context, swapMessage };
|
|
6715
6753
|
}
|
|
@@ -6851,19 +6889,33 @@ class DarkSwap {
|
|
|
6851
6889
|
|
|
6852
6890
|
function serializeDarkSwapMessage(swapMessage) {
|
|
6853
6891
|
return JSON.stringify({
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6892
|
+
address: swapMessage.address,
|
|
6893
|
+
orderNote: {
|
|
6894
|
+
rho: swapMessage.orderNote.rho.toString(),
|
|
6895
|
+
amount: swapMessage.orderNote.amount.toString(),
|
|
6896
|
+
asset: swapMessage.orderNote.asset,
|
|
6897
|
+
note: swapMessage.orderNote.note.toString(),
|
|
6898
|
+
feeRatio: swapMessage.orderNote.feeRatio.toString(),
|
|
6899
|
+
},
|
|
6858
6900
|
orderNullifier: swapMessage.orderNullifier,
|
|
6901
|
+
inNote: {
|
|
6902
|
+
rho: swapMessage.inNote.rho.toString(),
|
|
6903
|
+
amount: swapMessage.inNote.amount.toString(),
|
|
6904
|
+
asset: swapMessage.inNote.asset,
|
|
6905
|
+
note: swapMessage.inNote.note.toString(),
|
|
6906
|
+
},
|
|
6907
|
+
feeAmount: swapMessage.feeAmount.toString(),
|
|
6908
|
+
pubKey: [swapMessage.publicKey[0].toString(), swapMessage.publicKey[1].toString()],
|
|
6909
|
+
signature: swapMessage.signature,
|
|
6859
6910
|
});
|
|
6860
6911
|
}
|
|
6861
6912
|
function deserializePublicKey(publicKeyString) {
|
|
6862
|
-
return [Fr.
|
|
6913
|
+
return [Fr.fromHexString(publicKeyString[0]), Fr.fromHexString(publicKeyString[1])];
|
|
6863
6914
|
}
|
|
6864
6915
|
function deserializeDarkSwapMessage(serializedMessage) {
|
|
6865
6916
|
const message = JSON.parse(serializedMessage);
|
|
6866
6917
|
return {
|
|
6918
|
+
address: message.address,
|
|
6867
6919
|
orderNote: {
|
|
6868
6920
|
rho: BigInt(message.orderNote.rho),
|
|
6869
6921
|
amount: BigInt(message.orderNote.amount),
|
|
@@ -6871,6 +6923,7 @@ function deserializeDarkSwapMessage(serializedMessage) {
|
|
|
6871
6923
|
note: BigInt(message.orderNote.note),
|
|
6872
6924
|
feeRatio: BigInt(message.orderNote.feeRatio),
|
|
6873
6925
|
},
|
|
6926
|
+
feeAmount: BigInt(message.feeAmount),
|
|
6874
6927
|
inNote: {
|
|
6875
6928
|
rho: BigInt(message.inNote.rho),
|
|
6876
6929
|
amount: BigInt(message.inNote.amount),
|
|
@@ -6883,5 +6936,5 @@ function deserializeDarkSwapMessage(serializedMessage) {
|
|
|
6883
6936
|
};
|
|
6884
6937
|
}
|
|
6885
6938
|
|
|
6886
|
-
export { ChainId, DEFAULT_FEE_RATIO, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCancelOrderService, ProCreateOrderService, ProSwapService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, deserializeDarkSwapMessage, generateKeyPair,
|
|
6939
|
+
export { ChainId, DEFAULT_FEE_RATIO, DOMAIN_NOTE, DOMAIN_ORDER_NOTE, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NOTE, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCancelOrderService, ProCreateOrderService, ProSwapService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, calcNullifier, contractConfig, createNote, createOrderNoteExt, deserializeDarkSwapMessage, generateKeyPair, getFeeRatio, getMerklePathAndRoot, getNoteFooter, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, getNullifierBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot, serializeDarkSwapMessage };
|
|
6887
6940
|
//# sourceMappingURL=index.esm.js.map
|