Skip to content

Commit

Permalink
fix: fix create demo wallet script
Browse files Browse the repository at this point in the history
  • Loading branch information
ZavenArra committed Feb 19, 2021
1 parent cc7a45b commit 3601917
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions scripts/demo/create-demo-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ function getRandomArbitrary(min, max) {
// create wallet and password, salt

const result = await trx('wallets.wallet').insert({
type: 'p',
name: username,
password: passwordHash,
salt: salt
}).returning('*')
const entity = result[0]
console.log(entity)
const wallet = result[0]
console.log(wallet)


// insert fake planters
Expand Down Expand Up @@ -82,7 +81,7 @@ function getRandomArbitrary(min, max) {

// insert fake tree captures
let trees = []
for(i=0; i<1000; i++){
for(i=0; i<10; i++){
const captureData = {
time_created: new Date(),
time_updated: new Date(),
Expand All @@ -95,20 +94,20 @@ function getRandomArbitrary(min, max) {
}
const result3 = await trx('public.trees').insert(captureData).returning('*')
const capture = result3[0]
trees.push(capture.id)
console.log(capture.id)
trees.push(capture.uuid)
console.log(capture.uuid)
await trx.raw('UPDATE trees SET estimated_geometric_location = ST_SetSRID(ST_MakePoint(lon, lat), 4326) WHERE id = ?', capture.id)
}

// create fake tokens
for ( const treeId of trees ){
const tokenData = {
tree_id: treeId,
entity_id: entity.id
capture_id: treeId,
wallet_id: wallet.id
}
const result4 = await trx('wallets.token').insert(tokenData).returning('*')
const token = result4[0]
console.log(token.uuid)
console.log(token.id)
}

await trx.commit();
Expand Down

0 comments on commit 3601917

Please sign in to comment.