Skip to content

Commit

Permalink
Upgrade 13 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman authored Jan 5, 2024
2 parents 2007e7a + 51a9306 commit ab2422a
Show file tree
Hide file tree
Showing 13 changed files with 2,047 additions and 50 deletions.
9 changes: 2 additions & 7 deletions proposals/34:upgrade-10/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
executeCommand,
} from '../../upgrade-test-scripts/lib/cliHelper.js';
import {
HOME,
ATOM_DENOM,
GOV1ADDR,
GOV2ADDR,
Expand All @@ -18,7 +17,7 @@ import {
import {
waitForBlock,
executeOffer,
getUser,
addUser,
provisionSmartWallet,
} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js';

Expand Down Expand Up @@ -200,12 +199,8 @@ const paramChangeOfferGeneration = async (
const capData = { body: `#${JSON.stringify(body)}`, slots };
return JSON.stringify(capData);
};

export const provisionWallet = async user => {
const userKeyData = await agd.keys('add', user, '--keyring-backend=test');
await fs.writeFile(`${HOME}/.agoric/${user}.key`, userKeyData.mnemonic);

const userAddress = await getUser(user);
const userAddress = await addUser(user);

await provisionSmartWallet(
userAddress,
Expand Down
13 changes: 5 additions & 8 deletions proposals/49:smart-wallet-nft/core-eval-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { Fail, NonNullish } from '../../upgrade-test-scripts/lib/assert.js';

// TODO: factor out ambient authority from these
// or at least allow caller to supply authority.
import { mintIST } from '../../upgrade-test-scripts/lib/econHelpers.js';
import {
getISTBalance,
mintIST,
} from '../../upgrade-test-scripts/lib/econHelpers.js';
import { agoric } from '../../upgrade-test-scripts/lib/cliHelper.js';

// move to unmarshal.js?
Expand Down Expand Up @@ -94,12 +97,6 @@ const importBundleCost = (bytes, price = 0.002) => {
* }} ProposalInfo
*/

const myISTBalance = async (agd, addr, denom = 'uist', unit = 1_000_000) => {
const coins = await agd.query(['bank', 'balances', addr]);
const coin = coins.balances.find(a => a.denom === denom);
return Number(coin.amount) / unit;
};

/**
* @param {number} myIST
* @param {number} cost
Expand Down Expand Up @@ -136,7 +133,7 @@ export const ensureISTForInstall = async (agd, config, bytes, { log }) => {
log({ totalSize: bytes, cost });
const { installer } = config;
const addr = agd.lookup(installer);
const istBalance = await myISTBalance(agd, addr);
const istBalance = await getISTBalance(addr);

if (istBalance > cost) {
log('balance sufficient', { istBalance, cost });
Expand Down
13 changes: 5 additions & 8 deletions proposals/53:kread-start/core-eval-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { Fail, NonNullish } from '../../upgrade-test-scripts/lib/assert.js';

// TODO: factor out ambient authority from these
// or at least allow caller to supply authority.
import { mintIST } from '../../upgrade-test-scripts/lib/econHelpers.js';
import {
getISTBalance,
mintIST,
} from '../../upgrade-test-scripts/lib/econHelpers.js';
import { agoric } from '../../upgrade-test-scripts/lib/cliHelper.js';

// move to unmarshal.js?
Expand Down Expand Up @@ -93,12 +96,6 @@ const importBundleCost = (bytes, price = 0.002) => {
* }} ProposalInfo
*/

const myISTBalance = async (agd, addr, denom = 'uist', unit = 1_000_000) => {
const coins = await agd.query(['bank', 'balances', addr]);
const coin = coins.balances.find(a => a.denom === denom);
return Number(coin.amount) / unit;
};

/**
* @param {number} myIST
* @param {number} cost
Expand Down Expand Up @@ -135,7 +132,7 @@ export const ensureISTForInstall = async (agd, config, bytes, { log }) => {
log({ totalSize: bytes, cost });
const { installer } = config;
const addr = agd.lookup(installer);
const istBalance = await myISTBalance(agd, addr);
const istBalance = await getISTBalance(addr);

if (istBalance > cost) {
log('balance sufficient', { istBalance, cost });
Expand Down
13 changes: 5 additions & 8 deletions proposals/55:statom-vaults/core-eval-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { Fail, NonNullish } from '../../upgrade-test-scripts/lib/assert.js';

// TODO: factor out ambient authority from these
// or at least allow caller to supply authority.
import { mintIST } from '../../upgrade-test-scripts/lib/econHelpers.js';
import {
getISTBalance,
mintIST,
} from '../../upgrade-test-scripts/lib/econHelpers.js';
import { agoric } from '../../upgrade-test-scripts/lib/cliHelper.js';

// move to unmarshal.js?
Expand Down Expand Up @@ -94,12 +97,6 @@ const importBundleCost = (bytes, price = 0.002) => {
* }} ProposalInfo
*/

const myISTBalance = async (agd, addr, denom = 'uist', unit = 1_000_000) => {
const coins = await agd.query(['bank', 'balances', addr]);
const coin = coins.balances.find(a => a.denom === denom);
return Number(coin.amount) / unit;
};

/**
* @param {number} myIST
* @param {number} cost
Expand Down Expand Up @@ -136,7 +133,7 @@ export const ensureISTForInstall = async (agd, config, bytes, { log }) => {
log({ totalSize: bytes, cost });
const { installer } = config;
const addr = agd.lookup(installer);
const istBalance = await myISTBalance(agd, addr);
const istBalance = await getISTBalance(addr);

if (istBalance > cost) {
log('balance sufficient', { istBalance, cost });
Expand Down
1 change: 1 addition & 0 deletions proposals/65:upgrade-13/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
18 changes: 18 additions & 0 deletions proposals/65:upgrade-13/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"agoricProposal": {
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-13",
"sdkImageTag": "39",
"planName": "agoric-upgrade-13",
"type": "Software Upgrade Proposal"
},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"ava": "^5.3.1",
"execa": "^7.2.0"
},
"scripts": {
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops"
},
"packageManager": "[email protected]"
}
55 changes: 55 additions & 0 deletions proposals/65:upgrade-13/post.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import test from 'ava';

import { agd } from '../../upgrade-test-scripts/lib/cliHelper.js';
import {
ATOM_DENOM,
CHAINID,
GOV1ADDR,
} from '../../upgrade-test-scripts/lib/constants.js';
import {
mintIST,
getISTBalance,
openVault,
} from '../../upgrade-test-scripts/lib/econHelpers.js';
import {
waitForBlock,
addUser,
} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js';

test.before(async t => {
await mintIST(GOV1ADDR, 12340000000, 10000, 2000);

await waitForBlock(2);
const userAddress = await addUser('user-auto');
await agd.tx(
'bank',
'send',
'gov1',
userAddress,
`1000000uist,2100000000${ATOM_DENOM}`,
'--from',
GOV1ADDR,
'--chain-id',
CHAINID,
'--keyring-backend',
'test',
'--yes',
);
t.context = { userAddress };
await waitForBlock(2);
});

test('Open Vaults with auto-provisioned wallet', async t => {
const { userAddress } = /** @type {{userAddress: string}} */ (t.context);
t.is(await getISTBalance(userAddress), 1);

const ATOMGiven = 2000;
const ISTWanted = 400;
await openVault(userAddress, ISTWanted, ATOMGiven);

await waitForBlock(2);

const newISTBalance = await getISTBalance(userAddress);
t.log('New IST Balance in user-auto account:', newISTBalance);
t.true(newISTBalance >= ISTWanted, 'Got the wanted IST');
});
4 changes: 4 additions & 0 deletions proposals/65:upgrade-13/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
source /usr/src/upgrade-test-scripts/env_setup.sh

yarn ava post.test.js
Loading

0 comments on commit ab2422a

Please sign in to comment.