Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 16, 2024
1 parent 784024f commit efbfc10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions apps/authz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ authz/rego/build:
authz/rego/eval:
npx ts-node \
--compiler-options "{\"module\":\"CommonJS\"}" \
${AUTHZ_PROJECT_DIR}/src/opa/template/evaluation.script.ts
${AUTHZ_PROJECT_DIR}/src/opa/script/evaluation.script.ts

authz/rego/translate:
npx dotenv -e ${AUTHZ_PROJECT_DIR}/.env -- \
ts-node -r tsconfig-paths/register \
--project ${AUTHZ_PROJECT_DIR}/tsconfig.app.json ${AUTHZ_PROJECT_DIR}/src/opa/template/translate-legacy-policy.script.ts
--project ${AUTHZ_PROJECT_DIR}/tsconfig.app.json ${AUTHZ_PROJECT_DIR}/src/opa/script/translate-legacy-policy.script.ts


authz/rego/test:
Expand Down
24 changes: 12 additions & 12 deletions apps/authz/src/opa/script/translate-legacy-policy.script.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EntityType, FiatCurrency, UserRole, ValueOperators } from '@narval/authz-shared'
import axios from 'axios'
import { omit } from 'lodash'
import { Address, Hex } from 'viem'
import {
ApprovalCondition,
Expand Down Expand Up @@ -307,10 +306,10 @@ const translateLegacyPolicy = (oldPolicy: OldPolicy): NewPolicy | null => {
return res
}

const sendTranslatingRequest = async (data: { policies: OldPolicy[] }) => {
export const sendTranslatingRequest = async (policies: OldPolicy[]) => {
try {
console.log(data.policies.length)

console.log(`Number of policies to translate: ${policies.length}.`)
console.log('Translation in progress...')
const res = await axios.post('http://localhost:3010/admin/policies', {

Check failure on line 313 in apps/authz/src/opa/script/translate-legacy-policy.script.ts

View workflow job for this annotation

GitHub Actions / Build and test

'res' is assigned a value but never used
authentication: {
sig: '0x746ed2e4bf7311da76bc157c7fe8c0520b6e4c27ab96abf5a8d16fecbaac98b669418b2db9da8e6d3cbd4e1eaff1a9d9e765f0470e9b86c6694145778a8d46f81c',
Expand All @@ -332,18 +331,19 @@ const sendTranslatingRequest = async (data: { policies: OldPolicy[] }) => {
request: {
action: 'setPolicyRules',
nonce: 'random-nonce-111',
data: data.policies.map((policy) => {
const copy: OldPolicy = omit(policy, ['guild_id', 'sequence', 'version', 'amount'])
copy.amount = policy.amount !== null ? `${policy.amount}` : null
return translateLegacyPolicy(copy)
})
data: policies.map(translateLegacyPolicy)
}
})

console.log(res.data)
console.log('Translation completed!')
} catch (err) {
console.error(err.response.data)
}
}

sendTranslatingRequest({ policies: [] as OldPolicy[] })
// sendTranslatingRequest(
// data.policies.map((policy) => {
// const copy: OldPolicy = omit(policy, ['guild_id', 'sequence', 'version', 'amount'])
// copy.amount = policy.amount !== null ? `${policy.amount}` : null
// return copy
// })
// )

0 comments on commit efbfc10

Please sign in to comment.