How does Smart-Wallet work? #6934
-
Hello 👋 I am trying to understand how the
Tagging you here @dckc like you said in the office hours. Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
That API is based on general-purpose object messaging between an off-chain persistent vats (such as in
The smart wallet is not directly relevant to deployment at this time.
The first 2 steps are permissionless: The other 2 steps involve executing JS on-chain:
It's possible that the BLDer DAO will delegate the more on the other questions separately... |
Beta Was this translation helpful? Give feedback.
-
No, in this case "storage" refers to browser
via agoric-sdk/golang/cosmos/proto/agoric/swingset/msgs.proto Lines 16 to 17 in 7cd4bcf Clients Compose, Sign, and Broadcast Smart Wallet OffersThe smart wallet UI helps the user compose such messages and then hands off to keplr to sign and broadcast: Now what goes in that It's perhaps easier to study CLI code. In agoric-cli/test/agops-perf-smoketest.sh we have:
The code to make such an offer is... /**
* @param {Instance} instance
* @param {Record<string, Brand>} brands
* @param {{ offerId: number, feePct?: number } &
* ({ wantMinted: number | undefined, giveMinted: number | undefined })} opts
* @returns {BridgeAction}
*/
export const makePSMSpendAction = (instance, brands, opts) => {
const method = opts.wantMinted
? 'makeWantMintedInvitation'
: 'makeGiveMintedInvitation'; // ref psm.js
const proposal = makePSMProposal(
brands,
opts,
opts.feePct ? opts.feePct / 100 : undefined,
// @ts-expect-error please update types. Not sure where pair goees.
opts.pair[1],
);
console.warn('psm spend give', proposal.give);
console.warn('psm spend want', proposal.want);
// NB: not really a Proposal because the brands are not remotes
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
// mustMatch(harden(proposal), ProposalShape);
/** @type {OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
source: 'contract',
instance,
publicInvitationMaker: method,
},
proposal,
};
/** @type {BridgeAction} */
const spendAction = {
method: 'executeOffer',
offer,
};
return harden(spendAction);
}; where export const makePSMProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
...
return {
give: {
In: { brand: brand.in, value: adjusted.in },
},
want: {
Out: { brand: brand.out, value: adjusted.out },
},
}; Then Smart Wallet Contract executes offers from
|
Beta Was this translation helpful? Give feedback.
-
a "big picture" of smart-wallet style apps is now in the docs: Smart Wallet Dapp Architecture sequenceDiagram
actor client
box aqua Cosmos SDK layer
participant chain
end
box darksalmon Hardened JS VM
participant walletFactory
participant zoe
participant contract
end
client->>chain: Offer tx
chain->>walletFactory: Offer Spec
walletFactory->>+zoe: Offer
walletFactory-->>chain: Offer status
client->>+chain: vstorage query
chain-->>-client: Offer status
zoe->>+contract: Proposal
contract-->>-zoe: reallocations
zoe-->>-walletFactory: payouts
walletFactory-->>chain: Offer status
client->>+chain: vstorage query
chain-->>-client: Offer status
while drafting it, I (ab)used github's nifty support for hosting images in comments... diagram draftssuccessive elaboration: sequenceDiagram
box Zoe API (simplified)
actor client
participant zoe
participant contract
end
client->>+zoe: offer(invitation, {give, want}, pmts)
zoe->>+contract: {give, want}
contract-->>-zoe: reallocate()
zoe-->>-client: payout pmts
sequenceDiagram
box Zoe API (simplified)
actor client
participant zoe
participant contract
end
client->>contract: makeTradeInvitation()
contract-->>zoe: makeInvitation('trade')
zoe-->>client: invitation
submitting offers in cosmos Protobuf messages: sequenceDiagram
actor client
box aqua Cosmos SDK layer
participant chain
end
box darksalmon Hardened JS VM
participant walletFactory
participant zoe
participant contract
end
client->>chain: Offer tx
chain->>walletFactory: Offer Spec
walletFactory->>zoe: Offer
zoe->>+contract: Proposal
contract-->>-zoe: reallocations
zoe-->>walletFactory: payouts
aux info in vstorage: sequenceDiagram
actor client
box aqua Cosmos SDK layer
participant chain
end
box darksalmon Hardened JS VM
participant contract
end
contract-->>chain: aux info
client->>chain: vstorage query
chain-->>client: aux info
invitationSpec sequenceDiagram
box darksalmon Hardened JS VM
participant walletFactory
participant zoe
participant contract
end
walletFactory->>contract: makeBattleInvitation('troll')
contract-->>zoe: makeInvitation(...)
zoe-->>walletFactory: invitation
screenshot vstorage screenshot: |
Beta Was this translation helpful? Give feedback.
-
This just in... @samsiegart made a simple smart wallet app (context: Agoric/ui-kit#37 ). |
Beta Was this translation helpful? Give feedback.
a "big picture" of smart-wallet style apps is now in the docs: Smart Wallet Dapp Architecture