Skip to content

Commit

Permalink
Fix consul data fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
kanshi committed Aug 13, 2023
1 parent c91a1fd commit b30347a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion operations/add-scores-stage.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ job "add-scores-stage" {

config {
network_mode = "host"
image = "ghcr.io/ator-development/smart-contracts:0.1.6"
image = "ghcr.io/ator-development/smart-contracts:0.1.7"
entrypoint = ["npx"]
command = "ts-node"
args = ["scripts/distribution/add-scores.ts"]
Expand Down
9 changes: 3 additions & 6 deletions smartweave/scripts/distribution/add-scores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async function main() {

console.log(`Connecting to Consul at ${host}:${port}`)
consul = new Consul({ host, port })

contractTxId = await consul.kv.get({ token: consulToken, key })
const { Value } = await consul.kv.get<{Value: string}>({ token: consulToken, key })
contractTxId = Value
}

if (!contractTxId) {
Expand All @@ -66,15 +66,12 @@ async function main() {
)
} else {
if (consul) {
const accountsData = await consul.kv.get({
const accountsData = await consul.kv.get<{ Value: string }>({
key: process.env.TEST_ACCOUNTS_KEY || 'dummy-path',
token: consulToken
})

console.log(typeof accountsData, accountsData)

if (accountsData) {
//@ts-ignore
const decodedValue = Buffer.from(accountsData.Value, 'base64').toString('utf-8');
const accounts = JSON.parse(decodedValue) as string[];
scores = accounts.map((acct, index, array) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async function main() {
console.log(`Connecting to Consul at ${host}:${port}`)
const consul = new Consul({ host, port })

contractTxId = await consul.kv.get({ token: consulToken, key })
const { Value } = await consul.kv.get<{Value: string}>({ token: consulToken, key })
contractTxId = Value
}

if (!contractTxId) {
Expand Down

0 comments on commit b30347a

Please sign in to comment.