-
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?
Changes from 1 commit
6881e43
0ca271e
4947ffe
d7c166f
6acea51
3a7725f
2cb3e63
b5d3dfa
1f59d61
5872e80
fcbc6bb
e8347c4
8cf590f
feef99a
422e89a
6dbb344
b357a9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,7 @@ enum Interface { | |
Uncertain, | ||
CW20, | ||
LegacyBridgeSwap, | ||
MicroAgentAlmanac, | ||
} | ||
|
||
enum AccessType { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
import {MicroAgentAlmanacStructure} from "./wasm/contracts/almanac"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was supposed to be in d7c166f |
||
|
||
export type Primitive = CosmosEvent | CosmosMessage | CosmosTransaction | CosmosBlock; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. same ^ |
||
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 | ||
// TODO: refactor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
const structs = [CW20Structure, LegacyBridgeSwapStructure, MicroAgentAlmanacStructure]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {BaseStructure} from "./base"; | ||
import {Interface} from "../../../types"; | ||
|
||
export class MicroAgentAlmanacStructure extends BaseStructure { | ||
private stake_denom = ""; | ||
private expiry_height = 0; | ||
private register_stake_amount = "0"; | ||
private admin = ""; | ||
|
||
static listProperties() { | ||
return Object.getOwnPropertyNames(new MicroAgentAlmanacStructure()); | ||
} | ||
|
||
static getPropertyType(prop: string) { | ||
return typeof (new MicroAgentAlmanacStructure()[prop]); | ||
} | ||
|
||
static getInterface() { | ||
return Interface.MicroAgentAlmanac; | ||
} | ||
} |
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.