Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a61dddc
feat(smart-wallet): save offer result under given name (WIP)
dckc Apr 12, 2025
df10699
test(boot): save smartWallet offerResult under given name
dckc Apr 12, 2025
e7cf6f1
feat(smart-wallet): evalExpr (WIP)
dckc Apr 11, 2025
f62be3d
test(boot): set price without zoe offer using evalExpr
dckc Apr 12, 2025
89877df
feat: deposit offer result (WIP. NEEDSTEST)
dckc Apr 12, 2025
4be743b
test(boot): deposit Invitation offer result
dckc Apr 12, 2025
1a8d873
fix(vats): work around NameAdmin.readonly() return guard (WIP NEEDSTEST)
dckc Apr 12, 2025
70bc8e7
feat(smart-wallet): endow evalExpr with namesByAddress
dckc Apr 12, 2025
e29aa8f
test(boot): atomicSwap A<->B using smartWallet
dckc Apr 12, 2025
3dc72bf
refactor(boot): use actor style in atomicSwap test
dckc Apr 12, 2025
f2bb402
feat(smartWallet): make nameHub available as my.XYZ
dckc Apr 19, 2025
38bf4cd
feat(smartWallet): after(obj, { rx, method, args })
dckc Apr 19, 2025
ab873a7
test(boot): restart contract via smartWallet; use facet after
dckc Apr 15, 2025
f77d73c
refactor: move wallet-fun test to new dir
dckc Apr 19, 2025
26ed395
WIP: carrier contract
dckc Apr 19, 2025
9739fb1
chore: provide stakingView in walletFactoryContext
dckc Apr 19, 2025
ce2cf3b
refactor(smartWallet): use E.when for after()
dckc Apr 19, 2025
d03544b
feat(smartWallet): publish passStyle of evalExpr result
dckc Apr 19, 2025
5130306
feat(smart-wallet): require 10K staked BLD to evalExpr
dckc Apr 19, 2025
597ce1f
chore(boot): support stakingView in walletDriver
dckc Apr 19, 2025
e3f38fc
test(boot): require staked BLD for evalExpr
dckc Apr 19, 2025
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
2 changes: 1 addition & 1 deletion packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@endo/far": "^1.1.11",
"@endo/init": "^1.1.9",
"@endo/marshal": "^1.6.4",
"@endo/patterns": "^1.5.0",
"@endo/promise-kit": "^1.1.10",
"@endo/stream": "^1.2.10",
"import-meta-resolve": "^4.1.0",
Expand All @@ -60,7 +61,6 @@
"@agoric/store": "^0.9.2",
"@agoric/swingset-liveslots": "^0.10.2",
"@endo/base64": "^1.0.9",
"@endo/patterns": "^1.5.0",
"ava": "^5.3.0",
"c8": "^10.1.2",
"node-fetch-cache": "^4.1.2",
Expand Down
20 changes: 20 additions & 0 deletions packages/boot/test/bootstrapTests/walletFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
makeSwingsetTestKit,
} from '../../tools/supports.js';
import { makeWalletFactoryDriver } from '../../tools/drivers.js';
import type { StakingView } from '@agoric/smart-wallet/src/types.js';

Check failure on line 11 in packages/boot/test/bootstrapTests/walletFactory.ts

View workflow job for this annotation

GitHub Actions / lint-primary

`@agoric/smart-wallet/src/types.js` type import should occur before import of `../../tools/supports.js`
import { mockStakingViewKit } from '../smartWallet/staking-vew.mock.js';

export const makeWalletFactoryContext = async (
t,
Expand Down Expand Up @@ -52,6 +54,24 @@
}
};

{
const produceStakingView = async (
powers: PromiseSpaceOf<{ stakingView: StakingView }>,
) => {
const { view } = mockStakingViewKit();
powers.produce.stakingView.resolve(view);
};

const js_code = `

Check failure on line 65 in packages/boot/test/bootstrapTests/walletFactory.ts

View workflow job for this annotation

GitHub Actions / lint-primary

Identifier 'js_code' is not in camel case
const mockStakingViewKit = (${mockStakingViewKit});
(${produceStakingView})
`;
await swingsetTestKit.evalProposal({
evals: [{ js_code, json_permits: 'true' }],

Check failure on line 70 in packages/boot/test/bootstrapTests/walletFactory.ts

View workflow job for this annotation

GitHub Actions / lint-primary

Identifier 'js_code' is not in camel case
bundles: [],
});
}

