-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
570 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env tsx | ||
/** @file run a builder and deploy it onto the Agoric chain in local Starship cluster */ | ||
import '@endo/init/debug.js'; | ||
|
||
import { execa } from 'execa'; | ||
import fse from 'fs-extra'; | ||
import fsp from 'node:fs/promises'; | ||
import { makeE2ETools } from '../tools/e2e-tools.js'; | ||
import { makeNodeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js'; | ||
import childProcess from 'child_process'; | ||
|
||
const builder = process.argv[2]; | ||
|
||
if (!builder) { | ||
console.error('USAGE: deploy.ts <builder script>'); | ||
process.exit(1); | ||
} | ||
|
||
const tools = await (async () => { | ||
const bundleCache = await makeNodeBundleCache('bundles', {}, s => import(s)); | ||
const { writeFile } = fsp; | ||
const { execFileSync, execFile } = childProcess; | ||
const tools = await makeE2ETools(console, bundleCache, { | ||
execFileSync, | ||
execFile, | ||
fetch, | ||
setTimeout, | ||
writeFile, | ||
}); | ||
return tools; | ||
})(); | ||
|
||
// console.log('refreshing starship chain info'); | ||
// await import('./fetch-starship-chain-info.ts'); | ||
|
||
// build the plan | ||
const { stdout } = await execa`agoric run ${builder}`; | ||
const match = stdout.match(/ (?<name>[-\w]+)-permit.json/); | ||
if (!(match && match.groups)) { | ||
throw new Error('no permit found'); | ||
} | ||
const plan = await fse.readJSON(`./${match.groups.name}-plan.json`); | ||
|
||
console.log(plan); | ||
|
||
console.log('installing bundles'); | ||
tools.installBundles( | ||
plan.bundles.map(b => b.bundleID), | ||
console.log, | ||
); |
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 @@ | ||
#!/usr/bin/env tsx | ||
|
||
import nodeFetch from 'node-fetch'; | ||
import fsp from 'node:fs/promises'; | ||
import prettier from 'prettier'; | ||
|
||
import { convertChainInfo } from '@agoric/orchestration/src/utils/registry.js'; | ||
|
||
import type { IBCInfo, Chains } from '@chain-registry/types'; | ||
|
||
const fetch = nodeFetch.default; | ||
|
||
/** | ||
* Chain registry running in Starship | ||
* | ||
* https://github.com/cosmology-tech/starship/blob/main/starship/proto/registry/service.proto | ||
* | ||
* http://localhost:8081/chains | ||
* http://localhost:8081/chain_ids | ||
* http://localhost:8081/ibc | ||
*/ | ||
const BASE_URL = 'http://localhost:8081/'; | ||
|
||
const { chains }: { chains: Chains } = await fetch(`${BASE_URL}chains`).then( | ||
r => r.json(), | ||
); | ||
|
||
const ibc: { | ||
data: IBCInfo[]; | ||
} = await fetch(`${BASE_URL}ibc`).then(r => r.json()); | ||
|
||
// UNTIL https://github.com/cosmology-tech/starship/issues/494 | ||
const backmap = { | ||
agoriclocal: 'agoric', | ||
osmosislocal: 'osmosis', | ||
gaialocal: 'cosmoshub', | ||
}; | ||
for (const ibcInfo of ibc.data) { | ||
ibcInfo.chain_1.chain_name = backmap[ibcInfo.chain_1.chain_name]; | ||
ibcInfo.chain_2.chain_name = backmap[ibcInfo.chain_2.chain_name]; | ||
for (const c of ibcInfo.channels) { | ||
// @ts-expect-error XXX bad typedef | ||
c.tags.preferred = c.tags.perferred; | ||
} | ||
} | ||
|
||
const chainInfo = await convertChainInfo({ | ||
chains, | ||
ibcData: ibc.data, | ||
}); | ||
|
||
const record = JSON.stringify(chainInfo, null, 2); | ||
const src = `/** @file Generated by fetch-starship-chain-info.ts */\nexport default /** @type {const} } */ (${record});`; | ||
const prettySrc = await prettier.format(src, { | ||
parser: 'babel', // 'typescript' fails to preserve parens for typecast | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}); | ||
await fsp.writeFile('./starship-chain-info.js', prettySrc); |
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,22 @@ | ||
/* global harden */ | ||
/// <reference types="ses" /> | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
import chainInfo from '../starship-chain-info.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async () => | ||
harden({ | ||
sourceSpec: '@agoric/orchestration/src/proposals/revise-chain-info.js', | ||
getManifestCall: [ | ||
'getManifestForReviseChains', | ||
{ | ||
chainInfo, | ||
}, | ||
], | ||
}); | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('revise-chain-info', defaultProposalBuilder); | ||
}; |
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,162 @@ | ||
/** @file Generated by fetch-starship-chain-info.ts */ | ||
export default /** @type {const} } */ ({ | ||
agoric: { | ||
chainId: 'agoriclocal', | ||
stakingTokens: [ | ||
{ | ||
denom: 'ubld', | ||
}, | ||
], | ||
icqEnabled: false, | ||
connections: { | ||
gaialocal: { | ||
id: 'connection-1', | ||
client_id: '07-tendermint-1', | ||
counterparty: { | ||
client_id: '07-tendermint-1', | ||
connection_id: 'connection-1', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-1', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-1', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
osmosislocal: { | ||
id: 'connection-0', | ||
client_id: '07-tendermint-0', | ||
counterparty: { | ||
client_id: '07-tendermint-1', | ||
connection_id: 'connection-1', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-1', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-0', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
cosmoshub: { | ||
chainId: 'gaialocal', | ||
stakingTokens: [ | ||
{ | ||
denom: 'uatom', | ||
}, | ||
], | ||
icqEnabled: false, | ||
connections: { | ||
agoriclocal: { | ||
id: 'connection-1', | ||
client_id: '07-tendermint-1', | ||
counterparty: { | ||
client_id: '07-tendermint-1', | ||
connection_id: 'connection-1', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-1', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-1', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
osmosislocal: { | ||
id: 'connection-0', | ||
client_id: '07-tendermint-0', | ||
counterparty: { | ||
client_id: '07-tendermint-0', | ||
connection_id: 'connection-0', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-0', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-0', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
osmosis: { | ||
chainId: 'osmosislocal', | ||
stakingTokens: [ | ||
{ | ||
denom: 'uosmo', | ||
}, | ||
], | ||
icqEnabled: true, | ||
connections: { | ||
agoriclocal: { | ||
id: 'connection-1', | ||
client_id: '07-tendermint-1', | ||
counterparty: { | ||
client_id: '07-tendermint-0', | ||
connection_id: 'connection-0', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-0', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-1', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
gaialocal: { | ||
id: 'connection-0', | ||
client_id: '07-tendermint-0', | ||
counterparty: { | ||
client_id: '07-tendermint-0', | ||
connection_id: 'connection-0', | ||
prefix: { | ||
key_prefix: 'FIXME', | ||
}, | ||
}, | ||
state: 3, | ||
transferChannel: { | ||
channelId: 'channel-0', | ||
portId: 'transfer', | ||
counterPartyChannelId: 'channel-0', | ||
counterPartyPortId: 'transfer', | ||
ordering: 0, | ||
state: 3, | ||
version: 'ics20-1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.