quantumswap 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish-npmjs.yaml +22 -0
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/examples/_test-wallet.js +17 -0
- package/examples/deploy-IERC20.js +23 -0
- package/examples/deploy-QuantumSwapV2ERC20.js +23 -0
- package/examples/deploy-QuantumSwapV2Factory.js +23 -0
- package/examples/deploy-QuantumSwapV2Pair.js +23 -0
- package/examples/deploy-QuantumSwapV2Router02.js +23 -0
- package/examples/deploy-WQ.js +23 -0
- package/examples/events-IERC20.js +20 -0
- package/examples/events-QuantumSwapV2ERC20.js +20 -0
- package/examples/events-QuantumSwapV2Factory.js +20 -0
- package/examples/events-QuantumSwapV2Pair.js +20 -0
- package/examples/events-QuantumSwapV2Router02.js +20 -0
- package/examples/events-WQ.js +20 -0
- package/examples/offline-signing-IERC20.js +29 -0
- package/examples/offline-signing-QuantumSwapV2ERC20.js +29 -0
- package/examples/offline-signing-QuantumSwapV2Factory.js +29 -0
- package/examples/offline-signing-QuantumSwapV2Pair.js +29 -0
- package/examples/offline-signing-QuantumSwapV2Router02.js +29 -0
- package/examples/offline-signing-WQ.js +29 -0
- package/examples/read-operations-IERC20.js +19 -0
- package/examples/read-operations-QuantumSwapV2ERC20.js +19 -0
- package/examples/read-operations-QuantumSwapV2Factory.js +19 -0
- package/examples/read-operations-QuantumSwapV2Pair.js +19 -0
- package/examples/read-operations-QuantumSwapV2Router02.js +19 -0
- package/examples/read-operations-WQ.js +19 -0
- package/examples/walkthrough-dex-full-flow.js +226 -0
- package/examples/walkthrough-dex-full-flow.ts +231 -0
- package/examples/write-operations-IERC20.js +22 -0
- package/examples/write-operations-QuantumSwapV2ERC20.js +22 -0
- package/examples/write-operations-QuantumSwapV2Factory.js +22 -0
- package/examples/write-operations-QuantumSwapV2Pair.js +22 -0
- package/examples/write-operations-QuantumSwapV2Router02.js +22 -0
- package/examples/write-operations-WQ.js +22 -0
- package/index.d.ts +1 -0
- package/index.js +45 -0
- package/package.json +35 -0
- package/src/IERC20.d.ts +24 -0
- package/src/IERC20.js +348 -0
- package/src/IERC20__factory.d.ts +10 -0
- package/src/IERC20__factory.js +29 -0
- package/src/QuantumSwapV2ERC20.d.ts +24 -0
- package/src/QuantumSwapV2ERC20.js +353 -0
- package/src/QuantumSwapV2ERC20__factory.d.ts +10 -0
- package/src/QuantumSwapV2ERC20__factory.js +29 -0
- package/src/QuantumSwapV2Factory.d.ts +24 -0
- package/src/QuantumSwapV2Factory.js +310 -0
- package/src/QuantumSwapV2Factory__factory.d.ts +10 -0
- package/src/QuantumSwapV2Factory__factory.js +29 -0
- package/src/QuantumSwapV2Pair.d.ts +44 -0
- package/src/QuantumSwapV2Pair.js +847 -0
- package/src/QuantumSwapV2Pair__factory.d.ts +10 -0
- package/src/QuantumSwapV2Pair__factory.js +29 -0
- package/src/QuantumSwapV2Router02.d.ts +47 -0
- package/src/QuantumSwapV2Router02.js +1109 -0
- package/src/QuantumSwapV2Router02__factory.d.ts +10 -0
- package/src/QuantumSwapV2Router02__factory.js +29 -0
- package/src/WQ.d.ts +28 -0
- package/src/WQ.js +435 -0
- package/src/WQ__factory.d.ts +10 -0
- package/src/WQ__factory.js +29 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +15 -0
- package/src/quantumcoin-shims.d.ts +25 -0
- package/src/types.d.ts +3 -0
- package/src/types.js +3 -0
- package/test/e2e/IERC20.e2e.test.js +79 -0
- package/test/e2e/QuantumSwapV2ERC20.e2e.test.js +79 -0
- package/test/e2e/QuantumSwapV2Factory.e2e.test.js +79 -0
- package/test/e2e/QuantumSwapV2Pair.e2e.test.js +79 -0
- package/test/e2e/QuantumSwapV2Router02.e2e.test.js +79 -0
- package/test/e2e/WQ.e2e.test.js +79 -0
- package/test/e2e/all-contracts.e2e.test.js +103 -0
- package/test/e2e/dex-full-flow.e2e.test.js +353 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walkthrough: full DEX flow using Test Release (Dec 2025) contracts (TypeScript).
|
|
3
|
+
*
|
|
4
|
+
* Same flow as walkthrough-dex-full-flow.js: connect to pre-deployed WQ, Factory, Router;
|
|
5
|
+
* deploy two ERC20 tokens (SimpleERC20), create pair, add liquidity, swap token-for-token,
|
|
6
|
+
* then swap ETH for token.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* QC_RPC_URL=http://your-rpc:8545 npx ts-node examples/walkthrough-dex-full-flow.ts
|
|
10
|
+
*
|
|
11
|
+
* Optional: QC_CHAIN_ID (default 123123), QC_WALLET_JSON + QC_WALLET_PASSPHRASE (else uses _test-wallet).
|
|
12
|
+
*
|
|
13
|
+
* Requires: quantumcoin package with examples/sdk-generator-erc20.inline.json (SimpleERC20 artifact).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import * as path from "node:path";
|
|
17
|
+
|
|
18
|
+
import { Initialize } from "quantumcoin/config";
|
|
19
|
+
import {
|
|
20
|
+
JsonRpcProvider,
|
|
21
|
+
Wallet,
|
|
22
|
+
Contract,
|
|
23
|
+
ContractFactory,
|
|
24
|
+
getCreateAddress,
|
|
25
|
+
getAddress,
|
|
26
|
+
parseUnits,
|
|
27
|
+
isAddress,
|
|
28
|
+
} from "quantumcoin";
|
|
29
|
+
|
|
30
|
+
import {
|
|
31
|
+
WQ,
|
|
32
|
+
QuantumSwapV2Factory,
|
|
33
|
+
QuantumSwapV2Router02,
|
|
34
|
+
QuantumSwapV2Pair,
|
|
35
|
+
} from "..";
|
|
36
|
+
|
|
37
|
+
// Test Release (Dec 2025) — do not deploy these
|
|
38
|
+
const WQ_CONTRACT_ADDRESS = "0x0E49c26cd1ca19bF8ddA2C8985B96783288458754757F4C9E00a5439A7291628";
|
|
39
|
+
const V2_CORE_FACTORY_CONTRACT_ADDRESS = "0xbbF45a1B60044669793B444eD01Eb33e03Bb8cf3c5b6ae7887B218D05C5Cbf1d";
|
|
40
|
+
const SWAP_ROUTER_V2_CONTRACT_ADDRESS = "0x41323EF72662185f44a03ea0ad8094a0C9e925aB1102679D8e957e838054aac5";
|
|
41
|
+
|
|
42
|
+
const DEPLOY_GAS_LIMIT = 6_000_000;
|
|
43
|
+
const TX_GAS_LIMIT = 400_000;
|
|
44
|
+
const DEADLINE_OFFSET = 1200;
|
|
45
|
+
|
|
46
|
+
function deadline(): bigint {
|
|
47
|
+
return BigInt(Math.floor(Date.now() / 1000) + DEADLINE_OFFSET);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface SimpleErc20Artifact {
|
|
51
|
+
abi: unknown[];
|
|
52
|
+
bin: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let SIMPLE_ERC20_ABI: unknown[] | null = null;
|
|
56
|
+
let SIMPLE_ERC20_BYTECODE: string | null = null;
|
|
57
|
+
try {
|
|
58
|
+
const qcPkg = require.resolve("quantumcoin/package.json");
|
|
59
|
+
const qcRoot = path.dirname(qcPkg);
|
|
60
|
+
const artifact = require(path.join(qcRoot, "examples", "sdk-generator-erc20.inline.json")) as SimpleErc20Artifact[] | SimpleErc20Artifact;
|
|
61
|
+
const simple = Array.isArray(artifact) ? artifact[0] : artifact;
|
|
62
|
+
SIMPLE_ERC20_ABI = simple.abi as unknown[];
|
|
63
|
+
SIMPLE_ERC20_BYTECODE = simple.bin;
|
|
64
|
+
} catch {
|
|
65
|
+
SIMPLE_ERC20_ABI = null;
|
|
66
|
+
SIMPLE_ERC20_BYTECODE = null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function main(): Promise<void> {
|
|
70
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
71
|
+
if (!rpcUrl) {
|
|
72
|
+
console.error("QC_RPC_URL is required. Example: QC_RPC_URL=http://localhost:8545 npx ts-node examples/walkthrough-dex-full-flow.ts");
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
if (!SIMPLE_ERC20_ABI || !SIMPLE_ERC20_BYTECODE) {
|
|
76
|
+
console.error("SimpleERC20 artifact not found (quantumcoin examples/sdk-generator-erc20.inline.json). Cannot deploy tokens.");
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
81
|
+
await Initialize(null);
|
|
82
|
+
|
|
83
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
84
|
+
let wallet: InstanceType<typeof Wallet>;
|
|
85
|
+
if (process.env.QC_WALLET_JSON && process.env.QC_WALLET_PASSPHRASE) {
|
|
86
|
+
wallet = Wallet.fromEncryptedJsonSync(process.env.QC_WALLET_JSON, process.env.QC_WALLET_PASSPHRASE, provider);
|
|
87
|
+
} else {
|
|
88
|
+
const { createTestWallet } = require("./_test-wallet") as { createTestWallet: (provider: InstanceType<typeof JsonRpcProvider>) => InstanceType<typeof Wallet> };
|
|
89
|
+
wallet = createTestWallet(provider);
|
|
90
|
+
console.log("Using demo test wallet (set QC_WALLET_JSON + QC_WALLET_PASSPHRASE for your own).");
|
|
91
|
+
}
|
|
92
|
+
const walletAddr = getAddress(wallet.address);
|
|
93
|
+
|
|
94
|
+
// Step 1: Connect to pre-deployed WQ, Factory, Router
|
|
95
|
+
console.log("Step 1: Connecting to Test Release contracts...");
|
|
96
|
+
const wq = WQ.connect(WQ_CONTRACT_ADDRESS, wallet);
|
|
97
|
+
const wqAddressNorm = getAddress(WQ_CONTRACT_ADDRESS);
|
|
98
|
+
const factoryContract = QuantumSwapV2Factory.connect(V2_CORE_FACTORY_CONTRACT_ADDRESS, wallet);
|
|
99
|
+
const routerContract = QuantumSwapV2Router02.connect(SWAP_ROUTER_V2_CONTRACT_ADDRESS, wallet);
|
|
100
|
+
const routerAddress = routerContract.target;
|
|
101
|
+
console.log(" WQ:", wqAddressNorm);
|
|
102
|
+
console.log(" Factory:", getAddress(V2_CORE_FACTORY_CONTRACT_ADDRESS));
|
|
103
|
+
console.log(" Router:", getAddress(routerAddress));
|
|
104
|
+
|
|
105
|
+
// Step 2: Deploy two ERC20 tokens (SimpleERC20 with initial supply)
|
|
106
|
+
console.log("Step 2: Deploying TokenA and TokenB (SimpleERC20)...");
|
|
107
|
+
const initialSupply = parseUnits("1000000", 18);
|
|
108
|
+
const simpleErc20Factory = new ContractFactory(SIMPLE_ERC20_ABI, SIMPLE_ERC20_BYTECODE, wallet);
|
|
109
|
+
const deploySimpleErc20 = async (name: string, symbol: string): Promise<InstanceType<typeof Contract> & { _deployTx?: unknown }> => {
|
|
110
|
+
const tx = simpleErc20Factory.getDeployTransaction(name, symbol, initialSupply);
|
|
111
|
+
const nonce = await provider.getTransactionCount(walletAddr, "pending");
|
|
112
|
+
const address = getCreateAddress({ from: walletAddr, nonce });
|
|
113
|
+
const resp = await wallet.sendTransaction({ ...tx, nonce, gasLimit: DEPLOY_GAS_LIMIT });
|
|
114
|
+
await resp.wait(1, 600_000);
|
|
115
|
+
const contract = new Contract(address, SIMPLE_ERC20_ABI, wallet) as InstanceType<typeof Contract> & { _deployTx?: unknown };
|
|
116
|
+
contract._deployTx = resp;
|
|
117
|
+
return contract;
|
|
118
|
+
};
|
|
119
|
+
const tokenA = await deploySimpleErc20("TokenA", "TKA");
|
|
120
|
+
const tokenB = await deploySimpleErc20("TokenB", "TKB");
|
|
121
|
+
const tokenAAddress = getAddress(tokenA.target);
|
|
122
|
+
const tokenBAddress = getAddress(tokenB.target);
|
|
123
|
+
console.log(" TokenA:", tokenAAddress);
|
|
124
|
+
console.log(" TokenB:", tokenBAddress);
|
|
125
|
+
|
|
126
|
+
// Step 3: Create pair
|
|
127
|
+
console.log("Step 3: Creating pair (TokenA, TokenB)...");
|
|
128
|
+
const createPairTx = await factoryContract.createPair(tokenAAddress, tokenBAddress, { gasLimit: TX_GAS_LIMIT });
|
|
129
|
+
await createPairTx.wait(1, 600_000);
|
|
130
|
+
const pairAddressFromEvent = getAddress(await factoryContract.getPair(tokenAAddress, tokenBAddress));
|
|
131
|
+
const zeroAddress32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
132
|
+
const pairCreated = pairAddressFromEvent && isAddress(pairAddressFromEvent) && pairAddressFromEvent !== zeroAddress32 && pairAddressFromEvent !== "0x" + "0".repeat(64);
|
|
133
|
+
if (!pairCreated) {
|
|
134
|
+
console.error(" Pair not created (getPair returned zero or invalid address).");
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
console.log(" Pair:", pairAddressFromEvent);
|
|
138
|
+
|
|
139
|
+
// Step 4: Add liquidity
|
|
140
|
+
console.log("Step 4: Adding liquidity...");
|
|
141
|
+
const amountADesired = parseUnits("1000", 18);
|
|
142
|
+
const amountBDesired = parseUnits("1000", 18);
|
|
143
|
+
const approveAmount = amountADesired > amountBDesired ? amountADesired : amountBDesired;
|
|
144
|
+
await (await tokenA.approve(routerAddress, approveAmount, { gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
145
|
+
await (await tokenB.approve(routerAddress, approveAmount, { gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
146
|
+
const addLiqTx = await routerContract.addLiquidity(
|
|
147
|
+
tokenAAddress,
|
|
148
|
+
tokenBAddress,
|
|
149
|
+
amountADesired,
|
|
150
|
+
amountBDesired,
|
|
151
|
+
0n,
|
|
152
|
+
0n,
|
|
153
|
+
walletAddr,
|
|
154
|
+
deadline(),
|
|
155
|
+
{ gasLimit: TX_GAS_LIMIT },
|
|
156
|
+
);
|
|
157
|
+
await addLiqTx.wait(1, 600_000);
|
|
158
|
+
const pairContract = QuantumSwapV2Pair.connect(pairAddressFromEvent, provider);
|
|
159
|
+
const reservesAfter = await pairContract.getReserves();
|
|
160
|
+
const res0 = Array.isArray(reservesAfter) ? reservesAfter[0] : reservesAfter;
|
|
161
|
+
const res1 = Array.isArray(reservesAfter) ? reservesAfter[1] : 0n;
|
|
162
|
+
console.log(" Reserves after addLiquidity:", res0.toString(), res1.toString());
|
|
163
|
+
|
|
164
|
+
// Step 5: Swap token for token
|
|
165
|
+
console.log("Step 5: Swapping TokenA -> TokenB (swapExactTokensForTokens)...");
|
|
166
|
+
const swapAmountIn = parseUnits("10", 18);
|
|
167
|
+
const pathSwap = [tokenAAddress, tokenBAddress];
|
|
168
|
+
await (await tokenA.approve(routerAddress, swapAmountIn, { gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
169
|
+
const swapTx = await routerContract.swapExactTokensForTokens(
|
|
170
|
+
swapAmountIn,
|
|
171
|
+
0n,
|
|
172
|
+
pathSwap,
|
|
173
|
+
walletAddr,
|
|
174
|
+
deadline(),
|
|
175
|
+
{ gasLimit: TX_GAS_LIMIT },
|
|
176
|
+
);
|
|
177
|
+
await swapTx.wait(1, 600_000);
|
|
178
|
+
const tokenBBalanceAfterSwapRaw = await tokenB.balanceOf(walletAddr);
|
|
179
|
+
const tokenBBalanceAfterSwap = typeof tokenBBalanceAfterSwapRaw === "bigint" ? tokenBBalanceAfterSwapRaw : BigInt(String(tokenBBalanceAfterSwapRaw));
|
|
180
|
+
console.log(" TokenB balance after swap:", tokenBBalanceAfterSwap.toString());
|
|
181
|
+
|
|
182
|
+
// Step 6: Swap ETH for token (wrap, add WQ-token liquidity if needed, swapExactETHForTokens)
|
|
183
|
+
console.log("Step 6: Swapping ETH for TokenA (wrap, addLiquidityETH, swapExactETHForTokens)...");
|
|
184
|
+
const ethToWrap = parseUnits("1", 18);
|
|
185
|
+
await (await wq.deposit({ value: ethToWrap, gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
186
|
+
|
|
187
|
+
const pairWqTokenA = await factoryContract.getPair(wqAddressNorm, tokenAAddress);
|
|
188
|
+
let pairWqTokenAAddr: string | null = null;
|
|
189
|
+
try {
|
|
190
|
+
pairWqTokenAAddr = getAddress(pairWqTokenA);
|
|
191
|
+
} catch {
|
|
192
|
+
pairWqTokenAAddr = null;
|
|
193
|
+
}
|
|
194
|
+
const zeroAddr = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
195
|
+
const hasWqPair = pairWqTokenAAddr && isAddress(pairWqTokenAAddr) && pairWqTokenAAddr !== zeroAddr && pairWqTokenAAddr !== "0x" + "0".repeat(64);
|
|
196
|
+
if (!hasWqPair) {
|
|
197
|
+
await (await factoryContract.createPair(wqAddressNorm, tokenAAddress, { gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
198
|
+
}
|
|
199
|
+
const tokenForEthLiq = parseUnits("500", 18);
|
|
200
|
+
await (await tokenA.approve(routerAddress, tokenForEthLiq, { gasLimit: TX_GAS_LIMIT })).wait(1, 600_000);
|
|
201
|
+
await (
|
|
202
|
+
await routerContract.addLiquidityETH(
|
|
203
|
+
tokenAAddress,
|
|
204
|
+
tokenForEthLiq,
|
|
205
|
+
0n,
|
|
206
|
+
0n,
|
|
207
|
+
walletAddr,
|
|
208
|
+
deadline(),
|
|
209
|
+
{ value: ethToWrap, gasLimit: TX_GAS_LIMIT },
|
|
210
|
+
)
|
|
211
|
+
).wait(1, 600_000);
|
|
212
|
+
|
|
213
|
+
const ethSwapValue = parseUnits("0.1", 18);
|
|
214
|
+
const pathEthToToken = [wqAddressNorm, tokenAAddress];
|
|
215
|
+
const swapEthTx = await routerContract.swapExactETHForTokens(
|
|
216
|
+
0n,
|
|
217
|
+
pathEthToToken,
|
|
218
|
+
walletAddr,
|
|
219
|
+
deadline(),
|
|
220
|
+
{ value: ethSwapValue, gasLimit: TX_GAS_LIMIT },
|
|
221
|
+
);
|
|
222
|
+
await swapEthTx.wait(1, 600_000);
|
|
223
|
+
console.log(" swapExactETHForTokens completed.");
|
|
224
|
+
|
|
225
|
+
console.log("Walkthrough complete.");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
main().catch((err: unknown) => {
|
|
229
|
+
console.error(err);
|
|
230
|
+
process.exit(1);
|
|
231
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { IERC20 } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = IERC20.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { QuantumSwapV2ERC20 } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = QuantumSwapV2ERC20.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { QuantumSwapV2Factory } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = QuantumSwapV2Factory.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { QuantumSwapV2Pair } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = QuantumSwapV2Pair.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { QuantumSwapV2Router02 } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = QuantumSwapV2Router02.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Initialize } = require("quantumcoin/config");
|
|
2
|
+
const { JsonRpcProvider } = require("quantumcoin");
|
|
3
|
+
const { createTestWallet } = require("./_test-wallet");
|
|
4
|
+
const { WQ } = require("..");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const rpcUrl = process.env.QC_RPC_URL;
|
|
8
|
+
if (!rpcUrl) throw new Error("QC_RPC_URL is required");
|
|
9
|
+
const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;
|
|
10
|
+
const address = process.env.CONTRACT_ADDRESS;
|
|
11
|
+
if (!address) throw new Error("CONTRACT_ADDRESS is required");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const provider = new JsonRpcProvider(rpcUrl, chainId);
|
|
15
|
+
const wallet = createTestWallet(provider);
|
|
16
|
+
const contract = WQ.connect(address, wallet);
|
|
17
|
+
|
|
18
|
+
console.log("Connected:", contract.target);
|
|
19
|
+
console.log("Done");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main().catch((e) => { console.error(e); process.exitCode = 1; });
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated typed contract package.
|
|
3
|
+
*
|
|
4
|
+
* This file re-exports the package entry bundle in `src/`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const entry = require("./src");
|
|
8
|
+
Object.assign(exports, entry);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* IERC20
|
|
12
|
+
*/
|
|
13
|
+
exports.IERC20 = entry.IERC20;
|
|
14
|
+
exports.IERC20__factory = entry.IERC20__factory;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* QuantumSwapV2ERC20
|
|
18
|
+
*/
|
|
19
|
+
exports.QuantumSwapV2ERC20 = entry.QuantumSwapV2ERC20;
|
|
20
|
+
exports.QuantumSwapV2ERC20__factory = entry.QuantumSwapV2ERC20__factory;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* QuantumSwapV2Factory
|
|
24
|
+
*/
|
|
25
|
+
exports.QuantumSwapV2Factory = entry.QuantumSwapV2Factory;
|
|
26
|
+
exports.QuantumSwapV2Factory__factory = entry.QuantumSwapV2Factory__factory;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* QuantumSwapV2Pair
|
|
30
|
+
*/
|
|
31
|
+
exports.QuantumSwapV2Pair = entry.QuantumSwapV2Pair;
|
|
32
|
+
exports.QuantumSwapV2Pair__factory = entry.QuantumSwapV2Pair__factory;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* QuantumSwapV2Router02
|
|
36
|
+
*/
|
|
37
|
+
exports.QuantumSwapV2Router02 = entry.QuantumSwapV2Router02;
|
|
38
|
+
exports.QuantumSwapV2Router02__factory = entry.QuantumSwapV2Router02__factory;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* WQ
|
|
42
|
+
*/
|
|
43
|
+
exports.WQ = entry.WQ;
|
|
44
|
+
exports.WQ__factory = entry.WQ__factory;
|
|
45
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quantumswap",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "QuantumSwap.js SDK for DEX functionality in QuantumCoin blockchain",
|
|
5
|
+
"author": "QuantumSwap Community",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "src/index.js",
|
|
8
|
+
"types": "src/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "node -e \"console.log('JS package: no build step required')\"",
|
|
11
|
+
"build-powershell": "node -e \"console.log('JS package: no build step required')\"",
|
|
12
|
+
"test": "node --test --test-concurrency=1 \"test/**/*.test.js\"",
|
|
13
|
+
"test:e2e": "node --test --test-concurrency=1 \"test/e2e/**/*.test.js\""
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"quantum-coin-pqc-js-sdk": "^1.0.5",
|
|
17
|
+
"seed-words": "^1.0.2",
|
|
18
|
+
"quantum-coin-js-sdk": "^1.0.28",
|
|
19
|
+
"quantumcoin": "7.0.3"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"ts-node": "^10.9.2",
|
|
23
|
+
"typescript": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/quantumswapdex/QuantumSwap.js/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/quantumswapdex/QuantumSwap.js#readme",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"quantumswap",
|
|
31
|
+
"quantum coin",
|
|
32
|
+
"quantumcoin",
|
|
33
|
+
"dex"
|
|
34
|
+
]
|
|
35
|
+
}
|
package/src/IERC20.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Auto-generated by sdkgen
|
|
2
|
+
import { Contract, ContractRunner, ContractTransactionResponse, TransactionResponse } from "quantumcoin";
|
|
3
|
+
import type * as Types from "./types";
|
|
4
|
+
|
|
5
|
+
export declare class IERC20 extends Contract {
|
|
6
|
+
static readonly abi: readonly any[];
|
|
7
|
+
static readonly bytecode: string;
|
|
8
|
+
static connect(address: string, runner?: ContractRunner): IERC20;
|
|
9
|
+
constructor(address: string, runner?: ContractRunner, _deployTx?: TransactionResponse);
|
|
10
|
+
readonly populateTransaction: {
|
|
11
|
+
approve(spender: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
|
|
12
|
+
transfer(to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
|
|
13
|
+
transferFrom(from: Types.AddressLike, to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<import("quantumcoin").TransactionRequest>;
|
|
14
|
+
};
|
|
15
|
+
allowance(owner: Types.AddressLike, spender: Types.AddressLike): Promise<Types.Uint256>;
|
|
16
|
+
approve(spender: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
|
|
17
|
+
balanceOf(owner: Types.AddressLike): Promise<Types.Uint256>;
|
|
18
|
+
decimals(): Promise<Types.Uint8>;
|
|
19
|
+
name(): Promise<string>;
|
|
20
|
+
symbol(): Promise<string>;
|
|
21
|
+
totalSupply(): Promise<Types.Uint256>;
|
|
22
|
+
transfer(to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
|
|
23
|
+
transferFrom(from: Types.AddressLike, to: Types.AddressLike, value: Types.Uint256Like, overrides?: any): Promise<ContractTransactionResponse>;
|
|
24
|
+
}
|