Skip to content

Commit e83bb9f

Browse files
authored
Merge pull request #263 from Dapiguabc/use-new-lamden-js
use lamden-js version and add testnet v2 network
2 parents e42c50d + b907572 commit e83bb9f

33 files changed

+961
-613
lines changed

package-lock.json

+368-184
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lamden-wallet",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"description": "A secure wallet for making transactions on the Lamden blockchain.",
55
"author": "Jeff Scott <[email protected]>",
66
"license": "",
@@ -29,6 +29,7 @@
2929
"test-coin-changepassword": "mocha --timeout 60000 selenium/tests/ui/coin/coin-changepassword.js",
3030
"test-backup-view-accounts": "mocha --timeout 60000 selenium/tests/ui/backup/backup-view-accounts.js",
3131
"test-misc": "mocha --timeout 60000 selenium/tests/ui/misc/*.js",
32+
"test-misc-network": "mocha --timeout 60000 selenium/tests/ui/misc/network.js",
3233
"dev": "node utils/webserver.js"
3334
},
3435
"repository": {
@@ -37,7 +38,7 @@
3738
},
3839
"devDependencies": {
3940
"@babel/runtime": "^7.12.0",
40-
"chromedriver": "^99.0.0",
41+
"chromedriver": "^106.0.1",
4142
"clean-webpack-plugin": "^1.0.0",
4243
"copy-webpack-plugin": "^10.2.4",
4344
"css-loader": "2.1.0",
@@ -60,12 +61,13 @@
6061
"dependencies": {
6162
"easyqrcodejs": "^4.4.6",
6263
"faunadb": "^4.5.2",
63-
"lamden-js": "^3.6.0",
64+
"lamden-js": "^3.8.0",
6465
"monaco-editor": "^0.19.0",
6566
"monaco-editor-webpack-plugin": "^1.8.1",
6667
"node-cryptojs-aes": "^0.4.0",
6768
"socket.io-client": "^4.2.0",
6869
"svelte-flatpickr": "^2.4.0",
69-
"types-validate-assert": "^1.0.1"
70+
"types-validate-assert": "^1.0.1",
71+
"url-parse": "^1.5.10"
7072
}
7173
}

selenium/config/chrome_config.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"backup": "mcmjfpfhmepgncgcefnfnlbhplckagnf",
23
"walletExtentionID": "milbhnchmaidmgioekemioacdgkojndh"
34
}

