-
Notifications
You must be signed in to change notification settings - Fork 308
feat(xc-admin): add support for setMaxLatency instruction #1328
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
Changes from all commits
610416e
b5ccf95
cac2aab
7cf3b6d
6e5b61b
cb15d24
cc1931a
6acc998
d6efa19
ce2b990
759b777
1b7d2ac
1a70daa
8bbca7c
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 |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ import Modal from '../common/Modal' | |
| import Spinner from '../common/Spinner' | ||
| import Loadbar from '../loaders/Loadbar' | ||
| import PermissionDepermissionKey from '../PermissionDepermissionKey' | ||
| import { PriceRawConfig } from '../../hooks/usePyth' | ||
| import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider' | ||
|
|
||
| const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | ||
| const [data, setData] = useState<any>({}) | ||
|
|
@@ -126,14 +128,15 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | |
| metadata: { | ||
| ...product.metadata, | ||
| }, | ||
| priceAccounts: product.priceAccounts.map((p) => { | ||
| priceAccounts: product.priceAccounts.map((p: PriceRawConfig) => { | ||
| return { | ||
| address: p.address.toBase58(), | ||
| publishers: p.publishers | ||
| .map((p) => p.toBase58()) | ||
| .slice(0, getMaximumNumberOfPublishers(cluster)), | ||
| expo: p.expo, | ||
| minPub: p.minPub, | ||
| maxLatency: p.maxLatency, | ||
| } | ||
| }), | ||
| } | ||
|
|
@@ -144,7 +147,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | |
| setExistingSymbols(new Set(Object.keys(symbolToData))) | ||
| setData(sortDataMemo(symbolToData)) | ||
| } | ||
| }, [rawConfig, dataIsLoading, sortDataMemo]) | ||
| }, [rawConfig, dataIsLoading, sortDataMemo, cluster]) | ||
|
Contributor
Author
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. missing dependency
Contributor
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. mmmm I'm not sure about this, maybe it's fine because changing cluster updates some of the other deps |
||
|
|
||
| const sortObjectByKeys = (obj: any) => { | ||
| const sortedObj: any = {} | ||
|
|
@@ -367,7 +370,6 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | |
| } | ||
|
|
||
| // create add publisher instruction if there are any publishers | ||
|
|
||
| for (let publisherKey of newChanges.priceAccounts[0].publishers) { | ||
| instructions.push( | ||
| await pythProgramClient.methods | ||
|
|
@@ -489,6 +491,26 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | |
| ) | ||
| } | ||
|
|
||
| // check if maxLatency has changed | ||
| if ( | ||
| prev.priceAccounts[0].maxLatency !== | ||
| newChanges.priceAccounts[0].maxLatency | ||
| ) { | ||
| // create update product account instruction | ||
| instructions.push( | ||
| await pythProgramClient.methods | ||
| .setMaxLatency( | ||
| newChanges.priceAccounts[0].maxLatency, | ||
| [0, 0, 0] | ||
| ) | ||
| .accounts({ | ||
| priceAccount: new PublicKey(prev.priceAccounts[0].address), | ||
| fundingAccount, | ||
| }) | ||
| .instruction() | ||
| ) | ||
| } | ||
|
|
||
| // check if publishers have changed | ||
| const publisherKeysToAdd = | ||
| newChanges.priceAccounts[0].publishers.filter( | ||
|
|
@@ -804,7 +826,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => { | |
| if (connected && squads) { | ||
| const provider = new AnchorProvider( | ||
| connection, | ||
| squads.wallet, | ||
| squads.wallet as Wallet, | ||
|
Contributor
Author
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. upgraded |
||
| AnchorProvider.defaultOptions() | ||
| ) | ||
| setPythProgramClient( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.