@thesingularitynetwork/darkswap-sdk 0.1.14 → 0.1.16
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 +20 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +129 -80
- package/dist/index.js.map +1 -1
- package/dist/types/src/proof/noteService.d.ts +2 -2
- package/package.json +2 -1
- package/src/proof/noteService.ts +86 -80
- package/dist/index.umd.js +0 -7487
- package/dist/index.umd.js.map +0 -1
- package/dist/types/src/services/pro/swapMessage.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ethers = require('ethers');
|
|
4
|
+
var cryptoJs = require('crypto-js');
|
|
5
|
+
var crypto = require('@aztec/foundation/crypto');
|
|
6
|
+
var fields = require('@aztec/foundation/fields');
|
|
7
|
+
var bb_js = require('@aztec/bb.js');
|
|
8
|
+
var noir_js = require('@noir-lang/noir_js');
|
|
6
9
|
|
|
7
10
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
11
|
function isNativeAsset(asset) {
|
|
@@ -14,7 +17,7 @@ function isAddressEquals(address1, address2) {
|
|
|
14
17
|
return address1.toLowerCase() === address2.toLowerCase();
|
|
15
18
|
}
|
|
16
19
|
function hexlify32(value) {
|
|
17
|
-
return ethers.zeroPadValue(ethers.toBeHex(value), 32);
|
|
20
|
+
return ethers.ethers.zeroPadValue(ethers.ethers.toBeHex(value), 32);
|
|
18
21
|
}
|
|
19
22
|
function isHexEquals(hex1, hex2) {
|
|
20
23
|
if (!hex1 || !hex2)
|
|
@@ -575,22 +578,22 @@ class DarkSwapError extends Error {
|
|
|
575
578
|
}
|
|
576
579
|
}
|
|
577
580
|
|
|
578
|
-
|
|
581
|
+
exports.NoteOnChainStatus = void 0;
|
|
579
582
|
(function (NoteOnChainStatus) {
|
|
580
583
|
NoteOnChainStatus["ACTIVE"] = "ACTIVE";
|
|
581
584
|
NoteOnChainStatus["SPENT"] = "SPENT";
|
|
582
585
|
NoteOnChainStatus["LOCKED"] = "LOCKED";
|
|
583
586
|
NoteOnChainStatus["UNKNOWN"] = "UNKNOWN";
|
|
584
|
-
})(NoteOnChainStatus || (NoteOnChainStatus = {}));
|
|
587
|
+
})(exports.NoteOnChainStatus || (exports.NoteOnChainStatus = {}));
|
|
585
588
|
|
|
586
589
|
const P = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
587
590
|
const MAX_ALLOWANCE = BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935'); // 2**256 - 1
|
|
588
591
|
|
|
589
|
-
const defaultAbiCoder = new AbiCoder();
|
|
592
|
+
const defaultAbiCoder = new ethers.AbiCoder();
|
|
590
593
|
function encodeAddress(address) {
|
|
591
594
|
let encoder = defaultAbiCoder;
|
|
592
595
|
let encodedAddress = encoder.encode(["address"], [address]);
|
|
593
|
-
let hashedAddress = ripemd160(encodedAddress);
|
|
596
|
+
let hashedAddress = ethers.ripemd160(encodedAddress);
|
|
594
597
|
return BigInt(hashedAddress);
|
|
595
598
|
}
|
|
596
599
|
|
|
@@ -731,13 +734,14 @@ function mimc_bn254(array) {
|
|
|
731
734
|
}
|
|
732
735
|
|
|
733
736
|
let getRandomValues;
|
|
734
|
-
if (typeof window !== 'undefined' &&
|
|
737
|
+
if (typeof window !== 'undefined' &&
|
|
738
|
+
window.crypto &&
|
|
739
|
+
window.crypto.getRandomValues) {
|
|
735
740
|
getRandomValues = (buf) => window.crypto.getRandomValues(buf);
|
|
736
741
|
}
|
|
737
742
|
else {
|
|
738
|
-
const nodeCrypto = require('crypto');
|
|
739
743
|
getRandomValues = (buf) => {
|
|
740
|
-
const randomBytes =
|
|
744
|
+
const randomBytes = cryptoJs.randomBytes(buf.length);
|
|
741
745
|
buf.set(randomBytes);
|
|
742
746
|
return buf;
|
|
743
747
|
};
|
|
@@ -748,30 +752,28 @@ const EMPTY_NOTE = {
|
|
|
748
752
|
rho: 0n,
|
|
749
753
|
note: 0n,
|
|
750
754
|
amount: 0n,
|
|
751
|
-
asset: '0x0000000000000000000000000000000000000000'
|
|
755
|
+
asset: '0x0000000000000000000000000000000000000000',
|
|
752
756
|
};
|
|
753
757
|
function createNote(address, asset, amount, fuzkPubKey) {
|
|
754
758
|
const rho = generateRho();
|
|
755
759
|
const footer = getNoteFooter(rho, fuzkPubKey);
|
|
756
760
|
const addressMod = encodeAddress(address);
|
|
757
761
|
const assetMod = encodeAddress(asset);
|
|
758
|
-
const note = mimc_bn254([
|
|
759
|
-
DOMAIN_NOTE,
|
|
760
|
-
addressMod,
|
|
761
|
-
assetMod,
|
|
762
|
-
amount,
|
|
763
|
-
footer
|
|
764
|
-
]);
|
|
762
|
+
const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer]);
|
|
765
763
|
return {
|
|
766
764
|
rho,
|
|
767
765
|
note,
|
|
768
766
|
asset,
|
|
769
767
|
amount,
|
|
770
|
-
footer
|
|
768
|
+
footer,
|
|
771
769
|
};
|
|
772
770
|
}
|
|
773
771
|
function getNoteFooter(rho, publicKey) {
|
|
774
|
-
return mimc_bn254([
|
|
772
|
+
return mimc_bn254([
|
|
773
|
+
mimc_bn254([BigInt(rho)]),
|
|
774
|
+
BigInt(publicKey[0].toString()),
|
|
775
|
+
BigInt(publicKey[1].toString()),
|
|
776
|
+
]);
|
|
775
777
|
}
|
|
776
778
|
function generateRho() {
|
|
777
779
|
const securityLevel = 128;
|
|
@@ -781,12 +783,16 @@ 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
|
}
|
|
788
790
|
function calcNullifier(rho, fuzkPubKey) {
|
|
789
|
-
return mimc_bn254([
|
|
791
|
+
return mimc_bn254([
|
|
792
|
+
rho,
|
|
793
|
+
BigInt(fuzkPubKey[0].toString()),
|
|
794
|
+
BigInt(fuzkPubKey[1].toString()),
|
|
795
|
+
]);
|
|
790
796
|
}
|
|
791
797
|
function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
792
798
|
const rho = generateRho();
|
|
@@ -799,43 +805,43 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
799
805
|
assetMod,
|
|
800
806
|
amount,
|
|
801
807
|
feeRatio,
|
|
802
|
-
footer
|
|
808
|
+
footer,
|
|
803
809
|
]);
|
|
804
810
|
return {
|
|
805
811
|
rho,
|
|
806
812
|
note: noteCommitment,
|
|
807
813
|
asset,
|
|
808
814
|
amount,
|
|
809
|
-
feeRatio
|
|
815
|
+
feeRatio,
|
|
810
816
|
};
|
|
811
817
|
}
|
|
812
818
|
|
|
813
819
|
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()));
|
|
820
|
+
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
821
|
+
const schnorr = new crypto.Schnorr();
|
|
822
|
+
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
817
823
|
return [[publicKey.x, publicKey.y], privateKey];
|
|
818
824
|
}
|
|
819
825
|
|
|
820
826
|
function getContract$2(address, darkSwap) {
|
|
821
827
|
const provider = darkSwap.provider;
|
|
822
|
-
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
828
|
+
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
823
829
|
}
|
|
824
830
|
async function getNoteOnChainStatus(darkSwap, note, nullifier) {
|
|
825
831
|
const contract = getContract$2(darkSwap.contracts.merkleTreeOperator, darkSwap);
|
|
826
832
|
const isCreated = (await contract.noteCommitmentsCreated(note));
|
|
827
833
|
if (!isCreated) {
|
|
828
|
-
return NoteOnChainStatus.UNKNOWN;
|
|
834
|
+
return exports.NoteOnChainStatus.UNKNOWN;
|
|
829
835
|
}
|
|
830
836
|
const isSpent = (await contract.nullifiersUsed(nullifier));
|
|
831
837
|
if (isSpent) {
|
|
832
|
-
return NoteOnChainStatus.SPENT;
|
|
838
|
+
return exports.NoteOnChainStatus.SPENT;
|
|
833
839
|
}
|
|
834
840
|
const isLocked = (await contract.nullifiersLocked(nullifier));
|
|
835
841
|
if (isLocked) {
|
|
836
|
-
return NoteOnChainStatus.LOCKED;
|
|
842
|
+
return exports.NoteOnChainStatus.LOCKED;
|
|
837
843
|
}
|
|
838
|
-
return NoteOnChainStatus.ACTIVE;
|
|
844
|
+
return exports.NoteOnChainStatus.ACTIVE;
|
|
839
845
|
}
|
|
840
846
|
async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
841
847
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
@@ -851,17 +857,17 @@ async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
|
851
857
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
852
858
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
853
859
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
854
|
-
return onChainStatus === NoteOnChainStatus.ACTIVE;
|
|
860
|
+
return onChainStatus === exports.NoteOnChainStatus.ACTIVE;
|
|
855
861
|
}
|
|
856
862
|
async function isNoteSpent(darkSwap, note, publicKey) {
|
|
857
863
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
858
864
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
859
|
-
return onChainStatus === NoteOnChainStatus.SPENT;
|
|
865
|
+
return onChainStatus === exports.NoteOnChainStatus.SPENT;
|
|
860
866
|
}
|
|
861
867
|
async function isNoteValid(darkSwap, note, publicKey) {
|
|
862
868
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
863
869
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
864
|
-
return onChainStatus === NoteOnChainStatus.ACTIVE;
|
|
870
|
+
return onChainStatus === exports.NoteOnChainStatus.ACTIVE;
|
|
865
871
|
}
|
|
866
872
|
async function getNullifierBySignature(note, signature) {
|
|
867
873
|
const [publicKey] = await generateKeyPair(signature);
|
|
@@ -2434,7 +2440,7 @@ var abi$b = [
|
|
|
2434
2440
|
var ERC20_USDT = {
|
|
2435
2441
|
abi: abi$b};
|
|
2436
2442
|
|
|
2437
|
-
|
|
2443
|
+
exports.ChainId = void 0;
|
|
2438
2444
|
(function (ChainId) {
|
|
2439
2445
|
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
|
2440
2446
|
ChainId[ChainId["HARDHAT_ARBITRUM"] = 31338] = "HARDHAT_ARBITRUM";
|
|
@@ -2443,11 +2449,11 @@ var ChainId;
|
|
|
2443
2449
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
2444
2450
|
ChainId[ChainId["ARBITRUM_ONE"] = 42161] = "ARBITRUM_ONE";
|
|
2445
2451
|
ChainId[ChainId["BASE"] = 8453] = "BASE";
|
|
2446
|
-
})(ChainId || (ChainId = {}));
|
|
2452
|
+
})(exports.ChainId || (exports.ChainId = {}));
|
|
2447
2453
|
|
|
2448
2454
|
const legacyTokenConfig = {
|
|
2449
|
-
[ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2450
|
-
[ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2455
|
+
[exports.ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2456
|
+
[exports.ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2451
2457
|
};
|
|
2452
2458
|
const DEFAULT_FEE_RATIO = 300n;
|
|
2453
2459
|
|
|
@@ -2656,7 +2662,7 @@ var depositCircuit = {
|
|
|
2656
2662
|
brillig_names: brillig_names$9
|
|
2657
2663
|
};
|
|
2658
2664
|
|
|
2659
|
-
|
|
2665
|
+
exports.PROOF_DOMAIN = void 0;
|
|
2660
2666
|
(function (PROOF_DOMAIN) {
|
|
2661
2667
|
PROOF_DOMAIN[PROOF_DOMAIN["DEPOSIT"] = 10001] = "DEPOSIT";
|
|
2662
2668
|
PROOF_DOMAIN[PROOF_DOMAIN["WITHDRAW"] = 10002] = "WITHDRAW";
|
|
@@ -2668,7 +2674,7 @@ var PROOF_DOMAIN;
|
|
|
2668
2674
|
PROOF_DOMAIN[PROOF_DOMAIN["JOIN"] = 10008] = "JOIN";
|
|
2669
2675
|
PROOF_DOMAIN[PROOF_DOMAIN["TRIPLE_JOIN"] = 10009] = "TRIPLE_JOIN";
|
|
2670
2676
|
PROOF_DOMAIN[PROOF_DOMAIN["RETAIL_SWAP"] = 10010] = "RETAIL_SWAP";
|
|
2671
|
-
})(PROOF_DOMAIN || (PROOF_DOMAIN = {}));
|
|
2677
|
+
})(exports.PROOF_DOMAIN || (exports.PROOF_DOMAIN = {}));
|
|
2672
2678
|
const EMPTY_NULLIFIER = 0n;
|
|
2673
2679
|
const EMPTY_FOOTER = 0n;
|
|
2674
2680
|
const FEE_RATIO_PRECISION = 1000000n;
|
|
@@ -2699,13 +2705,13 @@ function uint8ArrayToNumberArray(uint8Array) {
|
|
|
2699
2705
|
|
|
2700
2706
|
async function generateProof(circuit, inputs) {
|
|
2701
2707
|
const start_time = new Date().getTime();
|
|
2702
|
-
const backend = new UltraHonkBackend(circuit.bytecode);
|
|
2703
|
-
const noir = new Noir(circuit);
|
|
2708
|
+
const backend = new bb_js.UltraHonkBackend(circuit.bytecode);
|
|
2709
|
+
const noir = new noir_js.Noir(circuit);
|
|
2704
2710
|
try {
|
|
2705
2711
|
const { witness } = await noir.execute(inputs);
|
|
2706
2712
|
const proof = await backend.generateProof(witness, { keccak: true });
|
|
2707
2713
|
console.log("Proof generated in " + (new Date().getTime() - start_time) + "ms");
|
|
2708
|
-
return { proof: hexlify(proof.proof), verifyInputs: proof.publicInputs };
|
|
2714
|
+
return { proof: ethers.hexlify(proof.proof), verifyInputs: proof.publicInputs };
|
|
2709
2715
|
}
|
|
2710
2716
|
finally {
|
|
2711
2717
|
const destroy_start_time = new Date().getTime();
|
|
@@ -2714,8 +2720,8 @@ async function generateProof(circuit, inputs) {
|
|
|
2714
2720
|
}
|
|
2715
2721
|
}
|
|
2716
2722
|
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()));
|
|
2723
|
+
const schnorr = new crypto.Schnorr();
|
|
2724
|
+
const signature = await schnorr.constructSignature(Buffer.from(message, "hex").reverse(), fields.Fq.fromBufferReduce(fuzkPriKey.toBuffer()));
|
|
2719
2725
|
return signature.toBuffer();
|
|
2720
2726
|
}
|
|
2721
2727
|
|
|
@@ -2735,7 +2741,7 @@ async function generateDepositProof(param) {
|
|
|
2735
2741
|
const newBalanceFooter = getNoteFooter(param.newBalanceNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
2736
2742
|
const addressMod = encodeAddress(param.address);
|
|
2737
2743
|
const message = bn_to_hex(mimc_bn254([
|
|
2738
|
-
BigInt(PROOF_DOMAIN.DEPOSIT),
|
|
2744
|
+
BigInt(exports.PROOF_DOMAIN.DEPOSIT),
|
|
2739
2745
|
oldBalanceNullifier,
|
|
2740
2746
|
addressMod,
|
|
2741
2747
|
param.newBalanceNote.note,
|
|
@@ -2836,7 +2842,7 @@ const EMPTY_PATH = {
|
|
|
2836
2842
|
};
|
|
2837
2843
|
function getContract$1(address, darkSwap) {
|
|
2838
2844
|
const provider = darkSwap.provider;
|
|
2839
|
-
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
2845
|
+
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
2840
2846
|
}
|
|
2841
2847
|
async function getMerklePathAndRoot(note, darkSwap) {
|
|
2842
2848
|
const result = await multiGetMerklePathAndRoot([note], darkSwap);
|
|
@@ -2956,7 +2962,7 @@ class DepositService extends BaseContractService {
|
|
|
2956
2962
|
throw new DarkSwapError('Invalid context');
|
|
2957
2963
|
}
|
|
2958
2964
|
const signer = this._darkSwap.signer;
|
|
2959
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, signer);
|
|
2965
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, signer);
|
|
2960
2966
|
if (!isNativeAsset(context.newBalance.asset)) {
|
|
2961
2967
|
await this.allowance(context);
|
|
2962
2968
|
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 +2980,12 @@ class DepositService extends BaseContractService {
|
|
|
2974
2980
|
throw new DarkSwapError('Invalid context');
|
|
2975
2981
|
}
|
|
2976
2982
|
const signer = this._darkSwap.signer;
|
|
2977
|
-
const allowanceContract = new ethers.Contract(context.newBalance.asset, ERC20Abi.abi, this._darkSwap);
|
|
2983
|
+
const allowanceContract = new ethers.ethers.Contract(context.newBalance.asset, ERC20Abi.abi, this._darkSwap);
|
|
2978
2984
|
const allowance = await allowanceContract.allowance(signer.getAddress(), this._darkSwap.contracts.darkSwapAssetManager);
|
|
2979
2985
|
if (BigInt(allowance) < context.newBalance.amount) {
|
|
2980
2986
|
const isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwap.chainId) &&
|
|
2981
2987
|
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);
|
|
2988
|
+
const contract = new ethers.ethers.Contract(context.newBalance.asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
|
|
2983
2989
|
const tx = await contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
|
|
2984
2990
|
await tx.wait();
|
|
2985
2991
|
}
|
|
@@ -3208,7 +3214,7 @@ async function generateWithdrawProof(param) {
|
|
|
3208
3214
|
const addressMod = encodeAddress(param.address);
|
|
3209
3215
|
const assetMod = encodeAddress(param.oldBalance.asset);
|
|
3210
3216
|
const message = bn_to_hex(mimc_bn254([
|
|
3211
|
-
BigInt(PROOF_DOMAIN.WITHDRAW),
|
|
3217
|
+
BigInt(exports.PROOF_DOMAIN.WITHDRAW),
|
|
3212
3218
|
addressMod,
|
|
3213
3219
|
oldBalanceNullifier,
|
|
3214
3220
|
param.newBalance.note,
|
|
@@ -3328,7 +3334,7 @@ class WithdrawService extends BaseContractService {
|
|
|
3328
3334
|
if (!context || !context.currentBalance || !context.newBalance || !context.proof || !context.merkleRoot) {
|
|
3329
3335
|
throw new DarkSwapError('Invalid context');
|
|
3330
3336
|
}
|
|
3331
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3337
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3332
3338
|
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
3339
|
await tx.wait();
|
|
3334
3340
|
return tx.hash;
|
|
@@ -3601,7 +3607,7 @@ async function generateJoinProof(param) {
|
|
|
3601
3607
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
3602
3608
|
const addressMod = encodeAddress(param.address);
|
|
3603
3609
|
const message = bn_to_hex(mimc_bn254([
|
|
3604
|
-
BigInt(PROOF_DOMAIN.JOIN),
|
|
3610
|
+
BigInt(exports.PROOF_DOMAIN.JOIN),
|
|
3605
3611
|
inNullifier1,
|
|
3606
3612
|
inNullifier2,
|
|
3607
3613
|
param.outNote.note,
|
|
@@ -3738,7 +3744,7 @@ class JoinService extends BaseContractService {
|
|
|
3738
3744
|
if (!context || !context.inNote1 || !context.inNote2 || !context.outNote || !context.proof || !context.merkleRoot) {
|
|
3739
3745
|
throw new DarkSwapError('Invalid context');
|
|
3740
3746
|
}
|
|
3741
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3747
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
3742
3748
|
const tx = await contract.join(context.merkleRoot, [
|
|
3743
3749
|
context.proof.inNullifier1,
|
|
3744
3750
|
context.proof.inNullifier2,
|
|
@@ -4070,7 +4076,7 @@ async function generateTripleJoinProof(param) {
|
|
|
4070
4076
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4071
4077
|
const addressMod = encodeAddress(param.address);
|
|
4072
4078
|
const message = bn_to_hex(mimc_bn254([
|
|
4073
|
-
BigInt(PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4079
|
+
BigInt(exports.PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4074
4080
|
inNullifier1,
|
|
4075
4081
|
inNullifier2,
|
|
4076
4082
|
inNullifier3,
|
|
@@ -4243,7 +4249,7 @@ class TripleJoinService extends BaseContractService {
|
|
|
4243
4249
|
|| !context.merkleRoot) {
|
|
4244
4250
|
throw new DarkSwapError('Invalid context');
|
|
4245
4251
|
}
|
|
4246
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
4252
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
4247
4253
|
const tx = await contract.join(context.merkleRoot, [
|
|
4248
4254
|
context.proof.inNullifier1,
|
|
4249
4255
|
context.proof.inNullifier2,
|
|
@@ -4537,7 +4543,7 @@ async function generateProCreateOrderProof(param) {
|
|
|
4537
4543
|
const orderNoteFooter = getNoteFooter(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4538
4544
|
const addressMod = encodeAddress(param.address);
|
|
4539
4545
|
const message = bn_to_hex(mimc_bn254([
|
|
4540
|
-
BigInt(PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4546
|
+
BigInt(exports.PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4541
4547
|
oldBalanceNullifier,
|
|
4542
4548
|
param.orderNote.feeRatio,
|
|
4543
4549
|
param.newBalanceNote.note,
|
|
@@ -4867,7 +4873,7 @@ var DarkSwapFeeAssetManagerAbi = {
|
|
|
4867
4873
|
|
|
4868
4874
|
function getContract(address, darkSwap) {
|
|
4869
4875
|
const provider = darkSwap.provider;
|
|
4870
|
-
return new ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4876
|
+
return new ethers.ethers.Contract(address, DarkSwapFeeAssetManagerAbi.abi, provider);
|
|
4871
4877
|
}
|
|
4872
4878
|
async function getFeeRatio(wallet, darkSwap) {
|
|
4873
4879
|
const contract = getContract(darkSwap.contracts.darkSwapFeeAssetManager, darkSwap);
|
|
@@ -5032,7 +5038,7 @@ class ProCreateOrderService extends BaseContractService {
|
|
|
5032
5038
|
|| !context.proof) {
|
|
5033
5039
|
throw new DarkSwapError('Invalid context');
|
|
5034
5040
|
}
|
|
5035
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5041
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5036
5042
|
const tx = await contract.proCreateOrder([
|
|
5037
5043
|
context.merkleRoot,
|
|
5038
5044
|
context.proof.oldBalanceNullifier,
|
|
@@ -5325,7 +5331,7 @@ async function generateProCancelOrderProof(param) {
|
|
|
5325
5331
|
const newBalanceNoteFooter = getNoteFooter(param.newBalanceNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
5326
5332
|
const addressMod = encodeAddress(param.address);
|
|
5327
5333
|
const message = bn_to_hex(mimc_bn254([
|
|
5328
|
-
BigInt(PROOF_DOMAIN.PRO_CANCEL_ORDER),
|
|
5334
|
+
BigInt(exports.PROOF_DOMAIN.PRO_CANCEL_ORDER),
|
|
5329
5335
|
orderNullifier,
|
|
5330
5336
|
param.orderNote.feeRatio,
|
|
5331
5337
|
oldBalanceNullifier,
|
|
@@ -5477,7 +5483,7 @@ class ProCancelOrderService extends BaseContractService {
|
|
|
5477
5483
|
|| !context.merkleRoot) {
|
|
5478
5484
|
throw new DarkSwapError('Invalid context');
|
|
5479
5485
|
}
|
|
5480
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5486
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
5481
5487
|
const tx = await contract.cancelOrder(context.merkleRoot, context.proof.orderNullifier, context.proof.oldBalanceNullifier, hexlify32(context.newBalance.note), context.proof.newBalanceNoteFooter, context.proof.proof);
|
|
5482
5488
|
await tx.wait();
|
|
5483
5489
|
return tx.hash;
|
|
@@ -5874,7 +5880,7 @@ async function generateProSwapProof(param) {
|
|
|
5874
5880
|
const aliceAddressMod = encodeAddress(param.aliceAddress);
|
|
5875
5881
|
const bobAddressMod = encodeAddress(param.bobAddress);
|
|
5876
5882
|
const message = bn_to_hex(mimc_bn254([
|
|
5877
|
-
BigInt(PROOF_DOMAIN.PRO_SWAP),
|
|
5883
|
+
BigInt(exports.PROOF_DOMAIN.PRO_SWAP),
|
|
5878
5884
|
aliceOrderNoteNullifier,
|
|
5879
5885
|
param.aliceOrderNote.feeRatio,
|
|
5880
5886
|
param.bobMessage.orderNote.feeRatio,
|
|
@@ -6131,7 +6137,7 @@ async function generateRetailSwapMessage(address, orderNote, swapInNote, feeAmou
|
|
|
6131
6137
|
const addressMod = encodeAddress(address);
|
|
6132
6138
|
const orderNoteNullifier = calcNullifier(orderNote.rho, pubKey);
|
|
6133
6139
|
const message = bn_to_hex(mimc_bn254([
|
|
6134
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6140
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6135
6141
|
addressMod,
|
|
6136
6142
|
orderNoteNullifier,
|
|
6137
6143
|
orderNote.feeRatio,
|
|
@@ -6162,7 +6168,7 @@ async function generateRetailCreateOrderProof(param) {
|
|
|
6162
6168
|
const swapInNoteFooter = getNoteFooter(param.swapInNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
6163
6169
|
const addressMod = encodeAddress(param.address);
|
|
6164
6170
|
const message = bn_to_hex(mimc_bn254([
|
|
6165
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6171
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
6166
6172
|
addressMod,
|
|
6167
6173
|
param.depositNote.note,
|
|
6168
6174
|
param.depositNote.feeRatio,
|
|
@@ -6356,7 +6362,7 @@ class ProSwapService extends BaseContractService {
|
|
|
6356
6362
|
|| !context.bobAddress) {
|
|
6357
6363
|
throw new DarkSwapError('Invalid context');
|
|
6358
6364
|
}
|
|
6359
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6365
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6360
6366
|
const tx = await contract.proSwap([
|
|
6361
6367
|
context.merkleRoot,
|
|
6362
6368
|
context.proof.aliceOutNullifier,
|
|
@@ -6569,7 +6575,7 @@ async function generateRetailCancelOrderProof(param) {
|
|
|
6569
6575
|
const nullifier = calcNullifier(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
6570
6576
|
const addressMod = encodeAddress(param.address);
|
|
6571
6577
|
const message = bn_to_hex(mimc_bn254([
|
|
6572
|
-
BigInt(PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
6578
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
6573
6579
|
addressMod,
|
|
6574
6580
|
nullifier,
|
|
6575
6581
|
param.orderNote.feeRatio,
|
|
@@ -6659,7 +6665,7 @@ class RetailCancelOrderService extends BaseContractService {
|
|
|
6659
6665
|
if (!context || !context.orderNote || !context.proof) {
|
|
6660
6666
|
throw new DarkSwapError('Invalid context');
|
|
6661
6667
|
}
|
|
6662
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6668
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6663
6669
|
const tx = await contract.cancelOrderWithdraw(context.merkleRoot, context.orderNote.asset, hexlify32(context.orderNote.amount), context.proof.nullifier, context.proof.proof);
|
|
6664
6670
|
await tx.wait();
|
|
6665
6671
|
return tx.hash;
|
|
@@ -6774,7 +6780,7 @@ class RetailCreateOrderService extends BaseContractService {
|
|
|
6774
6780
|
if (!context || !context.orderNote || !context.swapInNote || !context.proof) {
|
|
6775
6781
|
throw new DarkSwapError('Invalid context');
|
|
6776
6782
|
}
|
|
6777
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6783
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
6778
6784
|
let ethAmount = 0n;
|
|
6779
6785
|
if (isNativeAsset(context.orderNote.asset)) {
|
|
6780
6786
|
ethAmount = context.orderNote.amount;
|
|
@@ -7279,7 +7285,7 @@ class RetailSwapService extends BaseContractService {
|
|
|
7279
7285
|
|| !context.proof) {
|
|
7280
7286
|
throw new DarkSwapError('Invalid context');
|
|
7281
7287
|
}
|
|
7282
|
-
const contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
7288
|
+
const contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
7283
7289
|
const tx = await contract.retailSwap([
|
|
7284
7290
|
context.merkleRoot,
|
|
7285
7291
|
hexlify32(context.aliceSwapMessage.orderNote.feeRatio),
|
|
@@ -7297,7 +7303,7 @@ class RetailSwapService extends BaseContractService {
|
|
|
7297
7303
|
}
|
|
7298
7304
|
|
|
7299
7305
|
const contractConfig = {
|
|
7300
|
-
[ChainId.MAINNET]: {
|
|
7306
|
+
[exports.ChainId.MAINNET]: {
|
|
7301
7307
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7302
7308
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7303
7309
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -7306,7 +7312,7 @@ const contractConfig = {
|
|
|
7306
7312
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7307
7313
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-subgraph/version/v0.0.1/api',
|
|
7308
7314
|
},
|
|
7309
|
-
[ChainId.ARBITRUM_ONE]: {
|
|
7315
|
+
[exports.ChainId.ARBITRUM_ONE]: {
|
|
7310
7316
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7311
7317
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7312
7318
|
nativeWrapper: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
@@ -7315,7 +7321,7 @@ const contractConfig = {
|
|
|
7315
7321
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7316
7322
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-arb-subgraph/api'
|
|
7317
7323
|
},
|
|
7318
|
-
[ChainId.BASE]: {
|
|
7324
|
+
[exports.ChainId.BASE]: {
|
|
7319
7325
|
priceOracle: '0xf224a25453D76A41c4427DD1C05369BC9f498444',
|
|
7320
7326
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7321
7327
|
nativeWrapper: '0x4200000000000000000000000000000000000006',
|
|
@@ -7324,7 +7330,7 @@ const contractConfig = {
|
|
|
7324
7330
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7325
7331
|
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-base-subgraph/api'
|
|
7326
7332
|
},
|
|
7327
|
-
[ChainId.SEPOLIA]: {
|
|
7333
|
+
[exports.ChainId.SEPOLIA]: {
|
|
7328
7334
|
priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
|
|
7329
7335
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7330
7336
|
nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
@@ -7333,7 +7339,7 @@ const contractConfig = {
|
|
|
7333
7339
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
7334
7340
|
drakSwapSubgraphUrl: ''
|
|
7335
7341
|
},
|
|
7336
|
-
[ChainId.HARDHAT]: {
|
|
7342
|
+
[exports.ChainId.HARDHAT]: {
|
|
7337
7343
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
7338
7344
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
7339
7345
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -7412,7 +7418,7 @@ function serializeDarkSwapMessage(swapMessage) {
|
|
|
7412
7418
|
});
|
|
7413
7419
|
}
|
|
7414
7420
|
function deserializePublicKey(publicKeyString) {
|
|
7415
|
-
return [Fr.fromHexString(publicKeyString[0]), Fr.fromHexString(publicKeyString[1])];
|
|
7421
|
+
return [fields.Fr.fromHexString(publicKeyString[0]), fields.Fr.fromHexString(publicKeyString[1])];
|
|
7416
7422
|
}
|
|
7417
7423
|
function deserializeDarkSwapMessage(serializedMessage) {
|
|
7418
7424
|
const message = JSON.parse(serializedMessage);
|
|
@@ -7438,5 +7444,48 @@ function deserializeDarkSwapMessage(serializedMessage) {
|
|
|
7438
7444
|
};
|
|
7439
7445
|
}
|
|
7440
7446
|
|
|
7441
|
-
|
|
7447
|
+
exports.DEFAULT_FEE_RATIO = DEFAULT_FEE_RATIO;
|
|
7448
|
+
exports.DOMAIN_NOTE = DOMAIN_NOTE;
|
|
7449
|
+
exports.DOMAIN_ORDER_NOTE = DOMAIN_ORDER_NOTE;
|
|
7450
|
+
exports.DarkSwap = DarkSwap;
|
|
7451
|
+
exports.DarkSwapError = DarkSwapError;
|
|
7452
|
+
exports.DarkSwapProofError = DarkSwapProofError;
|
|
7453
|
+
exports.DepositContext = DepositContext;
|
|
7454
|
+
exports.DepositService = DepositService;
|
|
7455
|
+
exports.EMPTY_FOOTER = EMPTY_FOOTER;
|
|
7456
|
+
exports.EMPTY_NOTE = EMPTY_NOTE;
|
|
7457
|
+
exports.EMPTY_NULLIFIER = EMPTY_NULLIFIER;
|
|
7458
|
+
exports.EMPTY_PATH = EMPTY_PATH;
|
|
7459
|
+
exports.FEE_RATIO_PRECISION = FEE_RATIO_PRECISION;
|
|
7460
|
+
exports.JoinService = JoinService;
|
|
7461
|
+
exports.ProCancelOrderService = ProCancelOrderService;
|
|
7462
|
+
exports.ProCreateOrderService = ProCreateOrderService;
|
|
7463
|
+
exports.ProSwapService = ProSwapService;
|
|
7464
|
+
exports.RetailCancelOrderService = RetailCancelOrderService;
|
|
7465
|
+
exports.RetailCreateOrderService = RetailCreateOrderService;
|
|
7466
|
+
exports.RetailSwapService = RetailSwapService;
|
|
7467
|
+
exports.TripleJoinService = TripleJoinService;
|
|
7468
|
+
exports.WithdrawService = WithdrawService;
|
|
7469
|
+
exports.calcNullifier = calcNullifier;
|
|
7470
|
+
exports.contractConfig = contractConfig;
|
|
7471
|
+
exports.createNote = createNote;
|
|
7472
|
+
exports.createOrderNoteExt = createOrderNoteExt;
|
|
7473
|
+
exports.deserializeDarkSwapMessage = deserializeDarkSwapMessage;
|
|
7474
|
+
exports.generateKeyPair = generateKeyPair;
|
|
7475
|
+
exports.getFeeRatio = getFeeRatio;
|
|
7476
|
+
exports.getMerklePathAndRoot = getMerklePathAndRoot;
|
|
7477
|
+
exports.getNoteFooter = getNoteFooter;
|
|
7478
|
+
exports.getNoteOnChainStatusByPublicKey = getNoteOnChainStatusByPublicKey;
|
|
7479
|
+
exports.getNoteOnChainStatusBySignature = getNoteOnChainStatusBySignature;
|
|
7480
|
+
exports.getNullifierBySignature = getNullifierBySignature;
|
|
7481
|
+
exports.hexlify32 = hexlify32;
|
|
7482
|
+
exports.isAddressEquals = isAddressEquals;
|
|
7483
|
+
exports.isHexEquals = isHexEquals;
|
|
7484
|
+
exports.isNativeAsset = isNativeAsset;
|
|
7485
|
+
exports.isNoteActive = isNoteActive;
|
|
7486
|
+
exports.isNoteSpent = isNoteSpent;
|
|
7487
|
+
exports.isNoteValid = isNoteValid;
|
|
7488
|
+
exports.legacyTokenConfig = legacyTokenConfig;
|
|
7489
|
+
exports.multiGetMerklePathAndRoot = multiGetMerklePathAndRoot;
|
|
7490
|
+
exports.serializeDarkSwapMessage = serializeDarkSwapMessage;
|
|
7442
7491
|
//# 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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-
import { Fr } from
|
|
2
|
-
import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from '../types.js';
|
|
3
3
|
export declare const DOMAIN_NOTE = 2n;
|
|
4
4
|
export declare const DOMAIN_ORDER_NOTE = 3n;
|
|
5
5
|
export declare const EMPTY_NOTE: DarkSwapNote;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thesingularitynetwork/darkswap-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "DarkSwap SDK for browser and Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@noir-lang/noir_js": "^1.0.0-beta.3",
|
|
50
50
|
"@noir-lang/noir_wasm": "^1.0.0-beta.3",
|
|
51
51
|
"@noir-lang/types": "^1.0.0-beta.3",
|
|
52
|
+
"crypto-js": "^4.2.0",
|
|
52
53
|
"ethers": "^6.14.3"
|
|
53
54
|
}
|
|
54
55
|
}
|