Skip to content

API documentation of Agoric SDK / Exports / @agoric/smart-wallet / smartWallet

Module: smartWallet

Table of contents

Type Aliases

Variables

Functions

Type Aliases

BrandDescriptor

Ƭ BrandDescriptor: Object

For use by clients to describe brands to users. Includes displayInfo to save a remote call.

Type declaration

NameType
brandBrand
displayInfoDisplayInfo
issuerIssuer
petnametypes

Defined in

smartWallet.js:141


BrandDescriptorRegistry

Ƭ BrandDescriptorRegistry: Pick<MapStore<Brand, BrandDescriptor>, "has" | "get" | "values">

Defined in

smartWallet.js:154


BridgeAction

Ƭ BridgeAction: ExecuteOfferAction | TryExitOfferAction

Defined in

smartWallet.js:92


CurrentWalletRecord

Ƭ CurrentWalletRecord: Object

Type declaration

NameType
liveOffers[OfferId, offers][]
offerToPublicSubscriberPaths[offerId: string, publicTopics: Object][]
offerToUsedInvitation[offerId: string, usedInvitation: Amount][]
purses{ balance: Amount ; brand: Brand }[]

Defined in

smartWallet.js:116


ExecuteOfferAction

Ƭ ExecuteOfferAction: Object

Type declaration

NameType
method"executeOffer"
offerOfferSpec

Defined in

smartWallet.js:78


ExecutorPowers

Ƭ ExecutorPowers: Object

Type declaration

NameType
invitationFromSpecERef<Invitation>
logger{ error: (...args: any[]) => void ; info: (...args: any[]) => void }
logger.error(...args: any[]) => void
logger.info(...args: any[]) => void
makeOfferWatcherMakeOfferWatcher

Defined in

smartWallet.js:71


ImmutableState

Ƭ ImmutableState: Readonly<UniqueParams & { currentRecorderKit: RecorderKit ; liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>> ; liveOfferSeats: MapStore<OfferId, UserSeat<unknown>> ; liveOffers: MapStore<OfferId, offers> ; offerToInvitationMakers: MapStore<string, types> ; offerToPublicSubscriberPaths: MapStore<string, Record<string, string>> ; offerToUsedInvitation: MapStore<string, Amount<"set">> ; paymentQueues: MapStore<Brand, Payment[]> ; purseBalances: MapStore<Purse, Amount> ; updateRecorderKit: RecorderKit }>

Defined in

smartWallet.js:183


MutableState

Ƭ MutableState: Object

Defined in

smartWallet.js:187


OfferId

Ƭ OfferId: number | string

Defined in

smartWallet.js:55


OfferSpec

Ƭ OfferSpec: Object

Type declaration

NameType
idOfferId
invitationSpecinvitations
offerArgs?unknown
proposalProposal

Defined in

smartWallet.js:63


PurseRecord

Ƭ PurseRecord: BrandDescriptor & { purse: Purse }

Defined in

smartWallet.js:185


SharedParams

Ƭ SharedParams: Object

Type declaration

NameType
agoricNamesERef<index>
invitationBrandBrand<"set">
invitationDisplayInfoDisplayInfo
invitationIssuerIssuer<"set">
publicMarshallerMarshaller
registryBrandDescriptorRegistry
secretWalletFactoryKeyany
zoeERef<ZoeService>

Defined in

smartWallet.js:164


SmartWallet

Ƭ SmartWallet: Awaited<ReturnType<ReturnType<typeof prepareSmartWallet>>>

Defined in

smartWallet.js:1198


State

Ƭ State: ImmutableState & MutableState

brandPurses is precious and closely held. defined as late as possible to reduce its scope.

  • offerToInvitationMakers is precious and closely held.
  • offerToPublicSubscriberPaths is precious and closely held.
  • purseBalances is a cache of what we've received from purses. Held so we can publish all balances on change.

Defined in

smartWallet.js:166


TryExitOfferAction

Ƭ TryExitOfferAction: Object

Type declaration

NameType
method"tryExitOffer"
offerIdOfferId

Defined in

smartWallet.js:85


UniqueParams

Ƭ UniqueParams: Object

Type declaration

NameType
addressstring
bankERef<Bank>
currentStorageNodeStorageNode
invitationPursePurse<"set">
walletStorageNodeStorageNode

Defined in

smartWallet.js:152


UpdateRecord

