-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathfeeMint.js
53 lines (45 loc) · 1.3 KB
/
feeMint.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
// @ts-check
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import { makeHandle } from '../makeHandle.js';
const { details: X } = assert;
/**
* @param {FeeIssuerConfig} feeIssuerConfig
* @param {ShutdownWithFailure} shutdownZoeVat
* @returns {{
* feeMintAccess: FeeMintAccess,
* getFeeIssuerKit: GetFeeIssuerKit,
* feeIssuer: Issuer,
* feeBrand: Brand,
* initialFeeFunds: Payment,
* }}
*/
const createFeeMint = (feeIssuerConfig, shutdownZoeVat) => {
/** @type {IssuerKit} */
const feeIssuerKit = makeIssuerKit(
feeIssuerConfig.name,
feeIssuerConfig.assetKind,
feeIssuerConfig.displayInfo,
shutdownZoeVat,
);
/** @type {FeeMintAccess} */
const feeMintAccess = makeHandle('feeMintAccess');
/** @type {GetFeeIssuerKit} */
const getFeeIssuerKit = allegedFeeMintAccess => {
assert(
feeMintAccess === allegedFeeMintAccess,
X`The object representing access to the fee brand mint was not provided`,
);
return feeIssuerKit;
};
const initialFeeFunds = feeIssuerKit.mint.mintPayment(
AmountMath.make(feeIssuerKit.brand, feeIssuerConfig.initialFunds),
);
return harden({
feeMintAccess,
getFeeIssuerKit,
feeIssuer: feeIssuerKit.issuer,
feeBrand: feeIssuerKit.brand,
initialFeeFunds,
});
};
export { createFeeMint };