const walletFactoryDriver = await makeWalletFactoryDriver(
runUtils,
storage,
Expand Down
15 changes: 15 additions & 0 deletions packages/boot/test/smartWallet/staking-vew.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { StakingView } from '@agoric/smart-wallet/src/types.ts';
import { Far } from '@endo/marshal';

// NOTE: only coreEval scope (e.g. Far) allowed
export const mockStakingViewKit = () => {
const view: StakingView = Far('StakingView', {
get: addr => {
assert.typeof(addr, 'string'); // no exo guard
const qty = BigInt((addr.match(/\d+/g) || []).join(''));
// console.debug(addr, 'stake:', qty);
return qty;
},
});
return { view }; // leave room for write facet
};
44 changes: 44 additions & 0 deletions packages/boot/test/smartWallet/wallet-fun-carrier.contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** @file contract to pass a capability to an admin */
import { makeTracer } from '@agoric/internal';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { M } from '@endo/patterns';

const trace = makeTracer('WFun2');

const meta = {
privateArgsShape: { prize: M.record() },
};
harden(meta);

/**
* @template {Record<string, unknown>} P
* @param {ZCF} zcf
* @param {{ prize: P }} privateArgs
* @param {import("@agoric/swingset-liveslots").Baggage} baggage
*/
export const start = (zcf, { prize }, baggage) => {
const zone = makeDurableZone(baggage);
const creatorFacet = zone.exo(
'cf',
M.interface('cf', {
makeInvitation: M.callWhen().returns(M.remotable('Invitation')),
}),
{
makeInvitation() {
return zcf.makeInvitation(
seat => {
trace('admin invitation handler');
seat.exit();
zcf.shutdown();
return prize;
},
'admin',
undefined,
harden(M.splitRecord({ give: {}, want: {} })),
);
},
},
);
return { creatorFacet };
};
harden(start);
91 changes: 91 additions & 0 deletions packages/boot/test/smartWallet/wallet-fun.contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/** @file contract that can invite participants to set prices */
import { makeTracer } from '@agoric/internal';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { M } from '@endo/patterns';

const trace = makeTracer('WFun');

/**
* @param {ZCF} zcf
* @param {unknown} _pa
* @param {import('@agoric/swingset-liveslots').Baggage} baggage
*/
export const start = (zcf, _pa, baggage) => {
const zone = makeDurableZone(baggage);
const incarnation = (() => {
if (!baggage.has('incarnation')) {
baggage.init('incarnation', 0n);
return 0n;
}
const post = /** @type {bigint} */ (baggage.get('incarnation')) + 1n;
baggage.set('incarnation', post);
return post;
})();

/** @type {import('@agoric/store').SetStore<ReturnType<typeof makeAdmin>>} */
const admins = zone.setStore('admins');

const publicFacet = zone.exo(
'pf',
M.interface('pf', {
getIncarnation: M.call().returns(M.nat()),
getPrices: M.call().returns(M.arrayOf(M.nat())),
}),
{
getIncarnation() {
return incarnation;
},
getPrices() {
return [...admins.values()].map(a => a.getPrice());
},
},
);

const makeAdmin = zone.exoClass(
'Admin',
M.interface('Admin', {
getPrice: M.call().returns(M.nat()),
setPrice: M.call(M.nat()).returns(),
}),
() => ({ price: 0n }),
{
getPrice() {
return this.state.price;
},
/** @param {import('@agoric/ertp').NatValue} p */
setPrice(p) {
this.state.price = p;
console.log('price', p);
},
},
);

const creatorFacet = zone.exo(
'cf',
M.interface('cf', {
makeAdminInvitation: M.callWhen().returns(M.remotable('Invitation')),
}),
{
makeAdminInvitation() {
return zcf.makeInvitation(
seat => {
trace('admin invitation handler', { incarnation });
const it = makeAdmin();
admins.add(it);
seat.exit();
return it;
},
'admin',
undefined,
harden(M.splitRecord({ give: {}, want: {} })),
);
},
},
);

return {
publicFacet,
creatorFacet,
};
};
harden(start);
Loading
Loading