forked from alexanderem49/simple-exchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleExchange-proposal.js
77 lines (68 loc) · 1.84 KB
/
simpleExchange-proposal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { E } from '@endo/far';
export const initSimpleExchange = async (powers) => {
const {
consume: { zoe, board, chainStorage, agoricNames },
produce: { simpleExchangeKit },
installation: {
consume: { simpleExchangeInstallation },
},
instance: {
produce: { simpleExchangeInstance },
},
} = powers;
const marshaller = await E(board).getPublishingMarshaller();
const storageNode = await E(chainStorage).makeChildNode('simpleExchange');
const assetIssuer = await E(agoricNames).lookup('issuer', 'BLD');
const priceIssuer = await E(agoricNames).lookup('issuer', 'IST');
const issuerKeywordRecord = harden({
Asset: assetIssuer,
Price: priceIssuer,
});
const privateArgs = harden({ marshaller, storageNode });
const installation = await simpleExchangeInstallation;
const instanceFacets = await E(zoe).startInstance(
installation,
issuerKeywordRecord,
undefined,
privateArgs,
'simpleExchange',
);
simpleExchangeKit.reset();
simpleExchangeKit.resolve(instanceFacets);
simpleExchangeInstance.reset();
simpleExchangeInstance.resolve(instanceFacets.instance);
};
export const getManifestForInitSimpleExchange = async (
{ restoreRef },
{ contractRef },
) =>
harden({
manifest: {
[initSimpleExchange.name]: {
consume: {
zoe: 'zoe',
board: true,
chainStorage: true,
agoricNames: true,
},
produce: {
simpleExchangeKit: true,
},
installation: {
consume: {
simpleExchangeInstallation: true,
},
},
instance: {
produce: {
simpleExchangeInstance: true,
},
},
issuer: {},
brand: {},
},
},
installations: {
simpleExchangeInstallation: restoreRef(contractRef),
},
});