-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- retriable that withdraws payments (described by an IssuerKeywordRecord) from a LCA to a user seat
- Loading branch information
1 parent
d8a78d4
commit 55abd1d
Showing
5 changed files
with
778 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/orchestration/test/fixtures/zoe-tools.contract.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* @file Testing fixture that takes shortcuts to ensure we hit error paths | ||
* around `zoeTools.localTransfer` and `zoeTools.withdrawToSeat` | ||
*/ | ||
|
||
import { makeSharedStateRecord } from '@agoric/async-flow'; | ||
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js'; | ||
import { E } from '@endo/far'; | ||
import { M } from '@endo/patterns'; | ||
import { withOrchestration } from '../../src/utils/start-helper.js'; | ||
import { prepareChainHubAdmin } from '../../src/exos/chain-hub-admin.js'; | ||
import * as flows from './zoe-tools.flows.js'; | ||
import fetchedChainInfo from '../../src/fetched-chain-info.js'; | ||
|
||
const { values } = Object; | ||
|
||
/** | ||
* @import {TimerService} from '@agoric/time'; | ||
* @import {LocalChain} from '@agoric/vats/src/localchain.js'; | ||
* @import {NameHub} from '@agoric/vats'; | ||
* @import {Remote} from '@agoric/vow'; | ||
* @import {Zone} from '@agoric/zone'; | ||
* @import {AssetInfo} from '@agoric/vats/src/vat-bank.js'; | ||
* @import {CosmosInterchainService} from '@agoric/orchestration'; | ||
* @import {OrchestrationTools} from '../../src/utils/start-helper.js'; | ||
*/ | ||
|
||
/** | ||
* @typedef {{ | ||
* localchain: Remote<LocalChain>; | ||
* orchestrationService: Remote<CosmosInterchainService>; | ||
* storageNode: Remote<StorageNode>; | ||
* timerService: Remote<TimerService>; | ||
* agoricNames: Remote<NameHub>; | ||
* }} OrchestrationPowers | ||
*/ | ||
|
||
/** | ||
* @param {ZCF} zcf | ||
* @param {OrchestrationPowers & { | ||
* marshaller: Marshaller; | ||
* }} privateArgs | ||
* @param {Zone} zone | ||
* @param {OrchestrationTools} tools | ||
*/ | ||
const contract = async ( | ||
zcf, | ||
privateArgs, | ||
zone, | ||
{ chainHub, orchestrateAll, zoeTools }, | ||
) => { | ||
const contractState = makeSharedStateRecord( | ||
/** @type {{ account: OrchestrationAccount<any> | undefined }} */ { | ||
localAccount: undefined, | ||
}, | ||
); | ||
|
||
const creatorFacet = prepareChainHubAdmin(zone, chainHub); | ||
|
||
const orchFns = orchestrateAll(flows, { | ||
zcf, | ||
contractState, | ||
zoeTools, | ||
}); | ||
|
||
// register assets in ChainHub ourselves, | ||
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9752 | ||
const assets = /** @type {AssetInfo[]} */ ( | ||
await E(E(privateArgs.agoricNames).lookup('vbankAsset')).values() | ||
); | ||
for (const chainName of ['agoric', 'cosmoshub']) { | ||
chainHub.registerChain(chainName, fetchedChainInfo[chainName]); | ||
} | ||
for (const brand of values(zcf.getTerms().brands)) { | ||
const info = assets.find(a => a.brand === brand); | ||
if (info) { | ||
chainHub.registerAsset(info.denom, { | ||
// we are only registering agoric assets, so safe to use denom and | ||
// hardcode chainName | ||
baseDenom: info.denom, | ||
baseName: 'agoric', | ||
chainName: 'agoric', | ||
brand, | ||
}); | ||
} | ||
} | ||
|
||
const publicFacet = zone.exo( | ||
'Zoe Tools Test PF', | ||
M.interface('Zoe Tools Test PF', { | ||
makeDepositSendInvitation: M.callWhen().returns(InvitationShape), | ||
makeDepositInvitation: M.callWhen().returns(InvitationShape), | ||
makeWithdrawInvitation: M.callWhen().returns(InvitationShape), | ||
}), | ||
{ | ||
makeDepositSendInvitation() { | ||
return zcf.makeInvitation(orchFns.depositSend, 'depositSend'); | ||
}, | ||
makeDepositInvitation() { | ||
return zcf.makeInvitation(orchFns.deposit, 'deposit'); | ||
}, | ||
makeWithdrawInvitation() { | ||
return zcf.makeInvitation(orchFns.withdraw, 'withdraw'); | ||
}, | ||
}, | ||
); | ||
|
||
return { publicFacet, creatorFacet }; | ||
}; | ||
|
||
export const start = withOrchestration(contract); | ||
harden(start); |
Oops, something went wrong.