Skip to content

Commit

Permalink
chore(pp-upgrade): create helper core-evals
Browse files Browse the repository at this point in the history
Refs: #10395
  • Loading branch information
anilhelvaci committed Nov 6, 2024
1 parent 28cada0 commit 1b6fd5d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"consume": {
"contractKits": true,
"namesByAddressAdmin": true,
"agoricNames": true
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const PROVISIONING_POOL_ADDR = 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346';

const depositUsdLemons = async powers => {
const {
consume: { contractKits: contractKitsP, namesByAddressAdmin: namesByAddressAdminP , agoricNames },
// instance: { consume: { ['psm-IST-USD_LEMONS']: usdLemonsPsmInstanceP }}
} = powers;

const namesByAddressAdmin = await namesByAddressAdminP;

const getDepositFacet = async address => {
const admin = await E(namesByAddressAdmin).lookupAdmin(address);
console.log('ADMIN', admin)

const nameHub = await E(admin).readonly();
console.log('NAME_HUB', nameHub);
const hub = E(E(namesByAddressAdmin).lookupAdmin(address)).readonly();
return E(hub).lookup('depositFacet');
};

const [contractKits, usdLemonsIssuer, usdLemonsBrand, ppDepositFacet] = await Promise.all([
contractKitsP,
E(agoricNames).lookup('issuer', 'USD_LEMONS'),
E(agoricNames).lookup('brand', 'USD_LEMONS'),
getDepositFacet(PROVISIONING_POOL_ADDR),
]);

console.log('[CONTRACT_KITS]', contractKits);
console.log('[ISSUER]', usdLemonsIssuer);

let usdLemonsMint;
for (const { publicFacet, creatorFacet: mint } of contractKits.values()) {
if (publicFacet === usdLemonsIssuer) {
usdLemonsMint = mint;
console.log('BINGO', mint)
break;
}
}

console.log('Minting USD_LEMONS');
const helloPayment = await E(usdLemonsMint).mintPayment(harden({ brand: usdLemonsBrand, value: 500000n }));

console.log('Funding provision pool...');
await E(ppDepositFacet).receive(helloPayment);

console.log('Done.');
};

depositUsdLemons;
19 changes: 19 additions & 0 deletions packages/builders/scripts/testing/add-USD-LEMONS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { psmProposalBuilder } from '../inter-protocol/add-collateral-core.js';

const addUsdLemonsProposalBuilder = async powers => {
return psmProposalBuilder(powers, {
anchorOptions: {
denom: 'ibc/000C0AAAEECAFE000',
keyword: 'USD_LEMONS',
decimalPlaces: 6,
proposedName: 'USD_LEMONS',
}
});
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('add-LEMONS-PSM', addUsdLemonsProposalBuilder);
};

0 comments on commit 1b6fd5d

Please sign in to comment.