@agoric/deploy-script-support 0.10.4-dev-fab25c1.0 → 0.10.4-dev-a9707aa.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/deploy-script-support",
3
- "version": "0.10.4-dev-fab25c1.0+fab25c1",
3
+ "version": "0.10.4-dev-a9707aa.0+a9707aa",
4
4
  "description": "Helpers and other support for writing deploy scripts",
5
5
  "type": "module",
6
6
  "main": "src/helpers.js",
@@ -75,5 +75,5 @@
75
75
  "typeCoverage": {
76
76
  "atLeast": 83.92
77
77
  },
78
- "gitHead": "fab25c1d7df5590379b9d71d12d4b72500652932"
78
+ "gitHead": "a9707aad73cfb88ae2a1f2000c15b2a56f9603a0"
79
79
  }
@@ -82,10 +82,30 @@ export const txFlags = ({
82
82
 
83
83
  /**
84
84
  * @param {CmdRunner} agd
85
+ * @param {number} n
86
+ */
87
+ export const waitForBlock = async (agd, n = 1) => {
88
+ const getHeight = async () => {
89
+ const { stdout } = await agd.exec(['status']);
90
+ const { latest_block_height: height } = JSON.parse(stdout).SyncInfo;
91
+ return height;
92
+ };
93
+ const initialHeight = await getHeight();
94
+ const SEC = 1000;
95
+ let currentHeight;
96
+ do {
97
+ await new Promise(resolve => setTimeout(resolve, 1 * SEC)); // XXX ambient
98
+ currentHeight = await getHeight();
99
+ } while (currentHeight - initialHeight < n);
100
+ console.log('block height:', initialHeight, currentHeight);
101
+ };
102
+
103
+ /**
104
+ * @param {CmdRunner} agd - agd with --from etc.
85
105
  * @param {string[]} txArgs
86
106
  */
87
- export const runTx = (agd, txArgs) => {
88
- const { stdout } = agd.withFlags('-o', 'json').exec(['tx', ...txArgs]);
107
+ export const runTx = async (agd, txArgs) => {
108
+ const { stdout } = await agd.withFlags('-o', 'json').exec(['tx', ...txArgs]);
89
109
  const result = JSON.parse(stdout);
90
110
  if (result.code !== 0) {
91
111
  throw Object.assign(Error(result.raw_log), result);