Skip to content

Commit 2e061ce

Browse files
committed
Removing state transition
1 parent e0784d1 commit 2e061ce

1 file changed

Lines changed: 1 addition & 101 deletions

File tree

inspector/scripts/inspect-tbtc.js

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const DepositJson = require("@keep-network/tbtc/artifacts/Deposit.json")
22
const DepositFactoryJson = require("@keep-network/tbtc/artifacts/DepositFactory.json")
3-
const BondedECDSAKeepJson = require("@keep-network/keep-ecdsa/artifacts/BondedECDSAKeep.json")
43

54
const truffleContract = require("@truffle/contract")
65
const contractHelper = require("./lib/contract-helper")
@@ -24,7 +23,7 @@ module.exports = async function() {
2423
}
2524
)
2625

27-
console.log(`Number of created deposits: ${depositCreatedEvents.length}`)
26+
console.log(`Number of created deposits: ${depositCreatedEvents.length} \n`)
2827

2928
const depositAddresses = []
3029
depositCreatedEvents.forEach((event) =>
@@ -61,16 +60,6 @@ module.exports = async function() {
6160
console.log(`lot size [sat]: ${lotSizeSatoshis}`)
6261
console.log(`lot size [tbtc]: ${lotSizeTbtc}`)
6362

64-
if (stateString == "AWAITING_SIGNER_SETUP") {
65-
await retrieveSignerPubkey(deposit)
66-
} else if (stateString == "AWAITING_BTC_FUNDING_PROOF") {
67-
await notifyFundingTimedOut(deposit)
68-
} else if (stateString == "AWAITING_WITHDRAWAL_SIGNATURE") {
69-
await provideRedemptionSignature(deposit, keepAddress)
70-
} else if (stateString == "AWAITING_WITHDRAWAL_PROOF") {
71-
await notifyRedemptionProofTimeout(deposit)
72-
}
73-
7463
console.log(``)
7564
}
7665

@@ -80,92 +69,3 @@ module.exports = async function() {
8069
process.exit()
8170
}
8271
}
83-
84-
async function notifySignerSetupFailed(deposit) {
85-
console.log(`Notifying signer setup failed...`)
86-
try {
87-
const receipt = await deposit.notifySignerSetupFailed()
88-
console.log(`TX: ${receipt.tx}`)
89-
} catch (error) {
90-
console.log(`Failed with: ${JSON.stringify(error)}`)
91-
}
92-
}
93-
94-
async function retrieveSignerPubkey(deposit) {
95-
console.log(`Retrieving signer pubkey...`)
96-
try {
97-
const receipt = await deposit.retrieveSignerPubkey()
98-
console.log(`TX: ${receipt.tx}`)
99-
} catch (error) {
100-
console.log(`Failed with: ${JSON.stringify(error)}`)
101-
}
102-
}
103-
104-
async function notifyFundingTimedOut(deposit) {
105-
console.log(`Notifying funding timeout...`)
106-
try {
107-
const receipt = await deposit.notifyFundingTimedOut()
108-
console.log(`TX: ${receipt.tx}`)
109-
} catch (error) {
110-
console.log(`Failed with: ${JSON.stringify(error)}`)
111-
}
112-
}
113-
114-
async function provideRedemptionSignature(deposit, keepAddress) {
115-
const BondedECDSAKeep = truffleContract(BondedECDSAKeepJson)
116-
BondedECDSAKeep.setProvider(web3.currentProvider)
117-
118-
const keep = await BondedECDSAKeep.at(keepAddress)
119-
120-
console.log(`Looking for the signature from keep ${keepAddress}...`)
121-
122-
console.log(await keep.digest())
123-
const signatureSubmittedEvents = await keep.getPastEvents(
124-
"SignatureSubmitted",
125-
{
126-
fromBlock: factoryDeploymentBlock,
127-
toBlock: "latest",
128-
}
129-
)
130-
131-
const signaturesCount = signatureSubmittedEvents.length
132-
console.log(`Number of signatures submitted: ${signaturesCount}`)
133-
134-
if (signaturesCount == 0) {
135-
// no signatures, nothing to do here
136-
return
137-
}
138-
const lastSignature = signatureSubmittedEvents[signaturesCount - 1]
139-
140-
const {digest, r, s, recoveryID } = lastSignature.returnValues
141-
// A constant in the Ethereum ECDSA signature scheme, used for public key recovery [1]
142-
// Value is inherited from Bitcoin's Electrum wallet [2]
143-
// [1] https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v/38909#38909
144-
// [2] https://github.com/ethereum/EIPs/issues/155#issuecomment-253810938
145-
const ETHEREUM_ECDSA_RECOVERY_V = web3.utils.toBN(27)
146-
const v = web3.utils.toBN(recoveryID).add(ETHEREUM_ECDSA_RECOVERY_V)
147-
148-
console.log(`digest = ${digest}, r = ${r}, s = ${s}, v = ${v}`)
149-
150-
try {
151-
console.log(`Providing redemption signature...`)
152-
const receipt = await deposit.provideRedemptionSignature(
153-
v,
154-
r.toString(),
155-
s.toString()
156-
)
157-
console.log(`TX: ${receipt.tx}`)
158-
} catch (error) {
159-
console.log(`Failed with: ${JSON.stringify(error)}`)
160-
}
161-
}
162-
163-
async function notifyRedemptionProofTimeout(deposit) {
164-
console.log(`Notifying redemption proof timeout...`)
165-
try {
166-
const receipt = await deposit.notifyRedemptionProofTimedOut()
167-
console.log(`TX: ${receipt.tx}`)
168-
} catch (error) {
169-
console.log(`Failed with: ${JSON.stringify(error)}`)
170-
}
171-
}

0 commit comments

Comments
 (0)