-
Notifications
You must be signed in to change notification settings - Fork 2
/
request_cancel.ts
46 lines (37 loc) · 1.38 KB
/
request_cancel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import "dotenv/config";
import { ethers } from "ethers";
import fs from 'fs';
import path from 'path';
const orderProcessorDataPath = path.resolve(__dirname, '../../lib/sbt-deployments/src/v0.3.0/order_processor.json');
const orderProcessorData = JSON.parse(fs.readFileSync(orderProcessorDataPath, 'utf8'));
const orderProcessorAbi = orderProcessorData.abi;
async function main() {
// ------------------ Setup ------------------
// setup values
const privateKey = process.env.PRIVATE_KEY;
if (!privateKey) throw new Error("empty key");
const RPC_URL = process.env.RPC_URL;
if (!RPC_URL) throw new Error("empty rpc url");
// setup provider and signer
const provider = ethers.getDefaultProvider(RPC_URL);
const signer = new ethers.Wallet(privateKey, provider);
const chainId = Number((await provider.getNetwork()).chainId);
const orderProcessorAddress = orderProcessorData.networkAddresses[chainId];
console.log(`Order Processor Address: ${orderProcessorAddress}`);
// connect signer to order processor contract
const orderProcessor = new ethers.Contract(
orderProcessorAddress,
orderProcessorAbi,
signer,
);
const orderId = 0;
const tx = await orderProcessor.requestCancel(orderId);
console.log(`tx hash: ${tx.hash}`);
await tx.wait();
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});