Ƭ UpdateRecord: { status: offers ; updated: "offerStatus" } | { currentAmount: Amount ; updated: "balance" } | { status: { error: string } ; updated: "walletAction" }

Record of an update to the state of this wallet.

Client is responsible for coalescing updates into a current state. See coalesceUpdates utility.

The reason for this burden on the client is that publishing the full history of offers with each change is untenable.

balance update supports forward-compatibility for more than one purse per brand. An additional key will be needed to disambiguate. For now the brand in the amount suffices.

Defined in

smartWallet.js:123

Variables

BRAND_TO_PURSES_KEY

Const BRAND_TO_PURSES_KEY: "brandToPurses"

Defined in

smartWallet.js:226

Functions

prepareSmartWallet

prepareSmartWallet(baggage, shared): (uniqueWithoutChildNodes: Omit<UniqueParams, "currentStorageNode" | "walletStorageNode"> & { walletStorageNode: ERef<StorageNode> }) => Promise<Guarded<{ getCurrentSubscriber: () => Subscriber<CurrentWalletRecord> ; getDepositFacet: () => Guarded<{ receive: (payment: Payment<AssetKind>) => Promise<Amount<AssetKind>> }> ; getOffersFacet: () => Guarded<{ executeOffer: (offerSpec: OfferSpec) => Promise<void> ; tryExitOffer: (offerId: OfferId) => Promise<void> }> ; getPublicTopics: () => { current: { description: string = 'Current state of wallet'; storagePath: Promise<string> ; subscriber: Subscriber<CurrentWalletRecord> = currentRecorderKit.subscriber } ; updates: { description: string = 'Changes to wallet'; storagePath: Promise<string> ; subscriber: Subscriber<UpdateRecord> = updateRecorderKit.subscriber } } ; getUpdatesSubscriber: () => Subscriber<UpdateRecord> ; handleBridgeAction: (actionCapData: CapData<null | string>, canSpend?: boolean) => Promise<void> ; repairWalletForIncarnation2: (key: any) => void }>>

Parameters

NameType
baggageBaggage
sharedSharedParams

Returns

fn

▸ (uniqueWithoutChildNodes): Promise<Guarded<{ getCurrentSubscriber: () => Subscriber<CurrentWalletRecord> ; getDepositFacet: () => Guarded<{ receive: (payment: Payment<AssetKind>) => Promise<Amount<AssetKind>> }> ; getOffersFacet: () => Guarded<{ executeOffer: (offerSpec: OfferSpec) => Promise<void> ; tryExitOffer: (offerId: OfferId) => Promise<void> }> ; getPublicTopics: () => { current: { description: string = 'Current state of wallet'; storagePath: Promise<string> ; subscriber: Subscriber<CurrentWalletRecord> = currentRecorderKit.subscriber } ; updates: { description: string = 'Changes to wallet'; storagePath: Promise<string> ; subscriber: Subscriber<UpdateRecord> = updateRecorderKit.subscriber } } ; getUpdatesSubscriber: () => Subscriber<UpdateRecord> ; handleBridgeAction: (actionCapData: CapData<null | string>, canSpend?: boolean) => Promise<void> ; repairWalletForIncarnation2: (key: any) => void }>>

Parameters
NameType
uniqueWithoutChildNodesOmit<UniqueParams, "currentStorageNode" | "walletStorageNode"> & { walletStorageNode: ERef<StorageNode> }
Returns

Promise<Guarded<{ getCurrentSubscriber: () => Subscriber<CurrentWalletRecord> ; getDepositFacet: () => Guarded<{ receive: (payment: Payment<AssetKind>) => Promise<Amount<AssetKind>> }> ; getOffersFacet: () => Guarded<{ executeOffer: (offerSpec: OfferSpec) => Promise<void> ; tryExitOffer: (offerId: OfferId) => Promise<void> }> ; getPublicTopics: () => { current: { description: string = 'Current state of wallet'; storagePath: Promise<string> ; subscriber: Subscriber<CurrentWalletRecord> = currentRecorderKit.subscriber } ; updates: { description: string = 'Changes to wallet'; storagePath: Promise<string> ; subscriber: Subscriber<UpdateRecord> = updateRecorderKit.subscriber } } ; getUpdatesSubscriber: () => Subscriber<UpdateRecord> ; handleBridgeAction: (actionCapData: CapData<null | string>, canSpend?: boolean) => Promise<void> ; repairWalletForIncarnation2: (key: any) => void }>>

Defined in

smartWallet.js:243