@thesingularitynetwork/darkswap-sdk 0.1.14 → 0.1.15
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.js +109 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ethers = require('ethers');
|
|
4
|
+
var crypto = require('@aztec/foundation/crypto');
|
|
5
|
+
var fields = require('@aztec/foundation/fields');
|
|
6
|
+
var bb_js = require('@aztec/bb.js');
|
|
7
|
+
var noir_js = require('@noir-lang/noir_js');
|
|
6
8
|
|
|
7
9
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
10
|
function isNativeAsset(asset) {
|
|
@@ -14,7 +16,7 @@ function isAddressEquals(address1, address2) {
|
|
|
14
16
|
return address1.toLowerCase() === address2.toLowerCase();
|
|
15
17
|
}
|
|
16
18
|
function hexlify32(value) {
|
|
17
|
-
return ethers.zeroPadValue(ethers.toBeHex(value), 32);
|
|
19
|
+
return ethers.ethers.zeroPadValue(ethers.ethers.toBeHex(value), 32);
|
|
18
20
|
}
|
|
19
21
|
function isHexEquals(hex1, hex2) {
|
|
20
22
|
if (!hex1 || !hex2)
|
|
@@ -575,22 +577,22 @@ class DarkSwapError extends Error {
|
|
|
575
577
|
}
|
|
576
578
|
}
|
|
577
579
|
|
|
578
|
-
|
|
580
|
+
exports.NoteOnChainStatus = void 0;
|
|
579
581
|
(function (NoteOnChainStatus) {
|
|
580
582
|
NoteOnChainStatus["ACTIVE"] = "ACTIVE";
|
|
581
583
|
NoteOnChainStatus["SPENT"] = "SPENT";
|
|
582
584
|
NoteOnChainStatus["LOCKED"] = "LOCKED";
|
|
583
585
|
NoteOnChainStatus["UNKNOWN"] = "UNKNOWN";
|
|
584
|
-
})(NoteOnChainStatus || (NoteOnChainStatus = {}));
|
|
586
|
+
})(exports.NoteOnChainStatus || (exports.NoteOnChainStatus = {}));
|
|
585
587
|
|
|
586
588
|
const P = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
587
589
|
const MAX_ALLOWANCE = BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935'); // 2**256 - 1
|
|
588
590
|
|
|
589
|
-
const defaultAbiCoder = new AbiCoder();
|
|
591
|
+
const defaultAbiCoder = new ethers.AbiCoder();
|
|
590
592
|
function encodeAddress(address) {
|
|
591
593
|
let encoder = defaultAbiCoder;
|
|
592
594
|
let encodedAddress = encoder.encode(["address"], [address]);
|
|
593
|
-
let hashedAddress = ripemd160(encodedAddress);
|
|
595
|
+
let hashedAddress = ethers.ripemd160(encodedAddress);
|
|
594
596
|
return BigInt(hashedAddress);
|
|
595
597
|
}
|
|
596
598
|
|
|
@@ -781,7 +783,7 @@ function generateRho() {
|
|
|
781
783
|
do {
|
|
782
784
|
let ab = new ArrayBuffer(totalBytes);
|
|
783
785
|
let buf = new Uint8Array(ab);
|
|
784
|
-
rho = BigInt(hexlify(getRandomValues(buf))) % P;
|
|
786
|
+
rho = BigInt(ethers.hexlify(getRandomValues(buf))) % P;
|
|
785
787
|
} while (rho === BigInt(0));
|
|
786
788
|
return rho;
|
|
787
789
|
}
|
|
@@ -811,31 +813,31 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
811
813
|
}
|
|
812
814
|
|
|
813
815
|
async function generateKeyPair(signature) {
|
|
814
|
-
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
815
|
-
const schnorr = new Schnorr();
|
|
816
|
-
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
816
|
+
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
817
|
+
const schnorr = new crypto.Schnorr();
|
|
818
|
+
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
817
819
|
return [[publicKey.x, publicKey.y], privateKey];
|
|
818
820
|
}
|
|
819
821
|
|
|
820
822
|
function getContract$2(address, darkSwap) {
|
|
821
823
|
const provider = darkSwap.provider;
|
|
822
|
-
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
824
|
+
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
823
825
|
}
|
|
824
826
|
async function getNoteOnChainStatus(darkSwap, note, nullifier) {
|
|
825
827
|
const contract = getContract$2(darkSwap.contracts.merkleTreeOperator, darkSwap);
|
|
826
828
|
const isCreated = (await contract.noteCommitmentsCreated(note));
|
|
827
829
|
if (!isCreated) {
|
|
828
|
-
return NoteOnChainStatus.UNKNOWN;
|
|
830
|
+
return exports.NoteOnChainStatus.UNKNOWN;
|
|
829
831
|
}
|
|
830
832
|
const isSpent = (await contract.nullifiersUsed(nullifier));
|
|
831
833
|
if (isSpent) {
|
|
832
|
-
return NoteOnChainStatus.SPENT;
|
|
834
|
+
return exports.NoteOnChainStatus.SPENT;
|
|
833
835
|
}
|
|
834
836
|
const isLocked = (await contract.nullifiersLocked(nullifier));
|
|
835
837
|
if (isLocked) {
|
|
836
|
-
return NoteOnChainStatus.LOCKED;
|
|
838
|
+
return exports.NoteOnChainStatus.LOCKED;
|
|
837
839
|
}
|
|
838
|
-
return NoteOnChainStatus.ACTIVE;
|
|
840
|
+
return exports.NoteOnChainStatus.ACTIVE;
|
|
839
841
|
}
|
|
840
842
|
async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
841
843
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
@@ -851,17 +853,17 @@ async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
|
851
853
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
852
854
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
853
855
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
854
|
-
return onChainStatus === NoteOnChainStatus.ACTIVE;
|
|
856
|
+
return onChainStatus === exports.NoteOnChainStatus.ACTIVE;
|
|
855
857
|
}
|
|
856
858
|
async function isNoteSpent(darkSwap, note, publicKey) {
|
|
857
859
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
858
860
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
859
|
-
return onChainStatus === NoteOnChainStatus.SPENT;
|
|
861
|
+
return onChainStatus === exports.NoteOnChainStatus.SPENT;
|
|
860
862
|
}
|
|
861
863
|
async function isNoteValid(darkSwap, note, publicKey) {
|
|
862
864
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
863
865
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
864
|
-
return onChainStatus === NoteOnChainStatus.ACTIVE;
|
|
866
|
+
return onChainStatus === exports.NoteOnChainStatus.ACTIVE;
|
|
865
867
|
}
|
|
866
868
|
async function getNullifierBySignature(note, signature) {
|
|
867
869
|
const [publicKey] = await generateKeyPair(signature);
|
|
@@ -2434,7 +2436,7 @@ var abi$b = [
|
|
|
2434
2436
|
var ERC20_USDT = {
|
|
2435
2437
|
abi: abi$b};
|
|
2436
2438
|
|
|
2437
|
-
|
|
2439
|
+
exports.ChainId = void 0;
|
|
2438
2440
|
(function (ChainId) {
|
|
2439
2441
|
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
|
2440
2442
|
ChainId[ChainId["HARDHAT_ARBITRUM"] = 31338] = "HARDHAT_ARBITRUM";
|
|
@@ -2443,11 +2445,11 @@ var ChainId;
|
|
|
2443
2445
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
2444
2446
|
ChainId[ChainId["ARBITRUM_ONE"] = 42161] = "ARBITRUM_ONE";
|
|
2445
2447
|
ChainId[ChainId["BASE"] = 8453] = "BASE";
|
|
2446
|
-
})(ChainId || (ChainId = {}));
|
|
2448
|
+
})(exports.ChainId || (exports.ChainId = {}));
|
|
2447
2449
|
|
|
2448
2450
|
const legacyTokenConfig = {
|
|
2449
|
-
[ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2450
|
-
[ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2451
|
+
[exports.ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2452
|
+
[exports.ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2451
2453
|
};
|
|
2452
2454
|
const DEFAULT_FEE_RATIO = 300n;
|
|
2453
2455
|
|
|
@@ -2656,7 +2658,7 @@ var depositCircuit = {
|
|
|
2656
2658
|
brillig_names: brillig_names$9
|
|
2657
2659
|
};
|
|
2658
2660
|
|
|
2659
|
-
|
|
2661
|
+
exports.PROOF_DOMAIN = void 0;
|
|
2660
2662
|
(function (PROOF_DOMAIN) {
|
|
2661
2663
|
PROOF_DOMAIN[PROOF_DOMAIN["DEPOSIT"] = 10001] = "DEPOSIT";
|
|
2662
2664
|
PROOF_DOMAIN[PROOF_DOMAIN["WITHDRAW"] = 10002] = "WITHDRAW";
|
|
@@ -2668,7 +2670,7 @@ var PROOF_DOMAIN;
|
|
|
2668
2670
|
PROOF_DOMAIN[PROOF_DOMAIN["JOIN"] = 10008] = "JOIN";
|
|
2669
2671
|
PROOF_DOMAIN[PROOF_DOMAIN["TRIPLE_JOIN"] = 10009] = "TRIPLE_JOIN";
|
|
2670
2672
|
PROOF_DOMAIN[PROOF_DOMAIN["RETAIL_SWAP"] = 10010] = "RETAIL_SWAP";
|
|
2671
|
-
})(PROOF_DOMAIN || (PROOF_DOMAIN = {}));
|
|
2673
|
+
})(exports.PROOF_DOMAIN || (exports.PROOF_DOMAIN = {}));
|
|
2672
2674
|
const EMPTY_NULLIFIER = 0n;
|
|
2673
2675
|
const EMPTY_FOOTER = 0n;
|
|
2674
2676
|
const FEE_RATIO_PRECISION = 1000000n;
|
|
@@ -2699,13 +2701,13 @@ function uint8ArrayToNumberArray(uint8Array) {
|
|
|
2699
2701
|
|
|
2700
2702
|
async function generateProof(circuit, inputs) {
|
|
2701
2703
|
const start_time = new Date().getTime();
|
|
2702
|
-
const backend = new UltraHonkBackend(circuit.bytecode);
|
|
2703
|
-
const noir = new Noir(circuit);
|
|
2704
|
+
const backend = new bb_js.UltraHonkBackend(circuit.bytecode);
|
|
2705
|
+
const noir = new noir_js.Noir(circuit);
|
|
2704
2706
|
try {
|
|
2705
2707
|
const { witness } = await noir.execute(inputs);
|
|
2706
2708
|
const proof = await backend.generateProof(witness, { keccak: true });
|
|
2707
2709
|
console.log("Proof generated in " + (new Date().getTime() - start_time) + "ms");
|
|
2708
|
-
return { proof: hexlify(proof.proof), verifyInputs: proof.publicInputs };
|
|
2710
|
+
return { proof: ethers.hexlify(proof.proof), verifyInputs: proof.publicInputs };
|
|
2709
2711
|
}
|
|
2710
2712
|
finally {
|
|
2711
2713
|
const destroy_start_time = new Date().getTime();
|
|
@@ -2714,8 +2716,8 @@ async function generateProof(circuit, inputs) {
|
|
|
2714
2716
|
}
|
|
2715
2717
|
}
|
|
2716
2718
|
async function signMessage(message, fuzkPriKey) {
|
|
2717
|
-
const schnorr = new Schnorr();
|
|
2718
|
-
const signature = await schnorr.constructSignature(Buffer.from(message, "hex").reverse(), Fq.fromBufferReduce(fuzkPriKey.toBuffer()));
|
|
2719
|
+
const schnorr = new crypto.Schnorr();
|
|
2720
|
+
const signature = await schnorr.constructSignature(Buffer.from(message, "hex").reverse(), fields.Fq.fromBufferReduce(fuzkPriKey.toBuffer()));
|
|
2719
2721
|
return signature.toBuffer();
|
|
2720
2722
|
}
|
|
2721
2723
|
|
|
@@ -2735,7 +2737,7 @@ async function generateDepositProof(param) {
|
|
|
2735
2737
|
const newBalanceFooter = getNoteFooter(param.newBalanceNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
2736
2738
|
const addressMod = encodeAddress(param.address);
|
|
2737
2739
|
const message = bn_to_hex(mimc_bn254([
|
|
2738
|
-
BigInt(PROOF_DOMAIN.DEPOSIT),
|
|
2740
|
+
BigInt(exports.PROOF_DOMAIN.DEPOSIT),
|
|
2739
2741
|
oldBalanceNullifier,
|
|
2740
2742
|
addressMod,
|
|
2741
2743
|
param.newBalanceNote.note,
|
|
@@ -2836,7 +2838,7 @@ const EMPTY_PATH = {
|
|
|
2836
2838
|
};
|
|
2837
2839
|
function getContract$1(address, darkSwap) {
|
|
2838
2840
|
const provider = darkSwap.provider;
|
|
2839
|
-
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
2841
|
+
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
2840
2842
|
}
|
|
2841
2843
|
async function getMerklePathAndRoot(note, darkSwap) {
|
|
2842
2844
|
const result = await multiGetMerklePathAndRoot([note], darkSwap);
|
|
@@ -2956,7 +2958,7 @@ class DepositService extends BaseContractService {
|
|
|
2956
2958
|
throw new DarkSwapError('Invalid context');
|
|
2957
2959
|
}
|
|
2958
2960
|
const signer = this._darkSwap.signer;
|
|
2959
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, signer);
|
|
2961
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, signer);
|
|
2960
2962
|
if (!isNativeAsset(context.newBalance.asset)) {
|
|
2961
2963
|
await this.allowance(context);
|
|
2962
2964
|
const tx = await contract.deposit(context.merkleRoot, context.newBalance.asset, hexlify32(context.depositAmount), context.proof.oldBalanceNullifier, hexlify32(context.newBalance.note), context.proof.newBalanceFooter, context.proof.proof, { value: 0n });
|
|
@@ -2974,12 +2976,12 @@ class DepositService extends BaseContractService {
|
|
|
2974
2976
|
throw new DarkSwapError('Invalid context');
|
|
2975
2977
|
}
|
|
2976
2978
|
const signer = this._darkSwap.signer;
|
|
2977
|
-
const allowanceContract = new ethers.Contract(context.newBalance.asset, ERC20Abi.abi, this._darkSwap);
|
|
2979
|
+
const allowanceContract = new ethers.ethers.Contract(context.newBalance.asset, ERC20Abi.abi, this._darkSwap);
|
|
2978
2980
|
const allowance = await allowanceContract.allowance(signer.getAddress(), this._darkSwap.contracts.darkSwapAssetManager);
|
|
2979
2981
|
if (BigInt(allowance) < context.newBalance.amount) {
|
|
2980
2982
|
const isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwap.chainId) &&
|
|
2981
2983
|
legacyTokenConfig[this._darkSwap.chainId].includes(context.newBalance.asset.toLowerCase());
|
|
2982
|
-
const contract = new ethers.Contract(context.newBalance.asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
|
|
2984
|
+
const contract = new ethers.ethers.Contract(context.newBalance.asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
|
|
2983
2985
|
const tx = await contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
|
|
2984
2986
|
await tx.wait();
|
|
2985
2987
|
}
|
|
@@ -3208,7 +3210,7 @@ async function generateWithdrawProof(param) {
|
|
|
3208
3210
|
const addressMod = encodeAddress(param.address);
|
|
3209
3211
|
const assetMod = encodeAddress(param.oldBalance.asset);
|
|
3210
3212
|
const message = bn_to_hex(mimc_bn254([
|
|
3211
|
-
BigInt(PROOF_DOMAIN.WITHDRAW),
|
|
3213
|
+
BigInt(exports.PROOF_DOMAIN.WITHDRAW),
|
|
3212
3214
|
addressMod,
|
|
3213
3215
|
oldBalanceNullifier,
|
|
3214
3216
|
param.newBalance.note,
|
|
@@ -3328,7 +3330,7 @@ class WithdrawService extends BaseContractService {
|
|
|
3328
3330
|
if (!context || !context.currentBalance || !context.newBalance || !context.proof || !context.merkleRoot) {
|
|
3329
3331
|
throw new DarkSwapError('Invalid context');
|
|
3330
3332
|
}
|
|
3331
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3333
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3332
3334
|
const tx = await contract.withdraw(context.merkleRoot, context.currentBalance.asset, context.withdrawAmount, context.proof.oldBalanceNullifier, hexlify32(context.newBalance.note), context.proof.newBalanceFooter, context.proof.proof);
|
|
3333
3335
|
await tx.wait();
|
|
3334
3336
|
return tx.hash;
|
|
@@ -3601,7 +3603,7 @@ async function generateJoinProof(param) {
|
|
|
3601
3603
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
3602
3604
|
const addressMod = encodeAddress(param.address);
|
|
3603
3605
|
const message = bn_to_hex(mimc_bn254([
|
|
3604
|
-
BigInt(PROOF_DOMAIN.JOIN),
|
|
3606
|
+
BigInt(exports.PROOF_DOMAIN.JOIN),
|
|
3605
3607
|
inNullifier1,
|
|
3606
3608
|
inNullifier2,
|
|
3607
3609
|
param.outNote.note,
|
|
@@ -3738,7 +3740,7 @@ class JoinService extends BaseContractService {
|
|
|
3738
3740
|
if (!context || !context.inNote1 || !context.inNote2 || !context.outNote || !context.proof || !context.merkleRoot) {
|
|
3739
3741
|
throw new DarkSwapError('Invalid context');
|
|
3740
3742
|
}
|
|
3741
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3743
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3742
3744
|
const tx = await contract.join(context.merkleRoot, [
|
|
3743
3745
|
context.proof.inNullifier1,
|
|
3744
3746
|
context.proof.inNullifier2,
|
|
@@ -4070,7 +4072,7 @@ async function generateTripleJoinProof(param) {
|
|
|
4070
4072
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4071
4073
|
const addressMod = encodeAddress(param.address);
|
|
4072
4074
|
const message = bn_to_hex(mimc_bn254([
|
|
4073
|
-
BigInt(PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4075
|
+
BigInt(exports.PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4074
4076
|
inNullifier1,
|
|
4075
4077
|
inNullifier2,
|
|
4076
4078
|
inNullifier3,
|
|
@@ -4243,7 +4245,7 @@ class TripleJoinService extends BaseContractService {
|
|
|
4243
4245
|
|| !context.merkleRoot) {
|
|
4244
4246
|
throw new DarkSwapError('Invalid context');
|
|
4245
4247
|
}
|
|
4246
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
4248
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
4247
4249
|
const tx = await contract.join(context.merkleRoot, [
|
|
4248
4250
|
context.proof.inNullifier1,
|
|
4249
4251
|
context.proof.inNullifier2,
|
|
@@ -4537,7 +4539,7 @@ async function generateProCreateOrderProof(param) {
|
|
|
4537
4539
|
const orderNoteFooter = getNoteFooter(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4538
4540
|
const addressMod = encodeAddress(param.address);
|
|
4539
4541
|
const message = bn_to_hex(mimc_bn254([
|
|
4540
|
-
BigInt(PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4542
|
+
BigInt(exports.PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4541
4543
|
oldBalanceNullifier,
|
|
4542
4544
|
param.orderNote.feeRatio,
|
|
4543
4545
|
param.newBalanceNote.note,
|
|
@@ -4867,7 +4869,7 @@ var DarkSwapFeeAssetManagerAbi = {
|
|
|
4867
4869
|
|
|
4868
4870
|
function getContract(address, darkSwap) {
|
|
4869
4871
|
const provider = darkSwap.provider;
|
|
4870
|
-
return new ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4872
|
+
return new ethers.ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4871
4873
|
}
|
|
4872
4874
|
async function getFeeRatio(wallet, darkSwap) {
|
|
4873
4875
|
const contract = getContract(darkSwap.contracts.darkSwapFeeAssetManager, darkSwap);
|
|
@@ -5032,7 +5034,7 @@ class ProCreateOrderService extends BaseContractService {
|
|
|
5032
5034
|
|| !context.proof) {
|
|
5033
5035
|
throw new DarkSwapError('Invalid context');
|
|
5034
5036
|
}
|
|
5035
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5037
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5036
5038
|
const tx = await contract.proCreateOrder([
|
|
5037
5039
|
context.merkleRoot,
|
|
5038
5040
|
context.proof.oldBalanceNullifier,
|
|
@@ -5325,7 +5327,7 @@ async function generateProCancelOrderProof(param) {
|
|
|
5325
5327
|
const newBalanceNoteFooter = getNoteFooter(param.newBalanceNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5326
5328
|
const addressMod = encodeAddress(param.address);
|
|
5327
5329
|
const message = bn_to_hex(mimc_bn254([
|
|
5328
|
-
BigInt(PROOF_DOMAIN.PRO_CANCEL_ORDER),
|
|
5330
|
+
BigInt(exports.PROOF_DOMAIN.PRO_CANCEL_ORDER),
|
|
5329
5331
|
orderNullifier,
|
|
5330
5332
|
param.orderNote.feeRatio,
|
|
5331
5333
|
oldBalanceNullifier,
|
|
@@ -5477,7 +5479,7 @@ class ProCancelOrderService extends BaseContractService {
|
|
|
5477
5479
|
|| !context.merkleRoot) {
|
|
5478
5480
|
throw new DarkSwapError('Invalid context');
|
|
5479
5481
|
}
|
|
5480
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5482
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5481
5483
|
const tx = await contract.cancelOrder(context.merkleRoot, context.proof.orderNullifier, context.proof.oldBalanceNullifier, hexlify32(context.newBalance.note), context.proof.newBalanceNoteFooter, context.proof.proof);
|
|
5482
5484
|
await tx.wait();
|
|
5483
5485
|
return tx.hash;
|
|
@@ -5874,7 +5876,7 @@ async function generateProSwapProof(param) {
|
|
|
5874
5876
|
const aliceAddressMod = encodeAddress(param.aliceAddress);
|
|
5875
5877
|
const bobAddressMod = encodeAddress(param.bobAddress);
|
|
5876
5878
|
const message = bn_to_hex(mimc_bn254([
|
|
5877
|
-
BigInt(PROOF_DOMAIN.PRO_SWAP),
|
|
5879
|
+
BigInt(exports.PROOF_DOMAIN.PRO_SWAP),
|
|
5878
5880
|
aliceOrderNoteNullifier,
|
|
5879
5881
|
param.aliceOrderNote.feeRatio,
|
|
5880
5882
|
param.bobMessage.orderNote.feeRatio,
|
|
@@ -6131,7 +6133,7 @@ async function generateRetailSwapMessage(address, orderNote, swapInNote, feeAmou
|
|
|
6131
6133
|
const addressMod = encodeAddress(address);
|
|
6132
6134
|
const orderNoteNullifier = calcNullifier(orderNote.rho, pubKey);
|
|
6133
6135
|
const message = bn_to_hex(mimc_bn254([
|
|
6134
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6136
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6135
6137
|
addressMod,
|
|
6136
6138
|
orderNoteNullifier,
|
|
6137
6139
|
orderNote.feeRatio,
|
|
@@ -6162,7 +6164,7 @@ async function generateRetailCreateOrderProof(param) {
|
|
|
6162
6164
|
const swapInNoteFooter = getNoteFooter(param.swapInNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
6163
6165
|
const addressMod = encodeAddress(param.address);
|
|
6164
6166
|
const message = bn_to_hex(mimc_bn254([
|
|
6165
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6167
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6166
6168
|
addressMod,
|
|
6167
6169
|
param.depositNote.note,
|
|
6168
6170
|
param.depositNote.feeRatio,
|
|
@@ -6356,7 +6358,7 @@ class ProSwapService extends BaseContractService {
|
|
|
6356
6358
|
|| !context.bobAddress) {
|
|
6357
6359
|
throw new DarkSwapError('Invalid context');
|
|
6358
6360
|
}
|
|
6359
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6361
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6360
6362
|
const tx = await contract.proSwap([
|
|
6361
6363
|
context.merkleRoot,
|
|
6362
6364
|
context.proof.aliceOutNullifier,
|
|
@@ -6569,7 +6571,7 @@ async function generateRetailCancelOrderProof(param) {
|
|
|
6569
6571
|
const nullifier = calcNullifier(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
6570
6572
|
const addressMod = encodeAddress(param.address);
|
|
6571
6573
|
const message = bn_to_hex(mimc_bn254([
|
|
6572
|
-
BigInt(PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
6574
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
6573
6575
|
addressMod,
|
|
6574
6576
|
nullifier,
|
|
6575
6577
|
param.orderNote.feeRatio,
|
|
@@ -6659,7 +6661,7 @@ class RetailCancelOrderService extends BaseContractService {
|
|
|
6659
6661
|
if (!context || !context.orderNote || !context.proof) {
|
|
6660
6662
|
throw new DarkSwapError('Invalid context');
|
|
6661
6663
|
}
|
|
6662
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6664
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6663
6665
|
const tx = await contract.cancelOrderWithdraw(context.merkleRoot, context.orderNote.asset, hexlify32(context.orderNote.amount), context.proof.nullifier, context.proof.proof);
|
|
6664
6666
|
await tx.wait();
|
|
6665
6667
|
return tx.hash;
|
|
@@ -6774,7 +6776,7 @@ class RetailCreateOrderService extends BaseContractService {
|
|
|
6774
6776
|
if (!context || !context.orderNote || !context.swapInNote || !context.proof) {
|
|
6775
6777
|
throw new DarkSwapError('Invalid context');
|
|
6776
6778
|
}
|
|
6777
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6779
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6778
6780
|
let ethAmount = 0n;
|
|
6779
6781
|
if (isNativeAsset(context.orderNote.asset)) {
|
|
6780
6782
|
ethAmount = context.orderNote.amount;
|
|
@@ -7279,7 +7281,7 @@ class RetailSwapService extends BaseContractService {
|
|
|
7279
7281
|
|| !context.proof) {
|
|
7280
7282
|
throw new DarkSwapError('Invalid context');
|
|
7281
7283
|
}
|
|
7282
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
7284
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
7283
7285
|
const tx = await contract.retailSwap([
|
|
7284
7286
|
context.merkleRoot,
|
|
7285
7287
|
hexlify32(context.aliceSwapMessage.orderNote.feeRatio),
|
|
@@ -7297,7 +7299,7 @@ class RetailSwapService extends BaseContractService {
|
|
|
7297
7299
|
}
|
|
7298
7300
|
|
|
7299
7301
|
const contractConfig = {
|
|
7300
|
-
[ChainId.MAINNET]: {
|
|
7302
|
+
[exports.ChainId.MAINNET]: {
|
|
7301
7303
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7302
7304
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7303
7305
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -7306,7 +7308,7 @@ const contractConfig = {
|
|
|
7306
7308
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7307
7309
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-subgraph/version/v0.0.1/api',
|
|
7308
7310
|
},
|
|
7309
|
-
[ChainId.ARBITRUM_ONE]: {
|
|
7311
|
+
[exports.ChainId.ARBITRUM_ONE]: {
|
|
7310
7312
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7311
7313
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7312
7314
|
nativeWrapper: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
@@ -7315,7 +7317,7 @@ const contractConfig = {
|
|
|
7315
7317
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7316
7318
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-arb-subgraph/api'
|
|
7317
7319
|
},
|
|
7318
|
-
[ChainId.BASE]: {
|
|
7320
|
+
[exports.ChainId.BASE]: {
|
|
7319
7321
|
priceOracle: '0xf224a25453D76A41c4427DD1C05369BC9f498444',
|
|
7320
7322
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7321
7323
|
nativeWrapper: '0x4200000000000000000000000000000000000006',
|
|
@@ -7324,7 +7326,7 @@ const contractConfig = {
|
|
|
7324
7326
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7325
7327
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-base-subgraph/api'
|
|
7326
7328
|
},
|
|
7327
|
-
[ChainId.SEPOLIA]: {
|
|
7329
|
+
[exports.ChainId.SEPOLIA]: {
|
|
7328
7330
|
priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
|
|
7329
7331
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7330
7332
|
nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
@@ -7333,7 +7335,7 @@ const contractConfig = {
|
|
|
7333
7335
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7334
7336
|
drakSwapSubgraphUrl: ''
|
|
7335
7337
|
},
|
|
7336
|
-
[ChainId.HARDHAT]: {
|
|
7338
|
+
[exports.ChainId.HARDHAT]: {
|
|
7337
7339
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7338
7340
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7339
7341
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -7412,7 +7414,7 @@ function serializeDarkSwapMessage(swapMessage) {
|
|
|
7412
7414
|
});
|
|
7413
7415
|
}
|
|
7414
7416
|
function deserializePublicKey(publicKeyString) {
|
|
7415
|
-
return [Fr.fromHexString(publicKeyString[0]), Fr.fromHexString(publicKeyString[1])];
|
|
7417
|
+
return [fields.Fr.fromHexString(publicKeyString[0]), fields.Fr.fromHexString(publicKeyString[1])];
|
|
7416
7418
|
}
|
|
7417
7419
|
function deserializeDarkSwapMessage(serializedMessage) {
|
|
7418
7420
|
const message = JSON.parse(serializedMessage);
|
|
@@ -7438,5 +7440,48 @@ function deserializeDarkSwapMessage(serializedMessage) {
|
|
|
7438
7440
|
};
|
|
7439
7441
|
}
|
|
7440
7442
|
|
|
7441
|
-
|
|
7443
|
+
exports.DEFAULT_FEE_RATIO = DEFAULT_FEE_RATIO;
|
|
7444
|
+
exports.DOMAIN_NOTE = DOMAIN_NOTE;
|
|
7445
|
+
exports.DOMAIN_ORDER_NOTE = DOMAIN_ORDER_NOTE;
|
|
7446
|
+
exports.DarkSwap = DarkSwap;
|
|
7447
|
+
exports.DarkSwapError = DarkSwapError;
|
|
7448
|
+
exports.DarkSwapProofError = DarkSwapProofError;
|
|
7449
|
+
exports.DepositContext = DepositContext;
|
|
7450
|
+
exports.DepositService = DepositService;
|
|
7451
|
+
exports.EMPTY_FOOTER = EMPTY_FOOTER;
|
|
7452
|
+
exports.EMPTY_NOTE = EMPTY_NOTE;
|
|
7453
|
+
exports.EMPTY_NULLIFIER = EMPTY_NULLIFIER;
|
|
7454
|
+
exports.EMPTY_PATH = EMPTY_PATH;
|
|
7455
|
+
exports.FEE_RATIO_PRECISION = FEE_RATIO_PRECISION;
|
|
7456
|
+
exports.JoinService = JoinService;
|
|
7457
|
+
exports.ProCancelOrderService = ProCancelOrderService;
|
|
7458
|
+
exports.ProCreateOrderService = ProCreateOrderService;
|
|
7459
|
+
exports.ProSwapService = ProSwapService;
|
|
7460
|
+
exports.RetailCancelOrderService = RetailCancelOrderService;
|
|
7461
|
+
exports.RetailCreateOrderService = RetailCreateOrderService;
|
|
7462
|
+
exports.RetailSwapService = RetailSwapService;
|
|
7463
|
+
exports.TripleJoinService = TripleJoinService;
|
|
7464
|
+
exports.WithdrawService = WithdrawService;
|
|
7465
|
+
exports.calcNullifier = calcNullifier;
|
|
7466
|
+
exports.contractConfig = contractConfig;
|
|
7467
|
+
exports.createNote = createNote;
|
|
7468
|
+
exports.createOrderNoteExt = createOrderNoteExt;
|
|
7469
|
+
exports.deserializeDarkSwapMessage = deserializeDarkSwapMessage;
|
|
7470
|
+
exports.generateKeyPair = generateKeyPair;
|
|
7471
|
+
exports.getFeeRatio = getFeeRatio;
|
|
7472
|
+
exports.getMerklePathAndRoot = getMerklePathAndRoot;
|
|
7473
|
+
exports.getNoteFooter = getNoteFooter;
|
|
7474
|
+
exports.getNoteOnChainStatusByPublicKey = getNoteOnChainStatusByPublicKey;
|
|
7475
|
+
exports.getNoteOnChainStatusBySignature = getNoteOnChainStatusBySignature;
|
|
7476
|
+
exports.getNullifierBySignature = getNullifierBySignature;
|
|
7477
|
+
exports.hexlify32 = hexlify32;
|
|
7478
|
+
exports.isAddressEquals = isAddressEquals;
|
|
7479
|
+
exports.isHexEquals = isHexEquals;
|
|
7480
|
+
exports.isNativeAsset = isNativeAsset;
|
|
7481
|
+
exports.isNoteActive = isNoteActive;
|
|
7482
|
+
exports.isNoteSpent = isNoteSpent;
|
|
7483
|
+
exports.isNoteValid = isNoteValid;
|
|
7484
|
+
exports.legacyTokenConfig = legacyTokenConfig;
|
|
7485
|
+
exports.multiGetMerklePathAndRoot = multiGetMerklePathAndRoot;
|
|
7486
|
+
exports.serializeDarkSwapMessage = serializeDarkSwapMessage;
|
|
7442
7487
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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