Skip to content

Commit

Permalink
Fix prices data feed (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb authored Jan 31, 2024
1 parent 0636da8 commit 2238061
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 256 deletions.
2 changes: 1 addition & 1 deletion apps/authz/src/app/persistence/repository/mock_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const TREASURY_WALLET_X: Wallet = {
uid: 'eip155:eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b', // Prod guild 58 - treasury wallet
address: '0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b',
accountType: AccountType.EOA,
assignees: ['matt@narval.xyz']
assignees: [MATT.uid]
}

// Wallet Groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ test_destination {
checkDestinationClassification({"internal"}) with input as request
with data.entities as entities
}

test_wildcardDestination {
checkDestinationAddress(wildcard)
checkDestinationClassification(wildcard)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,3 @@ test_source {
checkSourceClassification({"wallet"}) with input as request
with data.entities as entities
}

test_wildcardSource {
checkSourceAccountType(wildcard)
checkSourceAddress(wildcard)
checkSourceClassification(wildcard)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_transferNative {
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"type": "transferNative",
"amount": "1000000000000000000",
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
},
}

Expand All @@ -21,7 +21,7 @@ test_transferNative {
checkDestinationAddress({"eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3"}) with input as nativeRequest
with data.entities as entities

checkIntentTokenAddress({"eip155:137/slip44/966"}) with input as nativeRequest
checkIntentTokenAddress({"eip155:137/slip44:966"}) with input as nativeRequest
with data.entities as entities

checkIntentAmount({"currency": wildcard, "operator": "lte", "value": "1000000000000000000"}) with input as nativeRequest
Expand Down
6 changes: 0 additions & 6 deletions apps/authz/src/opa/rego/__test__/criteria/principal_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,3 @@ test_principal {
checkPrincipalGroups({"test-user-group-one-uid"}) with input as request
with data.entities as entities
}

test_wildcardPrincipal {
checkPrincipalId(wildcard)
checkPrincipalRole(wildcard)
checkPrincipalGroups(wildcard)
}
7 changes: 0 additions & 7 deletions apps/authz/src/opa/rego/__test__/criteria/resource_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,3 @@ test_resource {
checkWalletAssignees({"test-bob-uid"}) with input as request
with data.entities as entities
}

test_wildcardResource {
checkWalletId(wildcard)
checkWalletGroups(wildcard)
checkWalletChainId(wildcard)
checkWalletAssignees(wildcard)
}
6 changes: 3 additions & 3 deletions apps/authz/src/opa/rego/__test__/main_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ transfersReq = [
},
]

pricesReq = {
pricesReq = {"eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
}
}}

request = {
"action": "signTransaction",
Expand All @@ -110,7 +110,7 @@ entities = {
},
"test-bar-uid": {
"uid": "test-bar-uid",
"role": "member",
"role": "admin",
},
"test-foo-uid": {
"uid": "test-foo-uid",
Expand Down
88 changes: 6 additions & 82 deletions apps/authz/src/opa/rego/__test__/policies/approvals_test.rego
Original file line number Diff line number Diff line change
@@ -1,87 +1,11 @@
package main

approvalReq = {
"action": "signTransaction",
"transactionRequest": {
"from": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"to": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chainId": 137,
"maxFeePerGas": "20000000000",
"maxPriorityFeePerGas": "3000000000",
"gas": "21000",
"value": "0xde0b6b3a7640000",
"data": "0x00000000",
"nonce": 192,
"type": "2",
},
"principal": {"userId": "test-alice-uid"},
"resource": {"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"},
"intent": {
"type": "transferERC20",
"from": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"contract": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
"amount": "1000000000000000000",
},
}

approvalEntities = {
"users": {
"test-bob-uid": {
"uid": "test-bob-uid",
"role": "root",
},
"test-alice-uid": {
"uid": "test-alice-uid",
"role": "member",
},
"test-bar-uid": {
"uid": "test-bar-uid",
"role": "admin",
},
"test-foo-uid": {
"uid": "test-foo-uid",
"role": "admin",
},
"0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43": {
"uid": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43",
"role": "admin",
},
},
"wallets": {
"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bob-uid", "test-alice-uid", "test-bar-uid"],
},
"eip155:eoa:0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e": {
"uid": "eip155:eoa:0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bar-uid"],
},
},
"userGroups": {
"test-user-group-one-uid": {
"uid": "test-user-group-one-uid",
"name": "dev",
"users": ["test-bob-uid", "test-bar-uid"],
},
"test-user-group-two-uid": {
"uid": "test-user-group-two-uid",
"name": "finance",
"users": ["test-bob-uid", "test-bar-uid"],
},
},
}

test_approvalByUsers {
approvalByUsersReq = object.union(approvalReq, {"approvals": [
approvalByUsersReq = object.union(request, {"principal": {"userId": "test-alice-uid"}, "approvals": [
{"userId": "test-bob-uid"},
{"userId": "test-bar-uid"},
]})
res = permit[{"policyId": "approvalByUsers"}] with input as approvalByUsersReq with data.entities as approvalEntities
res = permit[{"policyId": "approvalByUsers"}] with input as approvalByUsersReq with data.entities as entities

res == {
"approvalsMissing": [],
Expand All @@ -97,12 +21,12 @@ test_approvalByUsers {
}

test_approvalByUserGroups {
approvalByUserGroupsReq = object.union(approvalReq, {"approvals": [
approvalByUserGroupsReq = object.union(request, {"principal": {"userId": "test-alice-uid"}, "approvals": [
{"userId": "test-bob-uid"},
{"userId": "test-bar-uid"},
]})

res = permit[{"policyId": "approvalByUserGroups"}] with input as approvalByUserGroupsReq with data.entities as approvalEntities
res = permit[{"policyId": "approvalByUserGroups"}] with input as approvalByUserGroupsReq with data.entities as entities

res == {
"approvalsMissing": [],
Expand All @@ -118,12 +42,12 @@ test_approvalByUserGroups {
}

test_approvalByUserRoles {
approvalByUserRolesReq = object.union(approvalReq, {"approvals": [
approvalByUserRolesReq = object.union(request, {"principal": {"userId": "test-alice-uid"}, "approvals": [
{"userId": "test-bar-uid"},
{"userId": "test-foo-uid"},
]})

res = permit[{"policyId": "approvalByUserRoles"}] with input as approvalByUserRolesReq with data.entities as approvalEntities
res = permit[{"policyId": "approvalByUserRoles"}] with input as approvalByUserRolesReq with data.entities as entities

res == {
"approvalsMissing": [],
Expand Down
14 changes: 7 additions & 7 deletions apps/authz/src/opa/rego/__test__/policies/e2e_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ e2e_req = {
"from": "eip155:137:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
"type": "transferNative",
"amount": "1000000000000000000",
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
},
"transactionRequest": {
"from": "0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
Expand Down Expand Up @@ -54,7 +54,7 @@ e2e_req = {
"from": "eip155:137:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
"to": "eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4",
"chainId": 137,
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
"rates": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
Expand All @@ -67,7 +67,7 @@ e2e_req = {
"from": "eip155:137:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
"to": "eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4",
"chainId": 137,
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
"rates": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
Expand All @@ -80,7 +80,7 @@ e2e_req = {
"from": "eip155:137:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
"to": "eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4",
"chainId": 137,
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
"rates": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
Expand All @@ -93,7 +93,7 @@ e2e_req = {
"from": "eip155:137:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b",
"to": "eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4",
"chainId": 137,
"token": "eip155:137/slip44/966",
"token": "eip155:137/slip44:966",
"rates": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
Expand All @@ -102,10 +102,10 @@ e2e_req = {
"timestamp": tenHoursAgo,
},
],
"prices": {
"prices": {"eip155:137/slip44:966": {
"fiat:usd": "0.99",
"fiat:eur": "1.10",
},
}},
}

e2e_entities = {
Expand Down
Loading

0 comments on commit 2238061

Please sign in to comment.