-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(smart-wallet): upgrade walletFactory for non-vbank assets
- mint-ist.sh to pay for publish-bundle adapted from auctioneer-private-args branch - ensure GOV1ADDR is set so we don't give agd too few args and get a weird diagnostic - chore(walletFactory): initHandler / setHandler / upgrading - chore(walletFactory): start -> prepare for compat - chore(game contract): atomicRearrange -> zcf.reallocate() for compat - feat(smart-wallet): publishAgoricBrandsDisplayInfo to vstorage - test(smart-wallet): upgraded walletFactory handles game NFT - install game contract before walletFactory upgrade - move vat-status.mjs to tools/ - move mint-ist, parseProposals to tools/ - chore: split game1 proposal from walletFactory upgrade
- Loading branch information
Showing
19 changed files
with
701 additions
and
40 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
34 changes: 34 additions & 0 deletions
34
packages/builders/scripts/smart-wallet/build-game1-start.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,34 @@ | ||
/** | ||
* @file Proposal Builder: Start Game with non-vbank Place NFT asset | ||
* | ||
* Usage: | ||
* agoric run build-game1-start.js | ||
*/ | ||
|
||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForGame1 } from '@agoric/smart-wallet/test/start-game1-proposal.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const game1ProposalBuilder = async ({ publishRef, install }) => { | ||
return harden({ | ||
sourceSpec: '@agoric/smart-wallet/test/start-game1-proposal.js', | ||
getManifestCall: [ | ||
getManifestForGame1.name, | ||
{ | ||
game1Ref: publishRef( | ||
install( | ||
'@agoric/smart-wallet/test/gameAssetContract.js', | ||
'../bundles/bundle-game1.js', | ||
{ persist: true }, | ||
), | ||
), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
/** @type {DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
await writeCoreProposal('start-game1', game1ProposalBuilder); | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/builders/scripts/smart-wallet/build-walletFactory-upgrade.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,35 @@ | ||
/** | ||
* @file Proposal Builder: Upgrade walletFactory | ||
* | ||
* Usage: | ||
* agoric run build-walletFactory-upgrade.js | ||
*/ | ||
|
||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForUpgrade } from '@agoric/smart-wallet/src/proposals/upgrade-walletFactory-proposal.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => { | ||
return harden({ | ||
sourceSpec: | ||
'@agoric/smart-wallet/src/proposals/upgrade-walletFactory-proposal.js', | ||
getManifestCall: [ | ||
getManifestForUpgrade.name, | ||
{ | ||
walletFactoryRef: publishRef( | ||
install( | ||
'@agoric/smart-wallet/src/walletFactory.js', | ||
'../bundles/bundle-walletFactory.js', | ||
{ persist: true }, | ||
), | ||
), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
/** @type {DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
await writeCoreProposal('upgrade-walletFactory', defaultProposalBuilder); | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/.gitignore
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,2 @@ | ||
upgrade-walletFactory-permit.json | ||
upgrade-walletFactory.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
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
16 changes: 16 additions & 0 deletions
16
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/mint-ist.sh
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,16 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$GOV1ADDR" ]; then | ||
echo run env_setup.sh to set GOV1ADDR | ||
exit 1 | ||
fi | ||
|
||
micro=000000 | ||
|
||
# send some collateral to gov1 | ||
agd tx bank send validator $GOV1ADDR 20123$micro${ATOM_DENOM} \ | ||
--keyring-backend=test --chain-id=agoriclocal --yes -bblock -o json | ||
|
||
export PATH=/usr/src/agoric-sdk/packages/agoric-cli/bin:$PATH | ||
agops vaults open --giveCollateral 5000 --wantMinted 20000 > /tmp/offer.json | ||
agops perf satisfaction --executeOffer /tmp/offer.json --from gov1 --keyring-backend=test |
41 changes: 41 additions & 0 deletions
41
...s/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/parseProposals.mjs
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,41 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'fs'; | ||
|
||
const Fail = (template, ...args) => { | ||
throw Error(String.raw(template, ...args.map(val => String(val)))); | ||
}; | ||
|
||
/** | ||
* Parse output of `agoric run proposal-builder.js` | ||
* | ||
* @param {string} txt | ||
* | ||
* adapted from packages/boot/test/bootstrapTests/supports.js | ||
*/ | ||
const parseProposalParts = txt => { | ||
const evals = [ | ||
...txt.matchAll(/swingset-core-eval (?<permit>\S+) (?<script>\S+)/g), | ||
].map(m => { | ||
if (!m.groups) throw Fail`Invalid proposal output ${m[0]}`; | ||
const { permit, script } = m.groups; | ||
return { permit, script }; | ||
}); | ||
evals.length || Fail`No swingset-core-eval found in proposal output: ${txt}`; | ||
|
||
const bundles = [...txt.matchAll(/swingset install-bundle @([^\n]+)/gm)].map( | ||
([, bundle]) => bundle, | ||
); | ||
bundles.length || Fail`No bundles found in proposal output: ${txt}`; | ||
|
||
return { evals, bundles }; | ||
}; | ||
|
||
const main = (stdin, readFileSync) => { | ||
const input = readFileSync(stdin.fd).toString(); | ||
const parts = parseProposalParts(input); | ||
// relies on console.log printing to stdout unmodified | ||
console.log(JSON.stringify(parts)); | ||
}; | ||
|
||
main(process.stdin, fs.readFileSync); |
File renamed without changes.
116 changes: 116 additions & 0 deletions
116
...nt/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/gen-game-offer.mjs
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,116 @@ | ||
/* eslint-disable @jessie.js/safe-await-separator */ | ||
/* global process */ | ||
import assert from 'assert'; | ||
import { execFile } from 'child_process'; | ||
|
||
const ISTunit = 1_000_000n; // aka displayInfo: { decimalPlaces: 6 } | ||
const CENT = ISTunit / 100n; | ||
|
||
const [_node, _script, ...choices] = process.argv; | ||
|
||
const toSec = ms => BigInt(Math.round(ms / 1000)); | ||
|
||
const id = `join-${Date.now()}`; | ||
|
||
// look up boardIDs for brands, instances in agoricNames | ||
|
||
// poor-man's zx | ||
const $ = cmd => { | ||
console.error(cmd); | ||
const [file, ...args] = cmd.split(' '); | ||
|
||
return new Promise((resolve, reject) => { | ||
execFile(file, args, { encoding: 'utf8' }, (err, out) => { | ||
if (err) return reject(err); | ||
resolve(out); | ||
}); | ||
}); | ||
}; | ||
|
||
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]); | ||
const fromSmallCapsEntries = txt => { | ||
const { body, slots } = JSON.parse(txt); | ||
const theEntries = zip(JSON.parse(body.slice(1)), slots).map( | ||
([[name, ref], boardID]) => { | ||
const iface = ref.replace(/^\$\d+\./, ''); | ||
return [name, { iface, boardID }]; | ||
}, | ||
); | ||
return Object.fromEntries(theEntries); | ||
}; | ||
|
||
const wkInstance = fromSmallCapsEntries( | ||
await $('agoric follow -lF :published.agoricNames.instance -o text'), | ||
); | ||
assert(wkInstance.VaultFactory); | ||
|
||
const wkBrand = fromSmallCapsEntries( | ||
await $('agoric follow -lF :published.agoricNames.brand -o text'), | ||
); | ||
assert(wkBrand.IST); | ||
assert(wkBrand.Place); | ||
|
||
const slots = []; // XXX global mutable state | ||
|
||
// XXX should use @endo/marshal | ||
const smallCaps = { | ||
Nat: n => `+${n}`, | ||
replacer: (k, v) => | ||
typeof v === 'bigint' | ||
? `+${v}` | ||
: typeof v === 'symbol' | ||
? `%${v.description}` | ||
: v, | ||
// XXX mutates obj | ||
ref: obj => { | ||
if (obj.ix) return obj.ix; | ||
const ix = slots.length; | ||
slots.push(obj.boardID); | ||
obj.ix = `$${ix}.Alleged: ${obj.iface}`; | ||
return obj.ix; | ||
}, | ||
}; | ||
|
||
const AmountMath = { | ||
make: (brand, value) => ({ | ||
brand: smallCaps.ref(brand), | ||
value: typeof value === 'bigint' ? smallCaps.Nat(value) : value, | ||
}), | ||
}; | ||
|
||
const makeTagged = (tag, payload) => ({ | ||
'#tag': tag, | ||
payload, | ||
}); | ||
|
||
const makeCopyBag = entries => makeTagged('copyBag', entries); | ||
const want = { | ||
Places: AmountMath.make( | ||
wkBrand.Place, | ||
makeCopyBag(choices.map(name => [name, 1n])), | ||
), | ||
}; | ||
|
||
const give = { Price: AmountMath.make(wkBrand.IST, 25n * CENT) }; | ||
const body = { | ||
method: 'executeOffer', | ||
offer: { | ||
id, | ||
invitationSpec: { | ||
source: 'contract', | ||
instance: smallCaps.ref(wkInstance.game1), | ||
publicInvitationMaker: 'makeJoinInvitation', | ||
}, | ||
proposal: { give, want }, | ||
}, | ||
}; | ||
|
||
console.error(JSON.stringify(body.offer, smallCaps.replacer, 1)); | ||
|
||
const capData = { | ||
body: `#${JSON.stringify(body, smallCaps.replacer)}`, | ||
slots, | ||
}; | ||
const action = JSON.stringify(capData); | ||
|
||
console.log(action); |
Oops, something went wrong.