selenium/tests/dapp/content_lamdenWalletSendTx.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ describe("Content Script - Testing Dapp SendTx API", function () {
273273
transaction.uid = helpers.createUID()
274274
await helpers.sendTx(driver, transaction, false);
275275
await helpers.approveApprovalPopup(driver, 2, 1);
276-
await helpers.getTxResult(driver, transaction.uid );
277-
await helpers.sleep(50000);
276+
await helpers.sleep(40000);
278277
let afterApprovalAmount = await helpers.getApprovalAmount(
279278
connectionInfo.wallets[0],
280279
dappsInfo.approvalTransaction.kwargs.to

selenium/tests/ui/misc/fiat.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ describe('Testing Manage Network', function () {
2828
context('Testing fiat stuff: Can change currency', function() {
2929
it('Renders ManageNetworkMain.svelte', async function() {
3030
await driver.findElement(By.id('nav-fiat-currently-selected')).click()
31-
await helpers.sleep(500)
32-
await driver.findElement(By.id("select-option-3")).click()
31+
await helpers.sleep(1000)
32+
await driver.findElement(By.css(".fiat-dropdown #select-option-3")).click()
3333
await helpers.sleep(500)
3434
let val = await driver.findElement(By.css(".fiatvalue")).getText()
3535
assert.ok(val.startsWith("€"))

selenium/tests/ui/misc/network.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ describe('Testing Manage Network', function () {
6464
// switch to add network
6565
await driver.findElement(By.id('undefined-currently-selected')).click()
6666
await helpers.sleep(500)
67-
await driver.findElement(By.id("select-option-3")).click()
67+
await driver.findElement(By.id("select-option-4")).click()
6868
});
6969
it('Form Valid - Rejects empyty network name', async function() {
70+
await helpers.sleep(500)
7071
await driver.findElement(By.id("save")).click()
7172
let name = await driver.findElement(By.id("name"))
7273
let msg = await name.getAttribute('validationMessage')
@@ -117,7 +118,7 @@ describe('Testing Manage Network', function () {
117118
await helpers.fillNetworkForm(driver, badNetwork);
118119
await helpers.sleep(1000);
119120
await driver.findElement(By.id("save")).click()
120-
await helpers.sleep(5000);
121+
await helpers.sleep(30000);
121122
let msg = await driver.findElement(By.id("hostlist")).getAttribute('validationMessage')
122123
assert.equal(msg, 'Cannot contact network')
123124
})
@@ -139,7 +140,7 @@ describe('Testing Manage Network', function () {
139140
await helpers.sleep(500)
140141
await driver.findElement(By.id('undefined-currently-selected')).click()
141142
await helpers.sleep(500)
142-
await driver.findElement(By.id("select-option-3")).click()
143+
await driver.findElement(By.id("select-option-4")).click()
143144
await helpers.clearNetwork(driver);
144145
await helpers.fillNetworkForm(driver, editNetwork);
145146
await helpers.sleep(1000);
@@ -153,7 +154,7 @@ describe('Testing Manage Network', function () {
153154
await helpers.sleep(3000)
154155

155156
// valid result
156-
let networkname = await driver.findElement(By.css("#nav-network option:nth-child(3)")).getAttribute('innerText')
157+
let networkname = await driver.findElement(By.css("#nav-network option:nth-child(4)")).getAttribute('innerText')
157158
assert.equal(networkname, editNetwork.name)
158159
})
159160
})

selenium/tests/ui/tokens/tokens-edit.js

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('Testing Token Integration - Edit Token Info', function () {
6262
});
6363

6464
it('Will save token symbol if changed', async function() {
65+
await helpers.sleep(100)
6566
await tokenHelpers.gotoTokenDetails(driver, frostyToken)
6667
await tokenHelpers.gotoTokenOptions(driver)
6768
await tokenHelpers.validateTokenSymbol(driver, frostyToken)

selenium/tests/ui/tokens/tokens-transactions.js

+12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const whitelabel = require('../../../../whitelabel.json')
5555
it('Fills in the appropriate Transaction details for My Account of Simple Transaction UI', async function() {
5656
let token = tokenInfo.token_1_svg
5757
await helpers.sleep(500)
58+
let element = driver.findElement(By.className('wrap-second'))
59+
await driver.executeScript("arguments[0].click();", element)
60+
await helpers.sleep(500)
5861
await tokenHelpers.gotoTokenDetails(driver, token)
5962
await driver.wait(until.elementLocated(By.id('transfer-token-btn')), 5000).click();
6063
await helpers.sleep(500);
@@ -67,6 +70,9 @@ const whitelabel = require('../../../../whitelabel.json')
6770
it('Fills in the appropriate Transaction details for Advanced Transaction UI', async function() {
6871
let token = tokenInfo.token_1_svg
6972
await helpers.sleep(500)
73+
await helpers.sleep(500)
74+
let element = driver.findElement(By.className('wrap-second'))
75+
await driver.executeScript("arguments[0].click();", element)
7076
await tokenHelpers.gotoTokenDetails(driver, token)
7177
await driver.wait(until.elementLocated(By.id('transfer-token-btn')), 5000).click();
7278
await helpers.sleep(500);
@@ -80,6 +86,8 @@ const whitelabel = require('../../../../whitelabel.json')
8086
const to = 'xxxxxx'
8187
let token = tokenInfo.token_1_svg
8288
await helpers.sleep(500)
89+
let element = driver.findElement(By.className('wrap-second'))
90+
await driver.executeScript("arguments[0].click();", element)
8391
await tokenHelpers.gotoTokenDetails(driver, token)
8492
await driver.wait(until.elementLocated(By.id('transfer-token-btn')), 5000).click();
8593
await helpers.sleep(4000);
@@ -95,6 +103,8 @@ const whitelabel = require('../../../../whitelabel.json')
95103
const to = 'xxxxxx'
96104
let token = tokenInfo.token_1_svg
97105
await helpers.sleep(500)
106+
let element = driver.findElement(By.className('wrap-second'))
107+
await driver.executeScript("arguments[0].click();", element)
98108
await tokenHelpers.gotoTokenDetails(driver, token)
99109
await driver.wait(until.elementLocated(By.id('transfer-token-btn')), 5000).click();
100110
await driver.wait(until.elementLocated(By.id('advanced')), 5000).click();
@@ -113,6 +123,8 @@ const whitelabel = require('../../../../whitelabel.json')
113123
it('Can send an approve transaction', async function() {
114124
let token = tokenInfo.token_1_svg
115125
await helpers.sleep(500)
126+
let element = driver.findElement(By.className('wrap-second'))
127+
await driver.executeScript("arguments[0].click();", element)
116128
await tokenHelpers.gotoTokenDetails(driver, token)
117129
await driver.wait(until.elementLocated(By.id('approve-token-btn')), 5000).click();
118130
await tokenHelpers.validateTransacationFormDetails(driver, token, 'approve')

src/js/backgroundControllers/accountsController.js

-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ export const accountsController = (utils, services) => {
348348
const signTx = (txBuilder) => {
349349
let account = getAccountByVK(txBuilder.sender)
350350
if (!account) throw new Error(`Error: Account address ${xBuilder.sender} not in Lamden Vault.`)
351-
console.log("here")
352351
// let sk = decryptString(account.sk)
353352
// console.log(sk)
354353
txBuilder.sign(decryptString(account.sk))

src/js/backgroundControllers/balancesController.js

+36-22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { addConsoleHandler } from "selenium-webdriver/lib/logging";
2-
31
export const balancesController = (utils, services, actions) => {
42
let balancesStore = {};
53
let updatingBalances = {status: "waiting", time: new Date()};
64

7-
chrome.runtime.onSuspend.addListener(removeSocketListeners)
8-
chrome.runtime.onSuspendCanceled.addListener(addSocketListeners)
9-
addSocketListeners()
5+
//chrome.runtime.onSuspend.addListener(removeSocketListeners)
6+
//chrome.runtime.onSuspendCanceled.addListener(addSocketListeners)
7+
//addSocketListeners()
8+
9+
document.addEventListener('BlockServiceConnected', (e) => {
10+
addSocketListeners()
11+
})
1012

1113
chrome.storage.local.get({"balances":{}},function(getValue) {balancesStore = getValue.balances;})
1214
chrome.storage.onChanged.addListener(function(changes) {
@@ -16,20 +18,17 @@ export const balancesController = (utils, services, actions) => {
1618
}
1719
}
1820
});
19-
21+
2022
chrome.runtime.onInstalled.addListener(function(details) {
2123
if (details.reason === "update") clearAllNetworks()
2224
});
2325

2426
function addSocketListeners() {
25-
services.socketService.testnet_socket_on('new-state-changes-one', (update) => processBalanceSocketUpdate(update, 'testnet'))
26-
services.socketService.mainnet_socket_on('new-state-changes-one', (update) => processBalanceSocketUpdate(update, 'mainnet'))
27-
if (!actions.walletIsLocked()) joinAllSockets()
27+
services.socketService.socket_on('new-state-changes-one', (update) => processBalanceSocketUpdate(update))
2828
}
2929

3030
function removeSocketListeners() {
31-
services.socketService.testnet_socket_off('new-state-changes-one')
32-
services.socketService.mainnet_socket_off('new-state-changes-one')
31+
services.socketService.socket_off('new-state-changes-one')
3332
leaveAllSockets()
3433
}
3534

@@ -78,14 +77,29 @@ export const balancesController = (utils, services, actions) => {
7877
key: account.vk
7978
}
8079
})
81-
network.blockservice.getCurrentKeysValues(keysToGet).then(balances => {
82-
if (balances.length > 0){
83-
let newBalances = processBalances(balances, accountsList)
84-
let netKey = network.networkKey
85-
balancesStore[netKey] = newBalances
86-
setStore(balancesStore)
87-
}
88-
})
80+
if (network.blockservice.host) {
81+
network.blockservice.getCurrentKeysValues(keysToGet).then(balances => {
82+
if (balances.length > 0){
83+
let newBalances = processBalances(balances, accountsList)
84+
let netKey = network.networkKey
85+
balancesStore[netKey] = newBalances
86+
setStore(balancesStore)
87+
}
88+
})
89+
} else {
90+
let res = keysToGet.map(item => network.getVariable('currency', 'balances', item.key).then(res => {
91+
res.key = item.key
92+
return res
93+
}))
94+
Promise.all(res).then(balances => {
95+
if (balances.length > 0){
96+
let newBalances = processBalances(balances, accountsList)
97+
let netKey = network.networkKey
98+
balancesStore[netKey] = newBalances
99+
setStore(balancesStore)
100+
}
101+
})
102+
}
89103
}
90104

91105
const processBalance = (balance, account) => {
@@ -106,7 +120,7 @@ export const balancesController = (utils, services, actions) => {
106120
return newBalancesObj;
107121
}
108122

109-
const processBalanceSocketUpdate = (update, networkType) => {
123+
const processBalanceSocketUpdate = (update) => {
110124
if (actions.walletIsLocked()) return
111125
if (!update) return
112126

@@ -122,7 +136,7 @@ export const balancesController = (utils, services, actions) => {
122136
if (room !== `currency.balances:${key}`) return
123137

124138
try{
125-
let network = utils.networks.getLamdenNetwork(networkType)
139+
let network = utils.networks.getCurrent()
126140
let netKey = network.networkKey
127141

128142
let newValue = utils.getValueFromReturn(value)
@@ -143,7 +157,7 @@ export const balancesController = (utils, services, actions) => {
143157

144158
const getUpdate = async (account, network) => {
145159
let vk = account.vk
146-
let balance = await network.blockservice.getCurrentKeyValue('currency', 'balances', vk)
160+
let balance = await network.getVariable('currency', 'balances', vk)
147161
.then(res => {
148162
if (!res) return {value : "0"}
149163
if (res.notFound) return {value : "0"}

0 commit comments

Comments
 (0)