Skip to content

Commit

Permalink
chore: work around lack of USDC PSM
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 19, 2024
1 parent 7d78aaa commit cb784a6
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/fast-usdc/src/fast-usdc.start.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ const publishDisplayInfo = async (brand, { board, chainStorage }) => {
await E(node).setValue(JSON.stringify(aux));
};

/**
* Look up USDC issuer. Since it's not available in some test
* contexts, use USDC_axl as a fall-back.
*
* UNTIL https://github.com/Agoric/agoric-3-proposals/issues/19
* @param {BootstrapPowers['consume']['agoricNames']} agoricNames
*/
const lookupUSDCIssuer = async agoricNames => {
await null;
try {
/** @type {Issuer<'nat'>} */
const issuer = await E(agoricNames).lookup('issuer', 'USDC');
return issuer;
} catch (notFound) {
console.warn('USDC not found; using USDC_axl fallback', notFound);

/** @type {Issuer<'nat'>} */
const issuer = await E(agoricNames).lookup('issuer', 'USDC_axl');
return issuer;
}
};

/**
* @typedef { PromiseSpaceOf<{
* fastUsdcKit: FastUSDCKit
Expand Down Expand Up @@ -125,8 +147,7 @@ export const startFastUSDC = async (
trace('startFastUSDC');

await null;
/** @type {Issuer<'nat'>} */
const USDCissuer = await E(agoricNames).lookup('issuer', 'USDC');
const USDCissuer = await lookupUSDCIssuer(agoricNames);
const brands = harden({
USDC: await E(USDCissuer).getBrand(),
});
Expand Down

0 comments on commit cb784a6

Please sign in to comment.