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

Implement smart-wallet and read-only UI #5594

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1df5e01
feat(wallet-ui): much reworking of wallet connections
michaelfig Jun 13, 2022
7513d95
feat: pretty up the nonfunctional SmartWalletConnection
michaelfig Jun 13, 2022
c9d0038
inline classname
turadg Jun 13, 2022
0cc60af
enumerate ConnectionStatus
turadg Jun 13, 2022
e1e597d
refactor
turadg Jun 13, 2022
af95fcf
localStorage helpers
turadg Jun 13, 2022
0bb93d6
chore: move `Application.jsx` to `Provider.jsx`
michaelfig Jun 14, 2022
dd9466a
fix: use new `Application.jsx`
michaelfig Jun 14, 2022
fd407e2
KLUDGE: avoid AttestationTool import for now
dckc Jun 13, 2022
af48aec
chore: @agoric/smart-wallet package scaffold
dckc Jun 13, 2022
2b8d3d9
chore: prune vat-walletManager
dckc Jun 13, 2022
6a3c93f
feat: home.smartWallet
dckc Jun 14, 2022
cf0c146
build: fix smart-wallet contract deps
dckc Jun 14, 2022
70a7741
feat: connect smart-wallet with chainStorage
dckc Jun 14, 2022
6f7b0fc
chore: combine parts of smart wallet subscription
dckc Jun 14, 2022
f056824
feat(wallet-ui): merge ChainConnector into SmartWalletConnection
michaelfig Jun 14, 2022
2db3d8a
fix(smart-wallet): fresh initial state
michaelfig Jun 14, 2022
f3436f1
wip: follow casting from wallet ui
michaelfig Jun 14, 2022
b19bdd9
chore: update package names
michaelfig Jun 14, 2022
cb3f14b
fix(casting): properly unmarshal presences
michaelfig Jun 14, 2022
b302e41
feat(wallet-ui): read-only access to on-chain wallet
michaelfig Jun 14, 2022
ffaf649
fix(casting): more error handling
michaelfig Jun 14, 2022
36bdd7b
fix(wallet-ui): ready for demo
michaelfig Jun 14, 2022
ac8a288
makeSubscriptionKit no longer takes a state
turadg Jun 30, 2022
b137ad3
test: start of smart-wallet contract test
turadg Jun 30, 2022
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"golang/cosmos",
"packages/*",
"packages/wallet/api",
"packages/wallet/contract",
"packages/wallet/ui"
],
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/sdk-package-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default [
"@agoric/run-protocol",
"@agoric/same-structure",
"@agoric/sharing-service",
"@agoric/smart-wallet",
"@agoric/solo",
"@agoric/sparse-ints",
"@agoric/spawner",
Expand Down
2 changes: 2 additions & 0 deletions packages/agoric-cli/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
const newConfigToml = finishTendermintConfig({
configToml,
portNum,
enableCors: true,
});
const newAppToml = finishCosmosApp({
appToml,
portNum,
enableCors: true,
});

const create = (fileName, contents) => {
Expand Down
12 changes: 11 additions & 1 deletion packages/casting/src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ export const DEFAULT_DECODER = harden(buf => {
return harden(JSON.parse(str));
});

const ifaceAllegedPrefix = 'Alleged: ';
const ifaceInaccessiblePrefix = 'INACCESSIBLE: ';
const slotToVal = (_slot, iface) => {
// Private object.
if (typeof iface === 'string' && iface.startsWith(ifaceAllegedPrefix)) {
iface = iface.slice(ifaceAllegedPrefix.length);
}
return Far(`${ifaceInaccessiblePrefix}${iface}`, {});
};

/**
* Unserialize the JSONable data.
*
* @type {import('./types').Unserializer}
*/
export const DEFAULT_UNSERIALIZER = Far('marshal unserializer', {
unserialize: makeMarshal().unserialize,
unserialize: makeMarshal(undefined, slotToVal).unserialize,
});
4 changes: 4 additions & 0 deletions packages/casting/src/follower-cosmjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ export const makeFollower = (leader, castingSpec, options = {}) => {
const getProvenValue = () => getProvenValueAtHeight(allegedBlockHeight);

const buf = await queryVerifier(getProvenValue, crash, getAllegedValue);
if (buf.length === 0) {
fail(Error('No query results'));
return;
}
attempt = 0;
if (!committer.isValid()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ scenario2-setup-nobuild:
$(AGCH) --home=t1/n0 --keyring-dir=t1/bootstrap gentx --keyring-backend=test bootstrap 73000000ubld --chain-id=$(CHAIN_ID)
$(AGCH) --home=t1/n0 collect-gentxs
$(AGCH) --home=t1/n0 validate-genesis
NODE_OPTIONS= ../agoric-cli/bin/agoric set-defaults --export-metrics ag-chain-cosmos t1/n0/config
NODE_OPTIONS= ../agoric-cli/bin/agoric set-defaults --enable-cors --export-metrics ag-chain-cosmos t1/n0/config
# Set the chain address in all the ag-solos.
jq --arg gen $(GENESIS_TIME) --arg init $(INITIAL_HEIGHT) --arg votepd $(VOTING_PERIOD) \
'. * { genesis_time: $$gen, initial_height: $$init, app_state: { gov: { voting_params: { voting_period: $$votepd }}}}' \
Expand Down
6 changes: 3 additions & 3 deletions packages/vats/decentral-core-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"mintHolder": {
"sourceSpec": "@agoric/vats/src/mintHolder.js"
},
"smartWallet": {
"sourceSpec": "@agoric/wallet/contract/src/smart-wallet.js"
},
"zcf": {
"sourceSpec": "@agoric/zoe/contractFacet.js"
},
Expand Down Expand Up @@ -42,9 +45,6 @@
"sharing": {
"sourceSpec": "@agoric/vats/src/vat-sharing.js"
},
"walletManager": {
"sourceSpec": "@agoric/vats/src/vat-walletManager.js"
},
"zoe": {
"sourceSpec": "@agoric/vats/src/vat-zoe.js"
}
Expand Down
3 changes: 0 additions & 3 deletions packages/vats/decentral-demo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"sharing": {
"sourceSpec": "@agoric/vats/src/vat-sharing.js"
},
"walletManager": {
"sourceSpec": "@agoric/vats/src/vat-walletManager.js"
},
"zoe": {
"sourceSpec": "@agoric/vats/src/vat-zoe.js"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/vats/scripts/build-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
const sourceToBundle = [
[`../src/centralSupply.js`, `../bundles/bundle-centralSupply.js`],
[`../src/mintHolder.js`, `../bundles/bundle-mintHolder.js`],
[
`@agoric/wallet/contract/src/smart-wallet.js`,
`../bundles/bundle-smartWallet.js`,
],
];

createBundles(sourceToBundle, dirname);
38 changes: 35 additions & 3 deletions packages/vats/src/core/basic-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,41 @@ export const makeAddressNameHubs = async ({
};
harden(makeAddressNameHubs);

const WALLET_STORAGE_PATH = 'wallet';

/** @param {BootstrapSpace} powers */
export const makeClientBanks = async ({ consume: { client, bankManager } }) => {
export const makeClientBanks = async ({
consume: {
agoricNames,
board,
namesByAddress,
namesByAddressAdmin,
client,
chainStorage,
bankManager,
zoe,
},
installation: {
consume: { smartWallet },
},
}) => {
const chainStoragePresence = await chainStorage;
const walletChainStorage = await (chainStoragePresence &&
E(chainStoragePresence).getChildNode(WALLET_STORAGE_PATH));
const marshaller = E(board).getPublishingMarshaller();
return E(client).assignBundle([
address => ({ bank: E(bankManager).getBankForAddress(address) }),
address => {
const bank = E(bankManager).getBankForAddress(address);
const myAddressNameAdmin = E(namesByAddressAdmin).lookupAdmin(address);
const myWallet = E(zoe).startInstance(
smartWallet,
{},
{ agoricNames, bank, namesByAddress, myAddressNameAdmin, board },
Comment on lines +252 to +256
Copy link
Member

Choose a reason for hiding this comment

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

Both the smartWallet contract an ag-solo use myAddressNameAdmin to set up depositFacet. There can be only one. This is why we see 0 invitations in xnet #5513 (comment) .

{ storageNode: walletChainStorage, marshaller },
);

return { bank, smartWallet: myWallet };
},
]);
};
harden(makeClientBanks);
Expand All @@ -238,12 +269,13 @@ export const installBootContracts = async ({
devices: { vatAdmin },
consume: { zoe },
installation: {
produce: { centralSupply, mintHolder },
produce: { centralSupply, mintHolder, smartWallet },
},
}) => {
for (const [name, producer] of Object.entries({
centralSupply,
mintHolder,
smartWallet,
})) {
const bundleCap = D(vatAdmin).getNamedBundleCap(name);
const bundle = D(bundleCap).getBundle();
Expand Down
8 changes: 8 additions & 0 deletions packages/vats/src/core/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,16 @@ const SHARED_CHAIN_BOOTSTRAP_MANIFEST = harden({
},
makeClientBanks: {
consume: {
agoricNames: true,
namesByAddress: true,
namesByAddressAdmin: true,
bankManager: 'bank',
board: 'board',
client: true,
chainStorage: true,
zoe: 'zoe',
},
installation: { consume: { smartWallet: 'zoe' } },
home: { produce: { bank: 'bank' } },
},
installBootContracts: {
Expand All @@ -117,6 +124,7 @@ const SHARED_CHAIN_BOOTSTRAP_MANIFEST = harden({
produce: {
centralSupply: 'zoe',
mintHolder: 'zoe',
smartWallet: 'zoe',
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion packages/vats/src/core/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
* issuer: |
* 'RUN' | 'BLD' | 'Attestation' | 'AUSD',
* installation: |
* 'centralSupply' | 'mintHolder' | 'feeDistributor' |
* 'centralSupply' | 'mintHolder' | 'smartWallet' |
* 'feeDistributor' |
* 'contractGovernor' | 'committee' | 'noActionElectorate' | 'binaryVoteCounter' |
* 'amm' | 'VaultFactory' | 'liquidate' | 'runStake' |
* 'Pegasus' | 'reserve' | 'psm' | 'interchainPool',
Expand Down
1 change: 1 addition & 0 deletions packages/vats/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const agoricNamesReserved = harden({
installation: {
centralSupply: 'central supply',
mintHolder: 'mint holder',
smartWallet: 'smart wallet',
contractGovernor: 'contract governor',
committee: 'committee electorate',
noActionElectorate: 'no action electorate',
Expand Down
25 changes: 0 additions & 25 deletions packages/vats/src/vat-walletManager.js

This file was deleted.

15 changes: 10 additions & 5 deletions packages/vats/test/devices.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import bundleCentralSupply from '../bundles/bundle-centralSupply.js';
import bundleMintHolder from '../bundles/bundle-mintHolder.js';
import bundleSmartWallet from '../bundles/bundle-smartWallet.js';

export const devices = {
vatAdmin: {
getNamedBundleCap: name => ({
getBundle: () => {
if (name === 'centralSupply') {
return bundleCentralSupply;
} else if (name === 'mintHolder') {
return bundleMintHolder;
switch (name) {
case 'centralSupply':
return bundleCentralSupply;
case 'mintHolder':
return bundleMintHolder;
case 'smartWallet':
return bundleSmartWallet;
default:
throw new Error(`unknown bundle ${name}`);
}
throw new Error(`unknown bundle ${name}`);
},
}),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/api/src/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { makePaymentActions } from './actions.js';

import '@agoric/store/exported.js';
import '@agoric/zoe/exported.js';
import '@agoric/run-protocol/exported.js';

import './internal-types.js';
import './types.js';
Expand Down Expand Up @@ -582,6 +581,7 @@ export function makeWallet({

const getAttBrand = makeMemoizedGetter(() => E(getAttIssuer()).getBrand());

/** @typedef {any} AttestationTool */ /* @@@ TODO */
Copy link
Member

Choose a reason for hiding this comment

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

before landing or after?

/** @type import('@endo/promise-kit').PromiseKit<AttestationTool> */
const attMakerPK = makePromiseKit();

Expand Down
25 changes: 25 additions & 0 deletions packages/wallet/contract/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",

"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
},
"include": [
"*.js",
"scripts/**/*.js",
"src/**/*.js",
"test/**/*.js",
"tools/**/*.js",
],
}
45 changes: 45 additions & 0 deletions packages/wallet/contract/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@agoric/smart-wallet",
"version": "0.1.1",
"description": "Wallet contract",
"type": "module",
"scripts": {
"build": "exit 0",
"test": "ava",
"test:xs": "exit 0",
"lint": "run-s --continue-on-error lint:*",
"lint-fix": "yarn lint:eslint --fix",
"lint:types": "tsc --maxNodeModuleJsDepth 3 -p jsconfig.json",
"lint:eslint": "eslint ."
},
"devDependencies": {
"ava": "^3.12.1"
},
"dependencies": {
"@agoric/wallet-backend": "0.12.1",
"@agoric/deploy-script-support": "^0.9.0",
"@agoric/zoe": "^0.24.0",
"@agoric/notifier": "^0.4.0",
"@endo/far": "^0.2.3"
},
"keywords": [],
"repository": {
"type": "git",
"url": "git+https://github.com/Agoric/agoric"
},
"author": "Agoric",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Agoric/agoric/issues"
},
"homepage": "https://github.com/Agoric/agoric#readme",
"ava": {
"files": [
"test/**/test-*.js"
],
"timeout": "2m"
},
"publishConfig": {
"access": "public"
}
}
Loading