-
Notifications
You must be signed in to change notification settings - Fork 206
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!: makeOsmosisSwap() using getDenomOn #9814
base: master
Are you sure you want to change the base?
Changes from 1 commit
cf7f043
09928c8
590dd03
a0c3950
8041ea7
59dc885
308e6eb
b046968
9a48822
dff557e
0890182
c37bcca
b555881
66ad3c9
60b30cb
f7dd521
46ac601
a06c29b
6a213e9
7a6ba9b
f9e7f4d
82e2040
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ import { | |
DenomShape, | ||
LocalChainAccountShape, | ||
} from '../typeGuards.js'; | ||
import { denomHash } from '../utils/denomHash.js'; | ||
|
||
/** | ||
* @import {Zone} from '@agoric/base-zone'; | ||
|
@@ -39,6 +40,11 @@ export const OrchestratorI = M.interface('Orchestrator', { | |
getChain: M.call(M.string()).returns(Vow$(ChainInfoShape)), | ||
makeLocalAccount: M.call().returns(Vow$(LocalChainAccountShape)), | ||
getBrandInfo: M.call(DenomShape).returns(BrandInfoShape), | ||
getDenomOn: M.call( | ||
DenomShape, | ||
M.remotable('Chain'), | ||
M.remotable('Chain'), | ||
).returns(Vow$(DenomShape)), | ||
asAmount: M.call(DenomAmountShape).returns(AmountShape), | ||
}); | ||
|
||
|
@@ -67,7 +73,7 @@ const prepareOrchestratorKit = ( | |
chainByName, | ||
makeLocalChainFacade, | ||
makeRemoteChainFacade, | ||
vowTools: { watch, asVow }, | ||
vowTools: { watch, asVow, when }, // TODO: no when | ||
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. will we need 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. no idea; I guess I should look into it |
||
}, | ||
) => | ||
zone.exoClassKit( | ||
|
@@ -156,6 +162,22 @@ const prepareOrchestratorKit = ( | |
// @ts-expect-error XXX HostOf<> not quite right? | ||
return harden({ chain, base, brand, baseDenom }); | ||
}, | ||
|
||
/** @type {HostOf<Orchestrator['getDenomOn']>} */ | ||
getDenomOn(baseDenom, base, chain) { | ||
// TODO: when -> watch | ||
return asVow(async () => { | ||
const baseInfo = await when(base.getChainInfo()); // XXX when | ||
const chainInfo = await when(chain.getChainInfo()); | ||
const { transferChannel } = await when( | ||
chainHub.getConnectionInfo(chainInfo.chainId, baseInfo.chainId), | ||
); | ||
const { channelId, portId } = transferChannel; | ||
const hash = denomHash({ portId, channelId, denom: baseDenom }); | ||
return `ibc/${hash}`; | ||
}); | ||
}, | ||
|
||
/** @type {HostOf<Orchestrator['asAmount']>} */ | ||
asAmount: () => Fail`not yet implemented`, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,8 +87,6 @@ export interface Chain<CI extends ChainInfo> { | |
*/ | ||
makeAccount: () => Promise<OrchestrationAccount<CI>>; | ||
// FUTURE supply optional port object; also fetch port object | ||
|
||
// TODO provide a way to get the local denom/brand/whatever for this chain | ||
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.
It's on 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. intended design is/was: osmosis.getLocalDenom(baseDemon) |
||
} | ||
|
||
/** | ||
|
@@ -124,6 +122,24 @@ export interface Orchestrator { | |
/** the Denom for the underlying asset on its issuer chain */ | ||
baseDenom: Denom; | ||
}; | ||
|
||
/** | ||
* Get denom on a holding chain. | ||
* | ||
* @param baseDenom denom on issuing chain | ||
* @param base issuing chain | ||
* @param chain holding chain - connection to base chain must be regitered in chainHub | ||
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. typo |
||
* @returns denom on holding chain | ||
*/ | ||
getDenomOn: < | ||
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. new top level interface method will need @tribble review 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. right... 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. the name different arg names might help... which suggests |
||
HoldingChain extends keyof KnownChains, | ||
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. not strictly necessary that it's a known chain. but we can tackle that when we have more use of contract-specified chains 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 followed the structure of |
||
IssuingChain extends keyof KnownChains, | ||
>( | ||
baseDenom: Denom, | ||
base: Chain<KnownChains[IssuingChain]>, | ||
chain: Chain<KnownChains[HoldingChain]>, | ||
) => Promise<Denom>; | ||
|
||
// TODO preload the mapping so this can be synchronous | ||
/** | ||
* Convert an amount described in native data to a local, structured Amount. | ||
|
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.
it is remotable but it lives in the same vat. can we have a stricter type in that case? (curious, not blocking)
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.
no; patterns are pass-invariant, and "in the same vat" is the antithesis of pass-invariant.