-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: cache / expire uAgent almanac resolutions #198
base: main
Are you sure you want to change the base?
Conversation
8e55180
to
cbf7aa7
Compare
eb6f2b9
to
e3302c5
Compare
25b5859
to
c1d3ff4
Compare
a9f50b3
to
db9d439
Compare
db9d439
to
7f90135
Compare
f0a6a10
to
9f1d4b5
Compare
(cherry picked from commit 1885f718eaf5d66a4d91db01be74f4d8d00b9c0f)
9f1d4b5
to
6dbb344
Compare
@@ -4,7 +4,7 @@ import {createHash} from "crypto"; | |||
import {Attribute} from "@cosmjs/stargate/build/logs"; | |||
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge"; | |||
import {CW20Structure} from "./wasm/contracts/cw20"; | |||
import {Structure} from "./wasm/contracts/types"; | |||
import {BaseStructure} from "./wasm/contracts/base"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should've been in d7c166f, my bad.
@@ -31,7 +31,7 @@ export async function checkBalancesAccount(address: string, chainId: string) { | |||
} | |||
|
|||
export function getJaccardResult(payload: object): Interface { | |||
let prediction = Structure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output | |||
let prediction = BaseStructure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same ^
@@ -29,7 +33,8 @@ export async function checkBalancesAccount(address: string, chainId: string) { | |||
export function getJaccardResult(payload: object): Interface { | |||
let prediction = Structure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output | |||
let diff = 0, match = 0, coefficient = 0; // where coefficient of 1 is a perfect property key match, 2 is a perfect match of property and type | |||
const structs = [CW20Structure, LegacyBridgeSwapStructure]; | |||
// TODO: refactor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more maintainable if we redesigned this a little bit. Perhaps we can add a contract structure registry which this function iterates over (as opposed to a hard-coded list of known structures). Each structure would import the registry and register itself. I suspect that the index (i.e. src/mappings/wasm/contracts) would have to be required (import value ignored) just so that they are included in the build tree (and their registration calls get run, subsequently). Effort may need to be taken to avoid circular dependencies when building and bootstrapping the registry. I think so long as the contract structure index isn't in the same module as the registry we should be good. I would imagine a good place for this import would be in the src/mappings/mappingHandler.ts file instead.
@@ -116,60 +121,6 @@ export async function trackUnprocessed(error: Error, primitives: Primitives): Pr | |||
} | |||
} | |||
|
|||
class Structure { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was supposed to be in d7c166f
@@ -2,6 +2,10 @@ import {CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction} from "@subql | |||
import {Account, Interface, UnprocessedEntity} from "../types"; | |||
import {createHash} from "crypto"; | |||
import {Attribute} from "@cosmjs/stargate/build/logs"; | |||
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge"; | |||
import {CW20Structure} from "./wasm/contracts/cw20"; | |||
import {Structure} from "./wasm/contracts/types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we actually need this import.
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge"; | ||
import {CW20Structure} from "./wasm/contracts/cw20"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was supposed to be in d7c166f
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge"; | ||
import {CW20Structure} from "./wasm/contracts/cw20"; | ||
import {Structure} from "./wasm/contracts/types"; | ||
import {MicroAgentAlmanacStructure} from "./wasm/contracts/almanac"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was supposed to be in d7c166f
Changes
Code Review Checklist (to be filled out by reviewer)