-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
182 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"messagers": { | ||
"crab": { | ||
"msglineMessager": "0xCAb1f69C671f1548fd3dE5d63852E9B9181a0D0E" | ||
"msglineMessager": "0xf85638B61E0425D6BB91981190B73246e3AF3CA9" | ||
}, | ||
"sepolia": { | ||
"msglineMessager": "0x527B67a61C6E1344C359Af2e241aAFeb0c3a9DE9" | ||
"msglineMessager": "0xc876D0873e4060472334E297b2db200Ca10cc806" | ||
} | ||
}, | ||
"backingProxy": { | ||
"crab": "0xb137BDf1Ad5392027832f54a4409685Ef52Aa9dA" | ||
"crab": "0x27F58339CbB8c5A6f58d5D05Bfc1B3fd121F489C" | ||
}, | ||
"backingLogic": { | ||
"crab": "0x0cDc94088C40B461C3c9cF44DD38B328BDca95e9" | ||
"crab": "0xF2274a80e93075ccD5E2Af8F07beF370Bb6dfac7" | ||
}, | ||
"issuingProxy": { | ||
"sepolia": "0x44A001aF6AcD2d5f5cB82FCB14Af3d497D56faB4" | ||
"sepolia": "0xFF3bc7372A8011CFaD43D240464ef2fe74C59b86" | ||
}, | ||
"issuingLogic": { | ||
"sepolia": "0x97cd4227eFC7AEd96CD027994dE2e3E9ACc1b394" | ||
"sepolia": "0x1c955644c527BAA5a28255bCf9F7D3635B7ad99b" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
const ethUtil = require('ethereumjs-util'); | ||
const abi = require('ethereumjs-abi'); | ||
const secp256k1 = require('secp256k1'); | ||
const fs = require("fs"); | ||
|
||
var ProxyDeployer = require("./proxy.js"); | ||
|
||
const privateKey = process.env.PRIKEY | ||
|
||
const crabNetwork = { | ||
name: "crab", | ||
url: "https://crab-rpc.darwinia.network", | ||
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4", | ||
backing: "0x27F58339CbB8c5A6f58d5D05Bfc1B3fd121F489C", | ||
chainid: 44 | ||
}; | ||
|
||
const sepoliaNetwork = { | ||
name: "sepolia", | ||
url: "https://rpc-sepolia.rockx.com", | ||
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4", | ||
issuing: "0xFF3bc7372A8011CFaD43D240464ef2fe74C59b86", | ||
chainid: 11155111 | ||
}; | ||
|
||
function wallet(url) { | ||
const provider = new ethers.providers.JsonRpcProvider(url); | ||
const wallet = new ethers.Wallet(privateKey, provider); | ||
return wallet; | ||
} | ||
|
||
async function registerIssuing() { | ||
const issuingNetwork = sepoliaNetwork; | ||
const walletIssuing = wallet(sepoliaNetwork.url); | ||
|
||
const issuing = await ethers.getContractAt("xTokenIssuing", issuingNetwork.issuing, walletIssuing); | ||
|
||
await issuing.registerxToken( | ||
44, | ||
"0x0000000000000000000000000000000000000000", | ||
"crab", | ||
"crab native token", | ||
"CRAB", | ||
18, | ||
"0x56bc75e2d63100000", | ||
{ gasLimit: 1000000 } | ||
); | ||
} | ||
|
||
async function registerBacking() { | ||
const backingNetwork = crabNetwork; | ||
const walletBacking = wallet(crabNetwork.url); | ||
|
||
const backing = await ethers.getContractAt("xTokenBacking", backingNetwork.backing, walletBacking); | ||
const xToken = "0x4828B88240166B8bB79A833Fd0dD38EaeADAAB1a"; | ||
|
||
await backing.registerOriginalToken( | ||
11155111, | ||
"0x0000000000000000000000000000000000000000", | ||
xToken, | ||
"0x56bc75e2d63100000" | ||
); | ||
} | ||
|
||
async function lockAndRemoteIssuing() { | ||
const backingNetwork = crabNetwork; | ||
const walletBacking = wallet(crabNetwork.url); | ||
|
||
const backing = await ethers.getContractAt("xTokenBacking", backingNetwork.backing, walletBacking); | ||
|
||
//const tx = await backing.callStatic.lockAndRemoteIssuing( | ||
await backing.lockAndRemoteIssuing( | ||
11155111, | ||
"0x0000000000000000000000000000000000000000", | ||
walletBacking.address, | ||
ethers.utils.parseEther("100"), | ||
1703247763001, | ||
"0x000000000000000000000000000000000000000000000000000000000005f02200000000000000000000000088a39b052d477cfde47600a7c9950a441ce61cb400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", | ||
{ value: ethers.utils.parseEther("105.4") } | ||
); | ||
} | ||
|
||
async function burnAndRemoteUnlock() { | ||
const issuingNetwork = sepoliaNetwork; | ||
const walletIssuing = wallet(sepoliaNetwork.url); | ||
|
||
const issuing = await ethers.getContractAt("xTokenIssuing", issuingNetwork.issuing, walletIssuing); | ||
|
||
const xTokenAddress = "0x4828B88240166B8bB79A833Fd0dD38EaeADAAB1a"; | ||
const xToken = await ethers.getContractAt("xTokenErc20", xTokenAddress, walletIssuing); | ||
await xToken.approve(issuing.address, ethers.utils.parseEther("10000000"), {gasLimit: 500000}); | ||
await issuing.burnAndRemoteUnlock( | ||
xTokenAddress, | ||
walletIssuing.address, | ||
ethers.utils.parseEther("5"), | ||
1703248419043, | ||
"0x000000000000000000000000000000000000000000000000000000000006493c00000000000000000000000088a39b052d477cfde47600a7c9950a441ce61cb400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", | ||
{ | ||
value: ethers.utils.parseEther("0.0000007"), | ||
gasLimit: 1000000, | ||
} | ||
); | ||
} | ||
|
||
async function requestRemoteUnlockForIssuingFailure() { | ||
const issuingNetwork = sepoliaNetwork; | ||
const walletIssuing = wallet(sepoliaNetwork.url); | ||
|
||
const issuing = await ethers.getContractAt("xTokenIssuing", issuingNetwork.issuing, walletIssuing); | ||
|
||
await issuing.requestRemoteUnlockForIssuingFailure( | ||
44, | ||
"0x0000000000000000000000000000000000000000", | ||
walletIssuing.address, | ||
walletIssuing.address, | ||
ethers.utils.parseEther("100"), | ||
1703247763000, | ||
"0x000000000000000000000000000000000000000000000000000000000006493c00000000000000000000000088a39b052d477cfde47600a7c9950a441ce61cb400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", | ||
{ | ||
value: ethers.utils.parseEther("0.0000007"), | ||
gasLimit: 1000000, | ||
} | ||
); | ||
} | ||
|
||
async function requestRemoteIssuingForUnlockFailure() { | ||
const backingNetwork = crabNetwork; | ||
const walletBacking = wallet(crabNetwork.url); | ||
|
||
const backing = await ethers.getContractAt("xTokenBacking", backingNetwork.backing, walletBacking); | ||
|
||
await backing.requestRemoteIssuingForUnlockFailure( | ||
"0xab4f619082b61cac56f60611a661e2b16d8052ab2531be791d95821f8fb232ce", | ||
11155111, | ||
"0x0000000000000000000000000000000000000000", | ||
walletBacking.address, | ||
ethers.utils.parseEther("100"), | ||
"0x000000000000000000000000000000000000000000000000000000000005f02200000000000000000000000088a39b052d477cfde47600a7c9950a441ce61cb400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", | ||
{ value: ethers.utils.parseEther("5.4") } | ||
); | ||
} | ||
|
||
async function main() { | ||
//await registerIssuing(); | ||
//await registerBacking(); | ||
//await lockAndRemoteIssuing(); | ||
//await burnAndRemoteUnlock(); | ||
await requestRemoteUnlockForIssuingFailure(); | ||
//await requestRemoteIssuingForUnlockFailure(); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|