-
Notifications
You must be signed in to change notification settings - Fork 212
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: localOrchAccount.getBalance
(non-vbank assets) and localOrchAccount.getBalances
#10029
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
45d1634
to
ed3037e
Compare
} catch (_) { | ||
return undefined; | ||
} | ||
}; |
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.
In the course of adding these, I considered refactoring these helpers to something like:
type DenomAmountHelper = {
coerceDenom: (denomArg: DenomArg) => Denom;
coerceDenomAmount: (amount: DenomAmount | Amount<'nat'>) => DenomAmount;
coerceCoin: (amount: AmountArg | Amount<'nat'>) => Coin;
getAssetSafe: (denom: Denom) => DenomDetail | undefined;
getDenomSafe: (brand: Brand<'nat'>) => Denom | undefined;
};
type makeDenomAmountHelper = (chainHub: ChainHub) => DenomAmountHelper;
so we can use it more conveniently. However, that might beg the question as to why these helpers aren't in ChainHub.
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 we should drop the Safe methods. I don't have a strong opinion on whether to curry the chainhub into the coercers but I lean towards the current factoring as it's more flexible.
@@ -395,21 +395,20 @@ export const makeChainHub = (agoricNames, vowTools) => { | |||
* | |||
* @param {Denom} denom | |||
* @returns {DenomDetail} | |||
* @throws {Error} if denom not found (unregistered) |
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.
there's no case in which undefined
is a valid return. let's just return undefined
when none is defined.
if (!denom) { | ||
throw Fail`No denomination for brand: ${denomArg}`; | ||
} |
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 still be after denom
is defined for type narrowing.
and then the if (brand && denom)
can be simplified to,
if (brand) {
} else {
}
if (!denom) { | ||
throw makeError(`No denomination for brand ${denomArg}`); | ||
} |
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.
to restore
* @param {Denom} denom | ||
* @returns {DenomDetail | undefined} | ||
*/ | ||
export const getAssetSafe = (chainHub, denom) => { |
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.
let's obviate
} catch (_) { | ||
return undefined; | ||
} | ||
}; |
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 we should drop the Safe methods. I don't have a strong opinion on whether to curry the chainhub into the coercers but I lean towards the current factoring as it's more flexible.
@@ -156,7 +156,7 @@ export const commonSetup = async (t: ExecutionContext<any>) => { | |||
*/ | |||
const registerAgoricBld = () => { | |||
try { | |||
chainHub.lookupAsset('ubld'); | |||
chainHub.getAsset('ubld'); |
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.
making getAsset stop throwing will need to be handled here
7a9da24
to
11f1cde
Compare
3dff07c
to
ac5d742
Compare
Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label. |
throw Fail`No denom for ${denomArg}`; | ||
} | ||
if (!denom) { | ||
throw Fail`No denomination for brand: ${denomArg}`; |
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.
"denom" was more accurate https://tutorials.cosmos.network/tutorials/6-ibc-dev/
const { chainName, baseName, baseDenom, brand } = | ||
chainHub.lookupAsset(denom); | ||
const denomDetail = chainHub.getAsset(denom); | ||
if (!denomDetail) throw Fail`No denomination detail for ${q(denom)}`; |
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.
again, denom
@@ -10,12 +10,14 @@ import { makeError } from '@endo/errors'; | |||
* @param {ChainHub} chainHub | |||
* @param {DenomArg} denomArg | |||
* @returns {Denom} | |||
* @throws {Error} if Brand is provided and ChainHub does't contain Brand:Denom |
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.
👍
|
||
t.deepEqual( | ||
await VE(account).getBalances(), | ||
// 'fake bridge is mocked to return 10 ubld and 10 uist balance' |
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.
could you import these from that module?
timer, | ||
vowTools, | ||
chainHub, | ||
{ |
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.
yeah that was too many positionals
ac5d742
to
1647cc0
Compare
1647cc0
to
2fdcddc
Compare
BREAKING CHANGE: lookupDenom -> getDenom and lookupAsset -> getAsset see []Method Naming Structure](https://docs.agoric.com/guides/ertp/#method-naming-structure) for more details
BREAKING CHANGE: The ChainHub.getAsset function returns undefined when a denom key is not found, instead of throwing an error
- getBalance should use asVow, as it synchronously throws errors
- use QueryAllBalancesRequest and localchain.query to return a list of a localOrchAccount's cosmos bank balances
2fdcddc
to
687adf1
Compare
closes: #9610
Description
LocalOrchestrationAccount.getBalance()
to support non-vbank assets (usinglocalchain.query()
to ask cosmos bank)LocalOrchestrationAccount.getBalances()
ChainHub.lookupDenom
andChainHub.lookupAsset
togetDenom
andgetAsset
ChainHub.getAsset
returns undefined instead of throwing when lookup failsSecurity Considerations
n/a
Scaling Considerations
n/a
Documentation Considerations
Updates pertinent jsodc and
exos/README.md
Testing Considerations
Includes unit and e2e tests
Upgrade Considerations
n/a, unreleased code