Skip to content

Commit 448a940

Browse files
Fixing spacing discrepancies
Signed-off-by: Dhinakaran Vinayagamurthy <[email protected]>
1 parent d46ad7b commit 448a940

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

core/network/besu/contracts/interop/manageAsset.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ contract InteroperationBaseClassERC20 {
159159
return true;
160160
}
161161

162+
162163
// Function to check if there is an active contract with the input lockContractId.
163164
function isFungibleAssetLocked(bytes32 lockContractId)
164165
external

samples/besu/simpleasset/app/AssetExchangeERC20.js

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ let BobERC20
2626
// (Assuming that the current folder is a sibling folder to build,
2727
// the path to json would be ../build/contracts/ContractName.json)
2828
async function getContractInstance(provider, pathToJson){
29-
3029
const jsonFile = path.resolve(__dirname, pathToJson)
3130
var jsonFileContents = fs.readFileSync(jsonFile)
3231
var contractName = contract(JSON.parse(jsonFileContents))
@@ -41,15 +40,13 @@ async function getContractInstance(provider, pathToJson){
4140

4241
// Initialization of the parameters
4342
async function init(provider1, provider2, contractOwner1, contractOwner2, Alice1, Bob2, tokenSupply, senderInitialBalance) {
44-
4543
interopContract1 = await getContractInstance(provider1,'../build/contracts/InteroperationBaseClassERC20.json').catch(function () {
4644
console.log("Failed getting interopContract1!");
4745
})
4846
interopContract2 = await getContractInstance(provider2,'../build/contracts/InteroperationBaseClassERC20.json').catch(function () {
4947
console.log("Failed getting interopContract2!");
5048
})
5149

52-
5350
AliceERC20 = await getContractInstance(provider1, '../build/contracts/AliceERC20.json').catch(function () {
5451
console.log("Failed getting AliceERC20 token contract!");
5552
})
@@ -58,10 +55,10 @@ async function init(provider1, provider2, contractOwner1, contractOwner2, Alice1
5855
})
5956

6057
// Issue AliceERC20 tokens to Alice in Network 1 and BobERC20 tokens
61-
// to Bob in Network 2. A minimal number of tokens equal to the
62-
// number of token being exchanged is issued to Alice and Bob to
63-
// ensure that the exchange in this test application does not fail
64-
// due to insufficient funds.
58+
// to Bob in Network 2. A minimal number of tokens equal to the
59+
// number of token being exchanged is issued to Alice and Bob to
60+
// ensure that the exchange in this test application does not fail
61+
// due to insufficient funds.
6562
await AliceERC20.transfer(Alice1, senderInitialBalance, {from: contractOwner1}).catch(function () {
6663
console.log("AliceERC20 transfer threw an error; Probably the token supply is used up!");
6764
})
@@ -90,7 +87,6 @@ async function claimToken(interopContract, lockContractId, recipient, preimage)
9087

9188
// Unlock function of a locked fungible asset/token
9289
async function unlockToken(interopContract, lockContractId, sender) {
93-
9490
var unlockStatus = await interopContract.unlockFungibleAsset(lockContractId, {
9591
from: sender
9692
}).catch(function () {
@@ -107,7 +103,6 @@ async function unlockToken(interopContract, lockContractId, sender) {
107103
// for 'recipient' using the contract constructs of 'interopContract'
108104
// with hashLock and timeLock providing the conditions for claiming/unlocking
109105
async function lockToken(sender, recipient, tokenContract, tokenAmount, interopContract, hashLock, timeLock) {
110-
111106
// initiator of the swap has to first designate the swap contract as a spender of his/her money
112107
// with allowance matching the swap amount
113108
await tokenContract.approve(interopContract.address, tokenAmount, {from: sender}).catch(function () {
@@ -124,7 +119,7 @@ async function lockToken(sender, recipient, tokenContract, tokenAmount, interopC
124119
{
125120
from: sender
126121
}
127-
).catch(function () {
122+
).catch(function () {
128123
console.log("lockFungibleAsset threw an error");
129124
lockStatus = false
130125
})
@@ -138,7 +133,6 @@ async function lockToken(sender, recipient, tokenContract, tokenAmount, interopC
138133
// Designed for printing the account balances of the sender and
139134
// recipient at various stages of the exchange.
140135
async function getBalances(Alice1, Bob1, Alice2, Bob2) {
141-
142136
var AliceAliceERC20Balance = await AliceERC20.balanceOf(Alice1)
143137
console.log("Alice balance of AliceERC20 in Network 1", AliceAliceERC20Balance.toString())
144138

@@ -150,13 +144,11 @@ async function getBalances(Alice1, Bob1, Alice2, Bob2) {
150144

151145
var BobBobERC20Balance = await BobERC20.balanceOf(Bob2)
152146
console.log("Bob balance of BobERC20 in Network 2", await BobBobERC20Balance.toString())
153-
154147
}
155148

156149

157150
// Main entry point to the app
158151
async function main() {
159-
160152
// Network 1
161153
const provider1 = new Web3.providers.HttpProvider('http://'+networkHost1+':'+networkPort1)
162154
const web3N1 = new Web3(provider1)
@@ -169,7 +161,6 @@ async function main() {
169161

170162
const contractOwner1 = accounts1[0] // owner of all the minted tokens when the contract was created, given how truffleconfig.js is composed
171163

172-
173164
// Network 2
174165
const provider2 = new Web3.providers.HttpProvider('http://'+networkHost2+':'+networkPort2)
175166
const web3N2 = new Web3(provider2)
@@ -197,32 +188,32 @@ async function main() {
197188
console.log("Hash: ", hash)
198189

199190
let timeOut = 15
200-
let timeLockSeconds = Math.floor(Date.now() / 1000) + 2*timeOut
191+
let timeLockSeconds = Math.floor(Date.now() / 1000) + 2*timeOut
201192

202193
// Creating a HTLC contract for Alice locking her AliceERC20 tokens for Bob
203194
let lockTx1 = await lockToken(Alice1, Bob1, AliceERC20, tokenAmount, interopContract1, hash, timeLockSeconds)
204-
if (!lockTx1) {
205-
console.log("\n !!! Locking of Alice's tokens failed in Netowrk 1. Aborting here !!!")
206-
return
207-
}
195+
if (!lockTx1) {
196+
console.log("\n !!! Locking of Alice's tokens failed in Netowrk 1. Aborting here !!!")
197+
return
198+
}
208199
let lockContractId1 = lockTx1.logs[0].args.lockContractId
209200
console.log("lockContractID1: ", lockContractId1)
210201

211202
console.log("\n Balances after Alice locks her tokens in Network 1:")
212203
await getBalances(Alice1, Bob1, Alice2, Bob2)
213204

214205
// After he observes this lockContract created in Network 1,
215-
// Bob creates a similar contract in Network 2 using the same
216-
// hash to transfer the agreed upon amount of BobERC20 to Alice.
206+
// Bob creates a similar contract in Network 2 using the same
207+
// hash to transfer the agreed upon amount of BobERC20 to Alice.
217208
// Bob sets the timeLock such that he will have enough time to
218-
// claim Alice's tokens in Network 1 after she claims Bob's
219-
// tokens in Network 2.
209+
// claim Alice's tokens in Network 1 after she claims Bob's
210+
// tokens in Network 2.
220211
timeLockSeconds = Math.floor(Date.now() / 1000) + timeOut
221212
let lockTx2 = await lockToken(Bob2, Alice2, BobERC20, tokenAmount, interopContract2, hash, timeLockSeconds)
222-
if (!lockTx2) {
223-
console.log("\n !!! Locking of Bob's tokens failed in Netowrk 2. Aborting here !!!")
224-
return
225-
}
213+
if (!lockTx2) {
214+
console.log("\n !!! Locking of Bob's tokens failed in Netowrk 2. Aborting here !!!")
215+
return
216+
}
226217
let lockContractId2 = lockTx2.logs[0].args.lockContractId
227218
console.log("lockContractID2: ", lockContractId2)
228219

0 commit comments

Comments
 (0)