Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synchronous makeVstorageKit #10670

Merged
merged 10 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion a3p-integration/proposals/s:stake-bld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"packageManager": "[email protected]",
"devDependencies": {
"@types/node": "^22.0.0"
"@types/node": "^22.0.0",
"typescript": "^5.7.2"
},
"resolutions": {
"@agoric/cosmos": "portal:../../agoric-sdk/golang/cosmos",
Expand Down
11 changes: 6 additions & 5 deletions a3p-integration/proposals/s:stake-bld/stakeBld.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GOV1ADDR } from '@agoric/synthetic-chain';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
import assert from 'node:assert';
import process from 'node:process';
import { networkConfig, walletUtils } from './test-lib/index.js';
import { networkConfig, agdWalletUtils } from './test-lib/index.js';

// XXX not the same as VALIDATOR_ADDRESS, which is actually the delegator
const VALIDATOR_ADDRESS = process.env.VALIDATOR_ADDRESS;
Expand All @@ -26,14 +26,15 @@ const currentDelegation = async () => {
test('basic', async t => {
assert(GOV1ADDR);

const { brand } = walletUtils.agoricNames;
const { brand } = agdWalletUtils.agoricNames;

t.is((await currentDelegation()).length, 1, 'just the initial delegation');

/** @type {import('@agoric/ertp').Brand} */
// @ts-expect-error actually a BoardRemote
const BLDBrand = brand.BLD;

await walletUtils.broadcastBridgeAction(GOV1ADDR, {
await agdWalletUtils.broadcastBridgeAction(GOV1ADDR, {
method: 'executeOffer',
offer: {
id: 'request-stake',
Expand All @@ -50,7 +51,7 @@ test('basic', async t => {
},
});

await walletUtils.broadcastBridgeAction(GOV1ADDR, {
await agdWalletUtils.broadcastBridgeAction(GOV1ADDR, {
method: 'executeOffer',
offer: {
id: 'request-delegate-6',
Expand All @@ -75,7 +76,7 @@ test('basic', async t => {
// omit 'delegation' because it has 'delegatorAddress' which is different every test run
});

await walletUtils.broadcastBridgeAction(GOV1ADDR, {
await agdWalletUtils.broadcastBridgeAction(GOV1ADDR, {
method: 'executeOffer',
offer: {
id: 'request-undelegate',
Expand Down
15 changes: 10 additions & 5 deletions a3p-integration/proposals/s:stake-bld/test-lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-env node */
import { makeSmartWalletKit, LOCAL_CONFIG } from '@agoric/client-utils';
import { execFileSync } from 'child_process';
import { LOCAL_CONFIG as networkConfig } from '@agoric/client-utils';
import { makeWalletUtils } from './wallet.js';
import { makeAgdWalletKit } from './wallet.js';

export { networkConfig };
export const networkConfig = LOCAL_CONFIG;

/**
* Resolve after a delay in milliseconds.
Expand All @@ -13,7 +13,12 @@ export { networkConfig };
*/
const delay = ms => new Promise(resolve => setTimeout(() => resolve(), ms));

export const walletUtils = await makeWalletUtils(
{ execFileSync, delay, fetch },
export const smartWalletKit = await makeSmartWalletKit(
{ delay, fetch },
networkConfig,
);

export const agdWalletUtils = await makeAgdWalletKit(
{ execFileSync, smartWalletKit, delay },
networkConfig,
);
24 changes: 12 additions & 12 deletions a3p-integration/proposals/s:stake-bld/test-lib/wallet.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// @ts-check

import { makeVstorageKit } from '@agoric/client-utils';
import { sendAction } from 'agoric/src/lib/index.js';
import { inspect } from 'util';

export const makeWalletUtils = async (
{ delay, execFileSync, fetch },
/**
* Stop-gap using execFileSync until we have a pure JS signing client.
*
* @param {object} root0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: this root0 seems a little out of place, yet familiar... is this codegen or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's what the eslint autofixer for missing jsdoc params does

* @param {import('child_process')['execFileSync']} root0.execFileSync
* @param {import('@agoric/client-utils').SmartWalletKit} root0.smartWalletKit
* @param {any} root0.delay
* @param {import('@agoric/client-utils').MinimalNetworkConfig} networkConfig
*/
export const makeAgdWalletKit = async (
{ execFileSync, smartWalletKit, delay },
networkConfig,
) => {
const { agoricNames, fromBoard, marshaller, readLatestHead, vstorage } =
await makeVstorageKit({ fetch }, networkConfig);

/**
*
* @param {string} from
Expand All @@ -23,17 +28,12 @@ export const makeWalletUtils = async (
delay,
execFileSync,
from,
marshaller,
keyring: { backend: 'test' },
});
};

return {
agoricNames,
...smartWalletKit,
broadcastBridgeAction,
fromBoard,
networkConfig,
readLatestHead,
vstorage,
};
};
21 changes: 21 additions & 0 deletions a3p-integration/proposals/s:stake-bld/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4617,6 +4617,7 @@ __metadata:
agoric: "npm:dev"
ava: "npm:^5.3.1"
execa: "npm:^8.0.1"
typescript: "npm:^5.7.2"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -5189,6 +5190,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.7.2":
version: 5.7.2
resolution: "typescript@npm:5.7.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/a873118b5201b2ef332127ef5c63fb9d9c155e6fdbe211cbd9d8e65877283797cca76546bad742eea36ed7efbe3424a30376818f79c7318512064e8625d61622
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A5.1.6 - 5.6.x#optional!builtin<compat/typescript>":
version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=8c6c40"
Expand All @@ -5199,6 +5210,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.7.2#optional!builtin<compat/typescript>":
version: 5.7.2
resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin<compat/typescript>::version=5.7.2&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/f3b8082c9d1d1629a215245c9087df56cb784f9fb6f27b5d55577a20e68afe2a889c040aacff6d27e35be165ecf9dca66e694c42eb9a50b3b2c451b36b5675cb
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
Expand Down
2 changes: 1 addition & 1 deletion a3p-integration/proposals/z:acceptance/psm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@agoric/synthetic-chain';
import { waitUntilAccountFunded } from '@agoric/client-utils';
import test from 'ava';
import { NonNullish } from './test-lib/errors.js';
import { NonNullish } from '@agoric/internal/src/errors.js';
import {
adjustBalancesIfNotProvisioned,
bankSend,
Expand Down
140 changes: 0 additions & 140 deletions a3p-integration/proposals/z:acceptance/test-lib/chain.js

This file was deleted.

20 changes: 0 additions & 20 deletions a3p-integration/proposals/z:acceptance/test-lib/errors.js

This file was deleted.

15 changes: 6 additions & 9 deletions a3p-integration/proposals/z:acceptance/test-lib/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* eslint-env node */
import { makeWalletUtils } from '@agoric/client-utils';
import { makeSmartWalletKit, LOCAL_CONFIG } from '@agoric/client-utils';
import { execFileSync } from 'child_process';
import { makeAgdWalletUtils } from './wallet.js';
import { makeAgdWalletKit } from './wallet.js';

export const networkConfig = {
rpcAddrs: ['http://0.0.0.0:26657'],
chainName: 'agoriclocal',
};
export const networkConfig = LOCAL_CONFIG;

/**
* Resolve after a delay in milliseconds.
Expand All @@ -16,12 +13,12 @@ export const networkConfig = {
*/
const delay = ms => new Promise(resolve => setTimeout(() => resolve(), ms));

export const walletUtils = await makeWalletUtils(
export const smartWalletKit = await makeSmartWalletKit(
{ delay, fetch },
networkConfig,
);

export const agdWalletUtils = await makeAgdWalletUtils(
{ execFileSync, setTimeout, walletUtils },
export const agdWalletUtils = await makeAgdWalletKit(
{ execFileSync, smartWalletKit, delay },
networkConfig,
);
1 change: 1 addition & 0 deletions a3p-integration/proposals/z:acceptance/test-lib/kread.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck FIXME
// XXX uses agoric.follow to read data through spawned processes; replace with VstorageKit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is agoric.follow deprecated? Just not preferred? Is there a larger pattern of work to replace it with vstorage kit that we should file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated, yeah. The larger pattern is in the comment, "replace with VstorageKit". That gets the vstorage data without shelling out, making it more portable and less dependent on the process env (e.g. PATH)

import assert from 'node:assert';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
VALIDATORADDR,
} from '@agoric/synthetic-chain';
import fsp from 'node:fs/promises';
import { NonNullish } from './errors.js';
import { NonNullish } from '@agoric/internal/src/errors.js';
import { getBalances } from './utils.js';

/** @import {Result as ExecaResult, ExecaError} from 'execa'; */
Expand Down
Loading
Loading