From 1b6fd5db968df0adf7344e1f93d1be97813bfcc7 Mon Sep 17 00:00:00 2001 From: anilhelvaci Date: Wed, 6 Nov 2024 16:43:15 +0300 Subject: [PATCH] chore(pp-upgrade): create helper core-evals Refs: https://github.com/Agoric/agoric-sdk/issues/10395 --- .../deposit-usd-lemons-permit.json | 8 +++ .../depositUSD-LEMONS/deposit-usd-lemons.js | 49 +++++++++++++++++++ .../scripts/testing/add-USD-LEMONS.js | 19 +++++++ 3 files changed, 76 insertions(+) create mode 100644 a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons-permit.json create mode 100644 a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons.js create mode 100644 packages/builders/scripts/testing/add-USD-LEMONS.js diff --git a/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons-permit.json b/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons-permit.json new file mode 100644 index 000000000000..0a580519276d --- /dev/null +++ b/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons-permit.json @@ -0,0 +1,8 @@ +{ + "consume": { + "contractKits": true, + "namesByAddressAdmin": true, + "agoricNames": true + } +} + diff --git a/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons.js b/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons.js new file mode 100644 index 000000000000..2d9a6f0650f6 --- /dev/null +++ b/a3p-integration/proposals/p:upgrade-19/depositUSD-LEMONS/deposit-usd-lemons.js @@ -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; diff --git a/packages/builders/scripts/testing/add-USD-LEMONS.js b/packages/builders/scripts/testing/add-USD-LEMONS.js new file mode 100644 index 000000000000..89afc1279cbe --- /dev/null +++ b/packages/builders/scripts/testing/add-USD-LEMONS.js @@ -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); + }; \ No newline at end of file