@thesingularitynetwork/darkswap-sdk 0.1.1 → 0.1.3
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 +16 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +45 -30
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/config/index.d.ts +3 -0
- package/dist/{src → types/src}/index.d.ts +3 -0
- package/dist/{src → types/src}/services/noteService.d.ts +1 -0
- package/package.json +5 -8
- package/src/config/index.ts +3 -0
- package/src/index.ts +3 -0
- package/src/services/noteService.ts +12 -0
- /package/dist/{src → types/src}/config/chain.d.ts +0 -0
- /package/dist/{src → types/src}/config/config.d.ts +0 -0
- /package/dist/{src → types/src}/config/contractConfig.d.ts +0 -0
- /package/dist/{src → types/src}/darkSwap.d.ts +0 -0
- /package/dist/{src → types/src}/entities/error.d.ts +0 -0
- /package/dist/{src → types/src}/entities/index.d.ts +0 -0
- /package/dist/{src → types/src}/entities/token.d.ts +0 -0
- /package/dist/{src → types/src}/entities/types.d.ts +0 -0
- /package/dist/{src → types/src}/proof/baseProofService.d.ts +0 -0
- /package/dist/{src → types/src}/proof/basic/depositProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/basic/joinProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/basic/tripleJoinProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/basic/withdrawProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/keyService.d.ts +0 -0
- /package/dist/{src → types/src}/proof/noteService.d.ts +0 -0
- /package/dist/{src → types/src}/proof/pro/orders/cancelOrderProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/pro/orders/createOrderProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/pro/orders/swapProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/retail/cancelOrderProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/retail/depositOrderProof.d.ts +0 -0
- /package/dist/{src → types/src}/proof/retail/swapProof.d.ts +0 -0
- /package/dist/{src → types/src}/services/BaseService.d.ts +0 -0
- /package/dist/{src → types/src}/services/EventService.d.ts +0 -0
- /package/dist/{src → types/src}/services/base/deposit.d.ts +0 -0
- /package/dist/{src → types/src}/services/base/index.d.ts +0 -0
- /package/dist/{src → types/src}/services/base/join.d.ts +0 -0
- /package/dist/{src → types/src}/services/base/tripleJoin.d.ts +0 -0
- /package/dist/{src → types/src}/services/base/withdraw.d.ts +0 -0
- /package/dist/{src → types/src}/services/index.d.ts +0 -0
- /package/dist/{src → types/src}/services/merkletree.d.ts +0 -0
- /package/dist/{src → types/src}/services/pro/cancelOrder.d.ts +0 -0
- /package/dist/{src → types/src}/services/pro/createOrder.d.ts +0 -0
- /package/dist/{src → types/src}/services/pro/index.d.ts +0 -0
- /package/dist/{src → types/src}/services/pro/proSwap.d.ts +0 -0
- /package/dist/{src → types/src}/services/retail/cancelAndWithdrawOrder.d.ts +0 -0
- /package/dist/{src → types/src}/services/retail/depositAndCreateOrder.d.ts +0 -0
- /package/dist/{src → types/src}/services/retail/index.d.ts +0 -0
- /package/dist/{src → types/src}/types.d.ts +0 -0
- /package/dist/{src → types/src}/utils/constants.d.ts +0 -0
- /package/dist/{src → types/src}/utils/encoders.d.ts +0 -0
- /package/dist/{src → types/src}/utils/formatters.d.ts +0 -0
- /package/dist/{src → types/src}/utils/mimc.d.ts +0 -0
- /package/dist/{src → types/src}/utils/proofUtils.d.ts +0 -0
- /package/dist/{src → types/src}/utils/util.d.ts +0 -0
- /package/dist/{test → types/test}/proof/depositProof.test.d.ts +0 -0
- /package/dist/{test → types/test}/proof/keyService.test.d.ts +0 -0
- /package/dist/{test → types/test}/proof/retail/cancelOrderProof.test.d.ts +0 -0
- /package/dist/{test → types/test}/proof/retail/createOrderProof.test.d.ts +0 -0
- /package/dist/{test → types/test}/services/depositService.test.d.ts +0 -0
- /package/dist/{test → types/test}/utils/helpers.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
|
|
2
|
-
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
3
2
|
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr, Fq } from '@aztec/foundation/fields';
|
|
4
|
+
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
4
5
|
import { Noir } from '@noir-lang/noir_js';
|
|
5
|
-
import { Fq, Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@ async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2690,13 +2703,6 @@ async function signMessage(message, fuzkPriKey) {
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -5183,5 +5189,5 @@ class DarkSwap {
|
|
|
5183
5189
|
}
|
|
5184
5190
|
}
|
|
5185
5191
|
|
|
5186
|
-
export { DarkSwap, DarkSwapError, DepositContext, DepositService, EMPTY_PATH, JoinService, NoteOnChainStatus, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, multiGetMerklePathAndRoot };
|
|
5192
|
+
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5187
5193
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
|
|
2
|
-
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
3
2
|
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr, Fq } from '@aztec/foundation/fields';
|
|
4
|
+
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
4
5
|
import { Noir } from '@noir-lang/noir_js';
|
|
5
|
-
import { Fq, Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@ async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2690,13 +2703,6 @@ async function signMessage(message, fuzkPriKey) {
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -5183,5 +5189,5 @@ class DarkSwap {
|
|
|
5183
5189
|
}
|
|
5184
5190
|
}
|
|
5185
5191
|
|
|
5186
|
-
export { DarkSwap, DarkSwapError, DepositContext, DepositService, EMPTY_PATH, JoinService, NoteOnChainStatus, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, multiGetMerklePathAndRoot };
|
|
5192
|
+
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5187
5193
|
//# 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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=== 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@aztec/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@aztec/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DarkSwapSDK = {}, global.ethers, global.
|
|
5
|
-
})(this, (function (exports, ethers,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@aztec/foundation/crypto'), require('@aztec/foundation/fields'), require('@aztec/bb.js'), require('@noir-lang/noir_js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@aztec/foundation/crypto', '@aztec/foundation/fields', '@aztec/bb.js', '@noir-lang/noir_js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DarkSwapSDK = {}, global.ethers, global.crypto, global.fields, global.AztecBB, global.NoirJS));
|
|
5
|
+
})(this, (function (exports, ethers, crypto, fields, bb_js, noir_js) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new crypto.Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2411,7 +2424,7 @@
|
|
|
2411
2424
|
var ERC20_USDT = {
|
|
2412
2425
|
abi: abi$6};
|
|
2413
2426
|
|
|
2414
|
-
|
|
2427
|
+
exports.ChainId = void 0;
|
|
2415
2428
|
(function (ChainId) {
|
|
2416
2429
|
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
|
2417
2430
|
ChainId[ChainId["HARDHAT_ARBITRUM"] = 31338] = "HARDHAT_ARBITRUM";
|
|
@@ -2420,11 +2433,11 @@
|
|
|
2420
2433
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
2421
2434
|
ChainId[ChainId["ARBITRUM_ONE"] = 42161] = "ARBITRUM_ONE";
|
|
2422
2435
|
ChainId[ChainId["BASE"] = 8453] = "BASE";
|
|
2423
|
-
})(ChainId || (ChainId = {}));
|
|
2436
|
+
})(exports.ChainId || (exports.ChainId = {}));
|
|
2424
2437
|
|
|
2425
2438
|
const legacyTokenConfig = {
|
|
2426
|
-
[ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2427
|
-
[ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2439
|
+
[exports.ChainId.MAINNET]: ['0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
2440
|
+
[exports.ChainId.HARDHAT]: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
|
|
2428
2441
|
};
|
|
2429
2442
|
const FEE_RATIO = 300n;
|
|
2430
2443
|
|
|
@@ -2633,7 +2646,7 @@
|
|
|
2633
2646
|
brillig_names: brillig_names$5
|
|
2634
2647
|
};
|
|
2635
2648
|
|
|
2636
|
-
|
|
2649
|
+
exports.PROOF_DOMAIN = void 0;
|
|
2637
2650
|
(function (PROOF_DOMAIN) {
|
|
2638
2651
|
PROOF_DOMAIN[PROOF_DOMAIN["DEPOSIT"] = 10001] = "DEPOSIT";
|
|
2639
2652
|
PROOF_DOMAIN[PROOF_DOMAIN["WITHDRAW"] = 10002] = "WITHDRAW";
|
|
@@ -2645,7 +2658,7 @@
|
|
|
2645
2658
|
PROOF_DOMAIN[PROOF_DOMAIN["JOIN"] = 10008] = "JOIN";
|
|
2646
2659
|
PROOF_DOMAIN[PROOF_DOMAIN["TRIPLE_JOIN"] = 10009] = "TRIPLE_JOIN";
|
|
2647
2660
|
PROOF_DOMAIN[PROOF_DOMAIN["RETAIL_SWAP"] = 10010] = "RETAIL_SWAP";
|
|
2648
|
-
})(PROOF_DOMAIN || (PROOF_DOMAIN = {}));
|
|
2661
|
+
})(exports.PROOF_DOMAIN || (exports.PROOF_DOMAIN = {}));
|
|
2649
2662
|
const EMPTY_NULLIFIER = 0n;
|
|
2650
2663
|
const EMPTY_FOOTER = 0n;
|
|
2651
2664
|
const FEE_RATIO_PRECISION = 1000000n;
|
|
@@ -2690,13 +2703,6 @@
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new crypto.Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -2713,7 +2719,7 @@
|
|
|
2713
2719
|
const newBalanceFooter = getNoteFooter(param.newBalanceNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
2714
2720
|
const addressMod = encodeAddress(param.address);
|
|
2715
2721
|
const message = bn_to_hex(mimc_bn254([
|
|
2716
|
-
BigInt(PROOF_DOMAIN.DEPOSIT),
|
|
2722
|
+
BigInt(exports.PROOF_DOMAIN.DEPOSIT),
|
|
2717
2723
|
oldBalanceNullifier,
|
|
2718
2724
|
addressMod,
|
|
2719
2725
|
param.newBalanceNote.note,
|
|
@@ -3187,7 +3193,7 @@
|
|
|
3187
3193
|
const addressMod = encodeAddress(param.address);
|
|
3188
3194
|
const assetMod = encodeAddress(param.oldBalance.asset);
|
|
3189
3195
|
const message = bn_to_hex(mimc_bn254([
|
|
3190
|
-
BigInt(PROOF_DOMAIN.WITHDRAW),
|
|
3196
|
+
BigInt(exports.PROOF_DOMAIN.WITHDRAW),
|
|
3191
3197
|
addressMod,
|
|
3192
3198
|
oldBalanceNullifier,
|
|
3193
3199
|
param.newBalance.note,
|
|
@@ -3579,7 +3585,7 @@
|
|
|
3579
3585
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
3580
3586
|
const addressMod = encodeAddress(param.address);
|
|
3581
3587
|
const message = bn_to_hex(mimc_bn254([
|
|
3582
|
-
BigInt(PROOF_DOMAIN.JOIN),
|
|
3588
|
+
BigInt(exports.PROOF_DOMAIN.JOIN),
|
|
3583
3589
|
inNullifier1,
|
|
3584
3590
|
inNullifier2,
|
|
3585
3591
|
param.outNote.note,
|
|
@@ -4043,7 +4049,7 @@
|
|
|
4043
4049
|
const outNoteFooter = getNoteFooter(param.outNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4044
4050
|
const addressMod = encodeAddress(param.address);
|
|
4045
4051
|
const message = bn_to_hex(mimc_bn254([
|
|
4046
|
-
BigInt(PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4052
|
+
BigInt(exports.PROOF_DOMAIN.TRIPLE_JOIN),
|
|
4047
4053
|
inNullifier1,
|
|
4048
4054
|
inNullifier2,
|
|
4049
4055
|
inNullifier3,
|
|
@@ -4245,7 +4251,7 @@
|
|
|
4245
4251
|
const orderNoteFooter = getNoteFooter(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4246
4252
|
const addressMod = encodeAddress(param.address);
|
|
4247
4253
|
const message = bn_to_hex(mimc_bn254([
|
|
4248
|
-
BigInt(PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4254
|
+
BigInt(exports.PROOF_DOMAIN.PRO_CREATE_ORDER),
|
|
4249
4255
|
oldBalanceNullifier,
|
|
4250
4256
|
addressMod,
|
|
4251
4257
|
param.newBalanceNote.note,
|
|
@@ -4621,7 +4627,7 @@
|
|
|
4621
4627
|
const nullifier = calcNullifier(param.orderNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4622
4628
|
const addressMod = encodeAddress(param.address);
|
|
4623
4629
|
const message = bn_to_hex(mimc_bn254([
|
|
4624
|
-
BigInt(PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
4630
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CANCEL_ORDER),
|
|
4625
4631
|
addressMod,
|
|
4626
4632
|
nullifier,
|
|
4627
4633
|
param.orderNote.feeRatio,
|
|
@@ -4916,7 +4922,7 @@
|
|
|
4916
4922
|
const addressMod = encodeAddress(address);
|
|
4917
4923
|
calcNullifier(orderNote.rho, pubKey);
|
|
4918
4924
|
const message = bn_to_hex(mimc_bn254([
|
|
4919
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
4925
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
4920
4926
|
addressMod,
|
|
4921
4927
|
orderNote.note,
|
|
4922
4928
|
orderNote.feeRatio,
|
|
@@ -4944,7 +4950,7 @@
|
|
|
4944
4950
|
const swapInNoteFooter = getNoteFooter(param.swapInNote.rho, [fuzkPubKeyX, fuzkPubKeyY]);
|
|
4945
4951
|
const addressMod = encodeAddress(param.address);
|
|
4946
4952
|
const message = bn_to_hex(mimc_bn254([
|
|
4947
|
-
BigInt(PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
4953
|
+
BigInt(exports.PROOF_DOMAIN.RETAIL_CREATE_ORDER),
|
|
4948
4954
|
addressMod,
|
|
4949
4955
|
param.depositNote.note,
|
|
4950
4956
|
param.depositNote.feeRatio,
|
|
@@ -5091,7 +5097,7 @@
|
|
|
5091
5097
|
}
|
|
5092
5098
|
|
|
5093
5099
|
const contractConfig = {
|
|
5094
|
-
[ChainId.MAINNET]: {
|
|
5100
|
+
[exports.ChainId.MAINNET]: {
|
|
5095
5101
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
5096
5102
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
5097
5103
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -5100,7 +5106,7 @@
|
|
|
5100
5106
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
5101
5107
|
drakpoolSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-subgraph/version/v0.0.1/api',
|
|
5102
5108
|
},
|
|
5103
|
-
[ChainId.ARBITRUM_ONE]: {
|
|
5109
|
+
[exports.ChainId.ARBITRUM_ONE]: {
|
|
5104
5110
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
5105
5111
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
5106
5112
|
nativeWrapper: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
@@ -5109,7 +5115,7 @@
|
|
|
5109
5115
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
5110
5116
|
drakpoolSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-arb-subgraph/api'
|
|
5111
5117
|
},
|
|
5112
|
-
[ChainId.BASE]: {
|
|
5118
|
+
[exports.ChainId.BASE]: {
|
|
5113
5119
|
priceOracle: '0xf224a25453D76A41c4427DD1C05369BC9f498444',
|
|
5114
5120
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
5115
5121
|
nativeWrapper: '0x4200000000000000000000000000000000000006',
|
|
@@ -5118,7 +5124,7 @@
|
|
|
5118
5124
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
5119
5125
|
drakpoolSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-base-subgraph/api'
|
|
5120
5126
|
},
|
|
5121
|
-
[ChainId.SEPOLIA]: {
|
|
5127
|
+
[exports.ChainId.SEPOLIA]: {
|
|
5122
5128
|
priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
|
|
5123
5129
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
5124
5130
|
nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
@@ -5127,7 +5133,7 @@
|
|
|
5127
5133
|
darkSwapFeeAssetManager: '0x0', //FIXME
|
|
5128
5134
|
drakpoolSubgraphUrl: ''
|
|
5129
5135
|
},
|
|
5130
|
-
[ChainId.HARDHAT]: {
|
|
5136
|
+
[exports.ChainId.HARDHAT]: {
|
|
5131
5137
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
5132
5138
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
5133
5139
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -5185,17 +5191,25 @@
|
|
|
5185
5191
|
|
|
5186
5192
|
exports.DarkSwap = DarkSwap;
|
|
5187
5193
|
exports.DarkSwapError = DarkSwapError;
|
|
5194
|
+
exports.DarkSwapProofError = DarkSwapProofError;
|
|
5188
5195
|
exports.DepositContext = DepositContext;
|
|
5189
5196
|
exports.DepositService = DepositService;
|
|
5197
|
+
exports.EMPTY_FOOTER = EMPTY_FOOTER;
|
|
5198
|
+
exports.EMPTY_NULLIFIER = EMPTY_NULLIFIER;
|
|
5190
5199
|
exports.EMPTY_PATH = EMPTY_PATH;
|
|
5200
|
+
exports.FEE_RATIO = FEE_RATIO;
|
|
5201
|
+
exports.FEE_RATIO_PRECISION = FEE_RATIO_PRECISION;
|
|
5191
5202
|
exports.JoinService = JoinService;
|
|
5192
5203
|
exports.ProCreateOrderService = ProCreateOrderService;
|
|
5193
5204
|
exports.RetailCancelOrderService = RetailCancelOrderService;
|
|
5194
5205
|
exports.RetailCreateOrderService = RetailCreateOrderService;
|
|
5195
5206
|
exports.TripleJoinService = TripleJoinService;
|
|
5196
5207
|
exports.WithdrawService = WithdrawService;
|
|
5208
|
+
exports.contractConfig = contractConfig;
|
|
5209
|
+
exports.generateKeyPair = generateKeyPair;
|
|
5197
5210
|
exports.getMerklePathAndRoot = getMerklePathAndRoot;
|
|
5198
5211
|
exports.getNoteOnChainStatusByPublicKey = getNoteOnChainStatusByPublicKey;
|
|
5212
|
+
exports.getNoteOnChainStatusBySignature = getNoteOnChainStatusBySignature;
|
|
5199
5213
|
exports.hexlify32 = hexlify32;
|
|
5200
5214
|
exports.isAddressEquals = isAddressEquals;
|
|
5201
5215
|
exports.isHexEquals = isHexEquals;
|
|
@@ -5203,6 +5217,7 @@
|
|
|
5203
5217
|
exports.isNoteActive = isNoteActive;
|
|
5204
5218
|
exports.isNoteSpent = isNoteSpent;
|
|
5205
5219
|
exports.isNoteValid = isNoteValid;
|
|
5220
|
+
exports.legacyTokenConfig = legacyTokenConfig;
|
|
5206
5221
|
exports.multiGetMerklePathAndRoot = multiGetMerklePathAndRoot;
|
|
5207
5222
|
|
|
5208
5223
|
}));
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { DarkSwap } from '../darkSwap';
|
|
|
3
3
|
import { DarkSwapNote } from '../types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
export declare function getNoteOnChainStatusByPublicKey(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<NoteOnChainStatus>;
|
|
6
|
+
export declare function getNoteOnChainStatusBySignature(darkSwap: DarkSwap, note: DarkSwapNote, signature: string): Promise<NoteOnChainStatus>;
|
|
6
7
|
export declare function isNoteActive(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
|
7
8
|
export declare function isNoteSpent(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
|
8
9
|
export declare function isNoteValid(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thesingularitynetwork/darkswap-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
3
|
+
"version": "0.1.3",
|
|
7
4
|
"description": "DarkSwap SDK for browser and Node.js",
|
|
8
5
|
"type": "module",
|
|
6
|
+
"types": "dist/types/src/index.d.ts",
|
|
9
7
|
"main": "dist/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
|
-
"module": "dist/index.esm.js",
|
|
12
8
|
"files": [
|
|
13
9
|
"dist",
|
|
14
10
|
"src"
|
|
15
11
|
],
|
|
16
12
|
"scripts": {
|
|
17
|
-
"build": "
|
|
13
|
+
"build:types": "tsc -p tsconfig.json",
|
|
14
|
+
"build:js": "rollup -c",
|
|
15
|
+
"build": "yarn build:types && yarn build:js",
|
|
18
16
|
"dev": "rollup -c --bundleConfigAsCjs -w",
|
|
19
17
|
"test": "vitest",
|
|
20
18
|
"lint": "eslint src --ext .ts",
|
|
@@ -39,7 +37,6 @@
|
|
|
39
37
|
"eslint": "^9.27.0",
|
|
40
38
|
"prettier": "^3.5.3",
|
|
41
39
|
"rollup": "^4.41.1",
|
|
42
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
43
40
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
44
41
|
"ts-node": "^10.9.2",
|
|
45
42
|
"typescript": "^5.8.3",
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DarkSwap } from '../darkSwap';
|
|
|
6
6
|
import { DarkSwapNote } from '../types';
|
|
7
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
8
|
import { calcNullifier } from '../proof/noteService';
|
|
9
|
+
import { generateKeyPair } from '../proof/keyService';
|
|
9
10
|
|
|
10
11
|
function getContract(address: string, darkSwap: DarkSwap) {
|
|
11
12
|
const provider = darkSwap.provider;
|
|
@@ -39,6 +40,17 @@ export async function getNoteOnChainStatusByPublicKey(
|
|
|
39
40
|
return onChainStatus;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
export async function getNoteOnChainStatusBySignature(
|
|
44
|
+
darkSwap: DarkSwap,
|
|
45
|
+
note: DarkSwapNote,
|
|
46
|
+
signature: string
|
|
47
|
+
): Promise<NoteOnChainStatus> {
|
|
48
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
49
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
50
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
51
|
+
return onChainStatus;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
export async function isNoteActive(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean> {
|
|
43
55
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
44
56
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|