-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinitialize.js
38 lines (33 loc) · 19.9 KB
/
initialize.js
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
const { ethers } = require('ethers');
require('dotenv').config()
const rpc = process.env.RPC
const pk= process.env.PK
const oofAddress= process.env.OOFAddress
const ABI = [
{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"signers","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"signerThreshold","type":"uint256"},{"indexed":false,"internalType":"address","name":"payout","type":"address"}],"name":"contractSetup","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"uint256","name":"decimal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timelsot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"feedAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"feedSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supportvalue","type":"uint256"}],"name":"feedSupported","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"newFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feed","type":"uint256"}],"name":"newFeedCost","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payout","type":"address"}],"name":"newPayoutAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"uintValue","type":"uint256"},{"indexed":false,"internalType":"address","name":"addressValue","type":"address"},{"indexed":false,"internalType":"uint256","name":"oracleType","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"}],"name":"newProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feed","type":"uint256"}],"name":"newRevenueMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"newSigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"newThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"proposalSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"routerFeeTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"signerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPass","type":"uint256"}],"name":"subscriptionPassPriceUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"buyPass","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"string[]","name":"descriptions","type":"string[]"},{"internalType":"uint256[]","name":"decimals","type":"uint256[]"},{"internalType":"uint256[]","name":"timeslots","type":"uint256[]"},{"internalType":"uint256[]","name":"feedCosts","type":"uint256[]"},{"internalType":"uint256[]","name":"revenueModes","type":"uint256[]"}],"name":"createNewFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"uintValue","type":"uint256"},{"internalType":"address","name":"addressValue","type":"address"},{"internalType":"uint256","name":"proposalType","type":"uint256"},{"internalType":"uint256","name":"feedId","type":"uint256"}],"name":"createProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factoryContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"feedSupport","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"feedID","type":"uint256"}],"name":"getFeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeedLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"}],"name":"getFeedList","outputs":[{"internalType":"string[]","name":"","type":"string[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"}],"name":"getFeeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"timestamps","type":"uint256[]"}],"name":"getHistoricalFeeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"signers_","type":"address[]"},{"internalType":"uint256","name":"signerThreshold_","type":"uint256"},{"internalType":"address payable","name":"payoutAddress_","type":"address"},{"internalType":"uint256","name":"subscriptionPassPrice_","type":"uint256"},{"internalType":"address","name":"factoryContract_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"payoutAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposalList","outputs":[{"internalType":"uint256","name":"uintValue","type":"uint256"},{"internalType":"address","name":"addressValue","type":"address"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint256","name":"proposalType","type":"uint256"},{"internalType":"uint256","name":"proposalFeedId","type":"uint256"},{"internalType":"uint256","name":"proposalActive","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"signProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"signerThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"signers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"submitFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"durations","type":"uint256[]"},{"internalType":"address","name":"buyer","type":"address"}],"name":"subscribeToFeed","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"subscriptionPassPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIds","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"supportFeeds","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawFunds","outputs":[],"stateMutability":"nonpayable","type":"function"}
];
const provider = new ethers.providers.JsonRpcProvider(rpc);
const walletWithProvider = new ethers.Wallet(pk, provider);
const signers = [''];
const threshold = 1
async function init() {
// Get the ABI (Application Binary Interface) of the contract
// Replace with the actual ABI of your contract
const abi = [
{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"signers","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"signerThreshold","type":"uint256"},{"indexed":false,"internalType":"address","name":"payout","type":"address"}],"name":"contractSetup","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"uint256","name":"decimal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timelsot","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"feedAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"feedSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supportvalue","type":"uint256"}],"name":"feedSupported","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"newFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feed","type":"uint256"}],"name":"newFeedCost","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payout","type":"address"}],"name":"newPayoutAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"uintValue","type":"uint256"},{"indexed":false,"internalType":"address","name":"addressValue","type":"address"},{"indexed":false,"internalType":"uint256","name":"oracleType","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"}],"name":"newProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feed","type":"uint256"}],"name":"newRevenueMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"newSigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"newThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"proposalSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"routerFeeTaken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"signerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPass","type":"uint256"}],"name":"subscriptionPassPriceUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"buyPass","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"string[]","name":"descriptions","type":"string[]"},{"internalType":"uint256[]","name":"decimals","type":"uint256[]"},{"internalType":"uint256[]","name":"timeslots","type":"uint256[]"},{"internalType":"uint256[]","name":"feedCosts","type":"uint256[]"},{"internalType":"uint256[]","name":"revenueModes","type":"uint256[]"}],"name":"createNewFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"uintValue","type":"uint256"},{"internalType":"address","name":"addressValue","type":"address"},{"internalType":"uint256","name":"proposalType","type":"uint256"},{"internalType":"uint256","name":"feedId","type":"uint256"}],"name":"createProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factoryContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"feedSupport","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"feedID","type":"uint256"}],"name":"getFeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeedLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"}],"name":"getFeedList","outputs":[{"internalType":"string[]","name":"","type":"string[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"}],"name":"getFeeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"timestamps","type":"uint256[]"}],"name":"getHistoricalFeeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"signers_","type":"address[]"},{"internalType":"uint256","name":"signerThreshold_","type":"uint256"},{"internalType":"address payable","name":"payoutAddress_","type":"address"},{"internalType":"uint256","name":"subscriptionPassPrice_","type":"uint256"},{"internalType":"address","name":"factoryContract_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"payoutAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposalList","outputs":[{"internalType":"uint256","name":"uintValue","type":"uint256"},{"internalType":"address","name":"addressValue","type":"address"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint256","name":"proposalType","type":"uint256"},{"internalType":"uint256","name":"proposalFeedId","type":"uint256"},{"internalType":"uint256","name":"proposalActive","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"signProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"signerThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"signers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"submitFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIDs","type":"uint256[]"},{"internalType":"uint256[]","name":"durations","type":"uint256[]"},{"internalType":"address","name":"buyer","type":"address"}],"name":"subscribeToFeed","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"subscriptionPassPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"feedIds","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"supportFeeds","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawFunds","outputs":[],"stateMutability":"nonpayable","type":"function"}
];
// Create a contract object
const contract = new ethers.Contract(oofAddress, ABI, walletWithProvider);
try {
let tx = await contract.initialize(signers,threshold,'0x0000000000000000000000000000000000000000',0,'0x0000000000000000000000000000000000000001');
const {events, cumulativeGasUsed, gasUsed, transactionHash} = await tx.wait();
console.log(`Cumulative: ${cumulativeGasUsed.toNumber()}`);
console.log(`Gas: ${gasUsed.toNumber()}`)
console.log(`hash: ${transactionHash.toString()}`)
console.log("oracle ready")
} catch (e) {
console.log(e)
}
}
// Example usage
init()