-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into mfig-unhandled-vow-…
…rejection
- Loading branch information
Showing
58 changed files
with
3,945 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ upgradeProvisionPool/ | |
upgradeAgoricNames/ | ||
publishTestInfo/ | ||
upgrade-mintHolder/ | ||
upgradeAssetReserve/ |
8 changes: 8 additions & 0 deletions
8
a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral-permit.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"consume": { | ||
"contractKits": true, | ||
"zoe": true, | ||
"agoricNames": true, | ||
"reserveKit": true | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// @ts-nocheck | ||
/* eslint-disable no-undef */ | ||
|
||
const addCollateral = async powers => { | ||
const { | ||
consume: { | ||
contractKits: contractKitsP, | ||
reserveKit: reserveKitP, | ||
zoe, | ||
agoricNames, | ||
}, | ||
} = powers; | ||
|
||
const [contractKits, reserveKit, usdLemonsIssuer, usdLemonsBrand] = | ||
await Promise.all([ | ||
contractKitsP, | ||
reserveKitP, | ||
E(agoricNames).lookup('issuer', 'USD_LEMONS'), | ||
E(agoricNames).lookup('brand', 'USD_LEMONS'), | ||
]); | ||
|
||
console.log('[CONTRACT_KITS]', contractKits); | ||
console.log('[ISSUER]', usdLemonsIssuer); | ||
|
||
const { governorCreatorFacet } = reserveKit; | ||
|
||
const arPublicFacet = await E(governorCreatorFacet).getPublicFacet(); | ||
const arLimitedFacet = await E(governorCreatorFacet).getCreatorFacet(); | ||
|
||
let usdLemonsMint; | ||
for (const { publicFacet, creatorFacet: mint } of contractKits.values()) { | ||
if (publicFacet === usdLemonsIssuer) { | ||
usdLemonsMint = mint; | ||
console.log('USD_LEMONS found', mint); | ||
break; | ||
} | ||
} | ||
|
||
await E(arLimitedFacet).addIssuer(usdLemonsIssuer, 'USD_LEMONS'); | ||
|
||
console.log('Minting USD_LEMONS'); | ||
const amt = harden({ brand: usdLemonsBrand, value: 500000n }); | ||
const helloPayment = await E(usdLemonsMint).mintPayment(amt); | ||
|
||
console.log('Adding to the reserve...'); | ||
|
||
const seat = E(zoe).offer( | ||
E(arPublicFacet).makeAddCollateralInvitation(), | ||
harden({ | ||
give: { Collateral: amt }, | ||
}), | ||
harden({ Collateral: helloPayment }), | ||
); | ||
|
||
console.log(await E(seat).getOfferResult()); | ||
console.log('Done.'); | ||
}; | ||
|
||
addCollateral; |
92 changes: 92 additions & 0 deletions
92
a3p-integration/proposals/p:upgrade-19/assetReserve.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-env node */ | ||
/** | ||
* @file The goal of this file is to make sure v36-reserve upgraded. | ||
* | ||
* The test scenario is as follows; | ||
* 1. Add asset USD_LEMONS | ||
* 2. Add collateral to the reserve | ||
* 3. Upgrade reserve | ||
* 4. Ensure that the collateral is still in the reserve | ||
*/ | ||
|
||
import '@endo/init'; | ||
import test from 'ava'; | ||
import { | ||
evalBundles, | ||
agd as agdAmbient, | ||
agoric, | ||
getDetailsMatchingVats, | ||
} from '@agoric/synthetic-chain'; | ||
import { | ||
makeVstorageKit, | ||
waitUntilContractDeployed, | ||
} from '@agoric/client-utils'; | ||
|
||
const ADD_PSM_DIR = 'addUsdLemons'; | ||
const UPGRADE_AR_DIR = 'upgradeAssetReserve'; | ||
const ADD_COLLATERAL = 'addCollateral'; | ||
|
||
const ambientAuthority = { | ||
query: agdAmbient.query, | ||
follow: agoric.follow, | ||
setTimeout, | ||
log: console.log, | ||
}; | ||
|
||
/** | ||
* @typedef {import('@agoric/ertp').NatAmount} NatAmount | ||
* @typedef {{ | ||
* allocations: { Fee: NatAmount, USD_LEMONS: NatAmount }, | ||
* }} ReserveAllocations | ||
*/ | ||
|
||
test.before(async t => { | ||
const vstorageKit = await makeVstorageKit( | ||
{ fetch }, | ||
{ rpcAddrs: ['http://localhost:26657'], chainName: 'agoriclocal' }, | ||
); | ||
|
||
t.context = { | ||
vstorageKit, | ||
}; | ||
}); | ||
|
||
test.serial('add collatoral to reserve', async t => { | ||
// @ts-expect-error casting | ||
const { vstorageKit } = t.context; | ||
|
||
// Introduce USD_LEMONS | ||
await evalBundles(ADD_PSM_DIR); | ||
await waitUntilContractDeployed('psm-IST-USD_LEMONS', ambientAuthority, { | ||
errorMessage: 'psm-IST-USD_LEMONS instance not observed.', | ||
}); | ||
|
||
await evalBundles(ADD_COLLATERAL); | ||
|
||
const metrics = /** @type {ReserveAllocations} */ ( | ||
await vstorageKit.readLatestHead('published.reserve.metrics') | ||
); | ||
|
||
t.truthy(Object.keys(metrics.allocations).includes('USD_LEMONS')); | ||
t.is(metrics.allocations.USD_LEMONS.value, 500000n); | ||
}); | ||
|
||
test.serial('upgrade', async t => { | ||
// @ts-expect-error casting | ||
const { vstorageKit } = t.context; | ||
|
||
await evalBundles(UPGRADE_AR_DIR); | ||
|
||
const vatDetailsAfter = await getDetailsMatchingVats('reserve'); | ||
const { incarnation } = vatDetailsAfter.find(vat => vat.vatID === 'v36'); // assetReserve is v36 | ||
|
||
t.log(vatDetailsAfter); | ||
t.is(incarnation, 1, 'incorrect incarnation'); | ||
|
||
const metrics = /** @type {ReserveAllocations} */ ( | ||
await vstorageKit.readLatestHead('published.reserve.metrics') | ||
); | ||
|
||
t.truthy(Object.keys(metrics.allocations).includes('USD_LEMONS')); | ||
t.is(metrics.allocations.USD_LEMONS.value, 500000n); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.