-
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.
Merge branch 'master' into iomekam-port-allocation
- Loading branch information
Showing
87 changed files
with
3,852 additions
and
493 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"private": true, | ||
"agoricSyntheticChain": { | ||
"fromTag": "use-upgrade-13" | ||
"fromTag": "latest" | ||
}, | ||
"scripts": { | ||
"build": "yarn run build:sdk && yarn run build:submissions && yarn run build:synthetic-chain", | ||
|
@@ -12,8 +12,8 @@ | |
"doctor": "yarn synthetic-chain doctor" | ||
}, | ||
"dependencies": { | ||
"@agoric/synthetic-chain": "^0.0.7" | ||
"@agoric/synthetic-chain": "^0.0.10" | ||
}, | ||
"packageManager": "[email protected].0", | ||
"packageManager": "[email protected].1", | ||
"license": "Apache-2.0" | ||
} |
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
74 changes: 0 additions & 74 deletions
74
a3p-integration/proposals/a:upgrade-next/ante-fees.test.js
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
a3p-integration/proposals/a:upgrade-next/exit-reclaim.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,36 @@ | ||
import test from 'ava'; | ||
import { $ } from 'execa'; | ||
import { execFileSync } from 'node:child_process'; | ||
import { makeAgd, waitForBlock } from './synthetic-chain-excerpt.js'; | ||
|
||
const offerId = 'bad-invitation-15'; // cf. prepare.sh | ||
const from = 'gov1'; | ||
|
||
test('exitOffer tool reclaims stuck payment', async t => { | ||
const showAndExec = (file, args, opts) => { | ||
console.log('$', file, ...args); | ||
return execFileSync(file, args, opts); | ||
}; | ||
const agd = makeAgd({ execFileSync: showAndExec }).withOpts({ | ||
keyringBackend: 'test', | ||
}); | ||
|
||
const addr = await agd.lookup(from); | ||
t.log(from, 'addr', addr); | ||
|
||
const getBalance = async target => { | ||
const { balances } = await agd.query(['bank', 'balances', addr]); | ||
const { amount } = balances.find(({ denom }) => denom === target); | ||
return Number(amount); | ||
}; | ||
|
||
const before = await getBalance('uist'); | ||
t.log('uist balance before:', before); | ||
|
||
await $`node ./exitOffer.js --id ${offerId} --from ${from}`; | ||
|
||
await waitForBlock(2); | ||
const after = await getBalance('uist'); | ||
t.log('uist balance after:', after); | ||
t.true(after > before); | ||
}); |
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,97 @@ | ||
// Note: limit imports to node modules for portability | ||
import { parseArgs, promisify } from 'node:util'; | ||
import { execFile } from 'node:child_process'; | ||
import { writeFile, mkdtemp, rm } from 'node:fs/promises'; | ||
import { join } from 'node:path'; | ||
|
||
const options = /** @type {const} */ ({ | ||
id: { type: 'string' }, | ||
from: { type: 'string' }, | ||
bin: { type: 'string', default: '/usr/src/agoric-sdk/node_modules/.bin' }, | ||
}); | ||
|
||
const Usage = ` | ||
Try to exit an offer, reclaiming any associated payments. | ||
node exitOffer.js --id ID --from FROM [--bin PATH] | ||
Options: | ||
--id <offer id> | ||
--from <address or key name> | ||
--bin <path to agoric and agd> default: ${options.bin.default} | ||
`; | ||
|
||
const badUsage = () => { | ||
const reason = new Error(Usage); | ||
reason.name = 'USAGE'; | ||
throw reason; | ||
}; | ||
|
||
const { stringify: q } = JSON; | ||
// limited to JSON data: no remotables/promises; no undefined. | ||
const toCapData = data => ({ body: `#${q(data)}`, slots: [] }); | ||
|
||
const { entries } = Object; | ||
/** | ||
* @param {Record<string, string>} obj - e.g. { color: 'blue' } | ||
* @returns {string[]} - e.g. ['--color', 'blue'] | ||
*/ | ||
const flags = obj => | ||
entries(obj) | ||
.map(([k, v]) => [`--${k}`, v]) | ||
.flat(); | ||
|
||
const execP = promisify(execFile); | ||
|
||
const showAndRun = (file, args) => { | ||
console.log('$', file, ...args); | ||
return execP(file, args); | ||
}; | ||
|
||
const withTempFile = async (tail, fn) => { | ||
const tmpDir = await mkdtemp('offers-'); | ||
const tmpFile = join(tmpDir, tail); | ||
try { | ||
const result = await fn(tmpFile); | ||
return result; | ||
} finally { | ||
await rm(tmpDir, { recursive: true, force: true }).catch(err => | ||
console.error(err), | ||
); | ||
} | ||
}; | ||
|
||
const doAction = async (action, from) => { | ||
await withTempFile('offer.json', async tmpOffer => { | ||
await writeFile(tmpOffer, q(toCapData(action))); | ||
|
||
const out = await showAndRun('agoric', [ | ||
'wallet', | ||
...flags({ 'keyring-backend': 'test' }), | ||
'send', | ||
...flags({ offer: tmpOffer, from }), | ||
]); | ||
return out.stdout; | ||
}); | ||
}; | ||
|
||
const main = async (argv, env) => { | ||
const { values } = parseArgs({ args: argv.slice(2), options }); | ||
const { id: offerId, from, bin } = values; | ||
(offerId && from) || badUsage(); | ||
|
||
env.PATH = `${bin}:${env.PATH}`; | ||
const action = { method: 'tryExitOffer', offerId }; | ||
const out = await doAction(action, from); | ||
console.log(out); | ||
}; | ||
|
||
main(process.argv, process.env).catch(e => { | ||
if (e.name === 'USAGE' || e.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') { | ||
console.error(e.message); | ||
} else { | ||
console.error(e); | ||
} | ||
process.exit(1); | ||
}); |
Oops, something went wrong.