-
Notifications
You must be signed in to change notification settings - Fork 231
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: CosmosChainInfo
includes pfmEnabled: bool
#10329
Changes from all commits
e1c35da
52ff70a
9eea3fd
c1b406c
e72782d
e4a6c6d
2dfddb3
e5a8b64
afb4f34
032f98a
2fa2f75
118bc6a
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,22 +10,53 @@ import { createWallet } from '../tools/wallet.js'; | |||||||||||
import { AmountMath } from '@agoric/ertp'; | ||||||||||||
import { makeQueryClient } from '../tools/query.js'; | ||||||||||||
import type { Amount } from '@agoric/ertp/src/types.js'; | ||||||||||||
import chainInfo from '../starship-chain-info.js'; | ||||||||||||
import { denomHash, withChainCapabilities } from '@agoric/orchestration'; | ||||||||||||
|
||||||||||||
const test = anyTest as TestFn<SetupContextWithWallets>; | ||||||||||||
|
||||||||||||
const accounts = ['osmosis1', 'osmosis2', 'cosmoshub1', 'cosmoshub2']; | ||||||||||||
|
||||||||||||
const contractName = 'sendAnywhere'; | ||||||||||||
const contractBuilder = | ||||||||||||
'../packages/builders/scripts/testing/start-send-anywhere.js'; | ||||||||||||
'../packages/builders/scripts/testing/init-send-anywhere.js'; | ||||||||||||
|
||||||||||||
test.before(async t => { | ||||||||||||
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t); | ||||||||||||
deleteTestKeys(accounts).catch(); | ||||||||||||
const wallets = await setupTestKeys(accounts); | ||||||||||||
t.context = { ...rest, wallets, deleteTestKeys }; | ||||||||||||
const { startContract } = rest; | ||||||||||||
await startContract(contractName, contractBuilder); | ||||||||||||
|
||||||||||||
const assetInfo = { | ||||||||||||
uosmo: { | ||||||||||||
baseName: 'osmosis', | ||||||||||||
chainName: 'osmosis', | ||||||||||||
baseDenom: 'uosmo', | ||||||||||||
}, | ||||||||||||
[`ibc/${denomHash({ denom: 'uosmo', channelId: chainInfo.agoric.connections['osmosislocal'].transferChannel.channelId })}`]: | ||||||||||||
{ | ||||||||||||
baseName: 'osmosis', | ||||||||||||
chainName: 'agoric', | ||||||||||||
baseDenom: 'uosmo', | ||||||||||||
}, | ||||||||||||
uatom: { | ||||||||||||
baseName: 'cosmoshub', | ||||||||||||
chainName: 'cosmoshub', | ||||||||||||
baseDenom: 'uatom', | ||||||||||||
}, | ||||||||||||
[`ibc/${denomHash({ denom: 'uatom', channelId: chainInfo.agoric.connections['gaialocal'].transferChannel.channelId })}`]: | ||||||||||||
{ | ||||||||||||
baseName: 'cosmoshub', | ||||||||||||
chainName: 'agoric', | ||||||||||||
baseDenom: 'uatom', | ||||||||||||
}, | ||||||||||||
Comment on lines
+48
to
+53
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 doesn't connect the relevant brand. |
||||||||||||
}; | ||||||||||||
|
||||||||||||
await startContract(contractName, contractBuilder, { | ||||||||||||
chainInfo: JSON.stringify(withChainCapabilities(chainInfo)), | ||||||||||||
assetInfo: JSON.stringify(assetInfo), | ||||||||||||
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. Using agoric-sdk/packages/fast-usdc/src/utils/config-marshal.js Lines 69 to 73 in 8657c4c
|
||||||||||||
}); | ||||||||||||
}); | ||||||||||||
|
||||||||||||
test.after(async t => { | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ import { | |
getManifestForFastUSDC, | ||
} from '@agoric/fast-usdc/src/fast-usdc.start.js'; | ||
import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js'; | ||
import { denomHash, withChainCapabilities } from '@agoric/orchestration'; | ||
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; | ||
import { | ||
multiplyBy, | ||
parseRatio, | ||
|
@@ -17,12 +19,35 @@ import { parseArgs } from 'node:util'; | |
* @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js' | ||
* @import {ParseArgsConfig} from 'node:util' | ||
* @import {FastUSDCConfig} from '@agoric/fast-usdc/src/fast-usdc.start.js' | ||
* @import {Passable} from '@endo/marshal'; | ||
* @import {CosmosChainInfo} from '@agoric/orchestration'; | ||
*/ | ||
|
||
const { keys } = Object; | ||
|
||
const defaultAssetInfo = { | ||
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. again: const defaultAssetInfo = Object.fromEntries([
assetOn('uusdc', 'noble'),
assetOn('uusdc', 'noble', 'agoric', chainInfo),
assetOn('uusdc', 'noble', 'osmosis', chainInfo),
]); |
||
uusdc: { | ||
baseName: 'noble', | ||
chainName: 'noble', | ||
baseDenom: 'uusdc', | ||
}, | ||
[`ibc/${denomHash({ denom: 'uusdc', channelId: fetchedChainInfo.agoric.connections['noble-1'].transferChannel.channelId })}`]: | ||
{ | ||
baseName: 'noble', | ||
chainName: 'agoric', | ||
baseDenom: 'uusdc', | ||
brandKey: 'USDC', | ||
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. What consumes
For background, see 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 is good feedback. I went with I created a ticket to track the removal of 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. Thanks. I think it's an entirely internal interface, so it's not a big deal. |
||
}, | ||
[`ibc/${denomHash({ denom: 'uusdc', channelId: fetchedChainInfo.osmosis.connections['noble-1'].transferChannel.channelId })}`]: | ||
{ | ||
baseName: 'noble', | ||
chainName: 'osmosis', | ||
baseDenom: 'uusdc', | ||
}, | ||
}; | ||
|
||
/** | ||
* @type {Record<string, Pick<FastUSDCConfig, 'oracles' | 'feedPolicy'>>} | ||
* @type {Record<string, Pick<FastUSDCConfig, 'oracles' | 'feedPolicy' | 'chainInfo' | 'assetInfo' >>} | ||
* | ||
* TODO: determine OCW operator addresses | ||
* meanwhile, use price oracle addresses (from updatePriceFeeds.js). | ||
|
@@ -47,6 +72,10 @@ const configurations = { | |
}, | ||
}, | ||
}, | ||
chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ ( | ||
withChainCapabilities(fetchedChainInfo) | ||
), | ||
assetInfo: defaultAssetInfo, | ||
}, | ||
MAINNET: { | ||
oracles: { | ||
|
@@ -69,6 +98,10 @@ const configurations = { | |
}, | ||
}, | ||
}, | ||
chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ ( | ||
withChainCapabilities(fetchedChainInfo) | ||
), | ||
assetInfo: defaultAssetInfo, | ||
}, | ||
DEVNET: { | ||
oracles: { | ||
|
@@ -90,6 +123,10 @@ const configurations = { | |
}, | ||
}, | ||
}, | ||
chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ ( | ||
withChainCapabilities(fetchedChainInfo) // TODO: use devnet values | ||
), | ||
assetInfo: defaultAssetInfo, // TODO: use emerynet values | ||
}, | ||
EMERYNET: { | ||
oracles: { | ||
|
@@ -108,6 +145,10 @@ const configurations = { | |
}, | ||
}, | ||
}, | ||
chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ ( | ||
withChainCapabilities(fetchedChainInfo) // TODO: use emerynet values | ||
), | ||
assetInfo: defaultAssetInfo, // TODO: use emerynet values | ||
}, | ||
}; | ||
|
||
|
@@ -124,11 +165,17 @@ const options = { | |
default: | ||
'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9', | ||
}, | ||
chainInfo: { type: 'string' }, | ||
assetInfo: { type: 'string' }, | ||
}; | ||
const oraclesUsage = 'use --oracle name:address ...'; | ||
|
||
const feedPolicyUsage = 'use --feedPolicy <policy> ...'; | ||
|
||
const chainInfoUsage = 'use --chainInfo chainName:CosmosChainInfo ...'; | ||
const assetInfoUsage = | ||
'use --assetInfo denom:DenomInfo & {brandKey?: string} ...'; | ||
|
||
/** | ||
* @typedef {{ | ||
* flatFee: string; | ||
|
@@ -139,6 +186,8 @@ const feedPolicyUsage = 'use --feedPolicy <policy> ...'; | |
* oracle?: string[]; | ||
* usdcDenom: string; | ||
* feedPolicy?: string; | ||
* chainInfo: string; | ||
* assetInfo: string; | ||
* }} FastUSDCOpts | ||
*/ | ||
|
||
|
@@ -180,7 +229,15 @@ export default async (homeP, endowments) => { | |
/** @type {{ values: FastUSDCOpts }} */ | ||
// @ts-expect-error ensured by options | ||
const { | ||
values: { oracle: oracleArgs, net, usdcDenom, feedPolicy, ...fees }, | ||
values: { | ||
oracle: oracleArgs, | ||
net, | ||
usdcDenom, | ||
feedPolicy, | ||
chainInfo, | ||
assetInfo, | ||
...fees | ||
}, | ||
} = parseArgs({ args: scriptArgs, options }); | ||
|
||
const parseFeedPolicy = () => { | ||
|
@@ -226,6 +283,27 @@ export default async (homeP, endowments) => { | |
}; | ||
}; | ||
|
||
const parseChainInfo = () => { | ||
if (net) { | ||
if (!(net in configurations)) { | ||
throw Error(`${net} not in ${keys(configurations)}`); | ||
} | ||
return configurations[net].chainInfo; | ||
} | ||
if (!chainInfo) throw Error(chainInfoUsage); | ||
return JSON.parse(chainInfo); | ||
}; | ||
const parseAssetInfo = () => { | ||
if (net) { | ||
if (!(net in configurations)) { | ||
throw Error(`${net} not in ${keys(configurations)}`); | ||
} | ||
return configurations[net].assetInfo; | ||
} | ||
if (!assetInfo) throw Error(assetInfoUsage); | ||
return JSON.parse(assetInfo); | ||
}; | ||
|
||
/** @type {FastUSDCConfig} */ | ||
const config = harden({ | ||
oracles: parseOracleArgs(), | ||
|
@@ -234,6 +312,8 @@ export default async (homeP, endowments) => { | |
}, | ||
feeConfig: parseFeeConfigArgs(), | ||
feedPolicy: parseFeedPolicy(), | ||
chainInfo: parseChainInfo(), | ||
assetInfo: parseAssetInfo(), | ||
}); | ||
|
||
await writeCoreEval('start-fast-usdc', utils => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { | ||
getManifest, | ||
startSendAnywhere, | ||
} from '@agoric/orchestration/src/proposals/start-send-anywhere.js'; | ||
import { parseArgs } from 'node:util'; | ||
|
||
/** | ||
* @import {ParseArgsConfig} from 'node:util' | ||
*/ | ||
|
||
/** @type {ParseArgsConfig['options']} */ | ||
const parserOpts = { | ||
chainInfo: { type: 'string' }, | ||
assetInfo: { type: 'string' }, | ||
}; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async ( | ||
{ publishRef, install }, | ||
options, | ||
) => | ||
harden({ | ||
sourceSpec: '@agoric/orchestration/src/proposals/start-send-anywhere.js', | ||
getManifestCall: [ | ||
getManifest.name, | ||
{ | ||
installationRef: publishRef( | ||
install( | ||
'@agoric/orchestration/src/examples/send-anywhere.contract.js', | ||
), | ||
), | ||
options, | ||
}, | ||
], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { scriptArgs } = endowments; | ||
|
||
const { | ||
values: { chainInfo, assetInfo }, | ||
} = parseArgs({ | ||
args: scriptArgs, | ||
options: parserOpts, | ||
}); | ||
|
||
const parseChainInfo = () => { | ||
if (typeof chainInfo !== 'string') return undefined; | ||
return JSON.parse(chainInfo); | ||
}; | ||
const parseAssetInfo = () => { | ||
if (typeof assetInfo !== 'string') return undefined; | ||
return JSON.parse(assetInfo); | ||
}; | ||
const opts = harden({ | ||
chainInfo: parseChainInfo(), | ||
assetInfo: parseAssetInfo(), | ||
}); | ||
|
||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
|
||
await writeCoreEval(startSendAnywhere.name, utils => | ||
defaultProposalBuilder(utils, opts), | ||
); | ||
}; |
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.
a helper for this comes to mind: