@agoric/fast-usdc 0.1.1-dev-a2e9363.0 → 0.1.1-dev-1d5cb99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -14
- package/src/exos/settler.js +3 -3
- package/src/exos/status-manager.js +43 -14
- package/src/fast-usdc.contract.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/fast-usdc",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-1d5cb99.0+1d5cb99",
|
|
4
4
|
"description": "CLI and library for Fast USDC product",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"lint:eslint": "eslint ."
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
25
|
-
"@agoric/vats": "0.15.2-dev-
|
|
26
|
-
"@agoric/zone": "0.2.3-dev-
|
|
24
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-1d5cb99.0+1d5cb99",
|
|
25
|
+
"@agoric/vats": "0.15.2-dev-1d5cb99.0+1d5cb99",
|
|
26
|
+
"@agoric/zone": "0.2.3-dev-1d5cb99.0+1d5cb99",
|
|
27
27
|
"@fast-check/ava": "^2.0.1",
|
|
28
28
|
"ava": "^5.3.0",
|
|
29
29
|
"c8": "^10.1.2",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"ts-blank-space": "^0.4.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/client-utils": "0.1.1-dev-
|
|
35
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
36
|
-
"@agoric/internal": "0.3.3-dev-
|
|
37
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
38
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
39
|
-
"@agoric/store": "0.9.3-dev-
|
|
40
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
41
|
-
"@agoric/vow": "0.1.1-dev-
|
|
42
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
34
|
+
"@agoric/client-utils": "0.1.1-dev-1d5cb99.0+1d5cb99",
|
|
35
|
+
"@agoric/ertp": "0.16.3-dev-1d5cb99.0+1d5cb99",
|
|
36
|
+
"@agoric/internal": "0.3.3-dev-1d5cb99.0+1d5cb99",
|
|
37
|
+
"@agoric/notifier": "0.6.3-dev-1d5cb99.0+1d5cb99",
|
|
38
|
+
"@agoric/orchestration": "0.1.1-dev-1d5cb99.0+1d5cb99",
|
|
39
|
+
"@agoric/store": "0.9.3-dev-1d5cb99.0+1d5cb99",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-dev-1d5cb99.0+1d5cb99",
|
|
41
|
+
"@agoric/vow": "0.1.1-dev-1d5cb99.0+1d5cb99",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-1d5cb99.0+1d5cb99",
|
|
43
43
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
44
44
|
"@cosmjs/stargate": "^0.32.4",
|
|
45
45
|
"@endo/base64": "^1.0.9",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "1d5cb990533dd737923e17c9537fe3963b06d5c5"
|
|
82
82
|
}
|
package/src/exos/settler.js
CHANGED
|
@@ -221,7 +221,7 @@ export const prepareSettler = (
|
|
|
221
221
|
repayer.repay(settlingSeat, split);
|
|
222
222
|
|
|
223
223
|
// update status manager, marking tx `SETTLED`
|
|
224
|
-
statusManager.disbursed(txHash
|
|
224
|
+
statusManager.disbursed(txHash);
|
|
225
225
|
},
|
|
226
226
|
/**
|
|
227
227
|
* @param {EvmHash | undefined} txHash
|
|
@@ -248,7 +248,7 @@ export const prepareSettler = (
|
|
|
248
248
|
},
|
|
249
249
|
transferHandler: {
|
|
250
250
|
/**
|
|
251
|
-
* @param {unknown}
|
|
251
|
+
* @param {unknown} _result
|
|
252
252
|
* @param {SettlerTransferCtx} ctx
|
|
253
253
|
*
|
|
254
254
|
* @typedef {{
|
|
@@ -257,7 +257,7 @@ export const prepareSettler = (
|
|
|
257
257
|
* amount: NatValue;
|
|
258
258
|
* }} SettlerTransferCtx
|
|
259
259
|
*/
|
|
260
|
-
onFulfilled(
|
|
260
|
+
onFulfilled(_result, ctx) {
|
|
261
261
|
const { txHash, sender, amount } = ctx;
|
|
262
262
|
statusManager.forwarded(txHash, sender, amount);
|
|
263
263
|
},
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { M } from '@endo/patterns';
|
|
2
2
|
import { Fail, makeError, q } from '@endo/errors';
|
|
3
|
-
|
|
4
3
|
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
|
|
4
|
+
import { E } from '@endo/eventual-send';
|
|
5
|
+
import { makeTracer } from '@agoric/internal';
|
|
5
6
|
import {
|
|
6
7
|
CctpTxEvidenceShape,
|
|
7
8
|
EvmHashShape,
|
|
8
9
|
PendingTxShape,
|
|
9
10
|
} from '../type-guards.js';
|
|
10
|
-
import { PendingTxStatus } from '../constants.js';
|
|
11
|
+
import { PendingTxStatus, TxStatus } from '../constants.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @import {MapStore, SetStore} from '@agoric/store';
|
|
14
15
|
* @import {Zone} from '@agoric/zone';
|
|
15
|
-
* @import {CctpTxEvidence, NobleAddress, SeenTxKey, PendingTxKey, PendingTx, EvmHash} from '../types.js';
|
|
16
|
+
* @import {CctpTxEvidence, NobleAddress, SeenTxKey, PendingTxKey, PendingTx, EvmHash, LogFn} from '../types.js';
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -53,6 +54,12 @@ const seenTxKeyOf = evidence => {
|
|
|
53
54
|
return `seenTx:${JSON.stringify([txHash, chainId])}`;
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {{
|
|
59
|
+
* log?: LogFn;
|
|
60
|
+
* }} StatusManagerPowers
|
|
61
|
+
*/
|
|
62
|
+
|
|
56
63
|
/**
|
|
57
64
|
* The `StatusManager` keeps track of Pending and Seen Transactions
|
|
58
65
|
* via {@link PendingTxStatus} states, aiding in coordination between the `Advancer`
|
|
@@ -61,8 +68,16 @@ const seenTxKeyOf = evidence => {
|
|
|
61
68
|
* XXX consider separate facets for `Advancing` and `Settling` capabilities.
|
|
62
69
|
*
|
|
63
70
|
* @param {Zone} zone
|
|
71
|
+
* @param {() => Promise<StorageNode>} makeStatusNode
|
|
72
|
+
* @param {StatusManagerPowers} caps
|
|
64
73
|
*/
|
|
65
|
-
export const prepareStatusManager =
|
|
74
|
+
export const prepareStatusManager = (
|
|
75
|
+
zone,
|
|
76
|
+
makeStatusNode,
|
|
77
|
+
{
|
|
78
|
+
log = makeTracer('Advancer', true),
|
|
79
|
+
} = /** @type {StatusManagerPowers} */ ({}),
|
|
80
|
+
) => {
|
|
66
81
|
/** @type {MapStore<PendingTxKey, PendingTx[]>} */
|
|
67
82
|
const pendingTxs = zone.mapStore('PendingTxs', {
|
|
68
83
|
keyShape: M.string(),
|
|
@@ -74,6 +89,17 @@ export const prepareStatusManager = zone => {
|
|
|
74
89
|
keyShape: M.string(),
|
|
75
90
|
});
|
|
76
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @param {CctpTxEvidence['txHash']} hash
|
|
94
|
+
* @param {TxStatus} status
|
|
95
|
+
*/
|
|
96
|
+
const recordStatus = (hash, status) => {
|
|
97
|
+
const statusNodeP = makeStatusNode();
|
|
98
|
+
const txnNodeP = E(statusNodeP).makeChildNode(hash);
|
|
99
|
+
// Don't await, just writing to vstorage.
|
|
100
|
+
void E(txnNodeP).setValue(status);
|
|
101
|
+
};
|
|
102
|
+
|
|
77
103
|
/**
|
|
78
104
|
* Ensures that `txHash+chainId` has not been processed
|
|
79
105
|
* and adds entry to `seenTxs` set.
|
|
@@ -95,6 +121,7 @@ export const prepareStatusManager = zone => {
|
|
|
95
121
|
pendingTxKeyOf(evidence),
|
|
96
122
|
harden({ ...evidence, status }),
|
|
97
123
|
);
|
|
124
|
+
recordStatus(evidence.txHash, status);
|
|
98
125
|
};
|
|
99
126
|
|
|
100
127
|
return zone.exo(
|
|
@@ -118,9 +145,7 @@ export const prepareStatusManager = zone => {
|
|
|
118
145
|
M.undefined(),
|
|
119
146
|
),
|
|
120
147
|
),
|
|
121
|
-
disbursed: M.call(EvmHashShape
|
|
122
|
-
M.undefined(),
|
|
123
|
-
),
|
|
148
|
+
disbursed: M.call(EvmHashShape).returns(M.undefined()),
|
|
124
149
|
forwarded: M.call(M.opt(EvmHashShape), M.string(), M.nat()).returns(
|
|
125
150
|
M.undefined(),
|
|
126
151
|
),
|
|
@@ -163,6 +188,7 @@ export const prepareStatusManager = zone => {
|
|
|
163
188
|
: PendingTxStatus.AdvanceFailed;
|
|
164
189
|
const txpost = { ...tx, status };
|
|
165
190
|
pendingTxs.set(key, harden([...prefix, txpost, ...suffix]));
|
|
191
|
+
recordStatus(tx.txHash, status);
|
|
166
192
|
},
|
|
167
193
|
|
|
168
194
|
/**
|
|
@@ -219,12 +245,9 @@ export const prepareStatusManager = zone => {
|
|
|
219
245
|
* Mark a transaction as `DISBURSED`
|
|
220
246
|
*
|
|
221
247
|
* @param {EvmHash} txHash
|
|
222
|
-
* @param {NobleAddress} address
|
|
223
|
-
* @param {bigint} amount
|
|
224
248
|
*/
|
|
225
|
-
disbursed(txHash
|
|
226
|
-
|
|
227
|
-
console.log('TODO: vstorage update', { txHash, address, amount });
|
|
249
|
+
disbursed(txHash) {
|
|
250
|
+
recordStatus(txHash, TxStatus.Disbursed);
|
|
228
251
|
},
|
|
229
252
|
|
|
230
253
|
/**
|
|
@@ -235,8 +258,14 @@ export const prepareStatusManager = zone => {
|
|
|
235
258
|
* @param {bigint} amount
|
|
236
259
|
*/
|
|
237
260
|
forwarded(txHash, address, amount) {
|
|
238
|
-
|
|
239
|
-
|
|
261
|
+
if (txHash) {
|
|
262
|
+
recordStatus(txHash, TxStatus.Forwarded);
|
|
263
|
+
} else {
|
|
264
|
+
// TODO store (early) `Minted` transactions to check against incoming evidence
|
|
265
|
+
log(
|
|
266
|
+
`⚠️ Forwarded minted amount ${amount} from account ${address} before it was observed.`,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
240
269
|
},
|
|
241
270
|
|
|
242
271
|
/**
|
|
@@ -29,6 +29,8 @@ import * as flows from './fast-usdc.flows.js';
|
|
|
29
29
|
|
|
30
30
|
const trace = makeTracer('FastUsdc');
|
|
31
31
|
|
|
32
|
+
const STATUS_NODE = 'status';
|
|
33
|
+
|
|
32
34
|
/**
|
|
33
35
|
* @import {HostInterface} from '@agoric/async-flow';
|
|
34
36
|
* @import {CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount} from '@agoric/orchestration';
|
|
@@ -84,7 +86,9 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
84
86
|
marshaller,
|
|
85
87
|
);
|
|
86
88
|
|
|
87
|
-
const
|
|
89
|
+
const makeStatusNode = () =>
|
|
90
|
+
E(privateArgs.storageNode).makeChildNode(STATUS_NODE);
|
|
91
|
+
const statusManager = prepareStatusManager(zone, makeStatusNode);
|
|
88
92
|
|
|
89
93
|
const { USDC } = terms.brands;
|
|
90
94
|
const { withdrawToSeat } = tools.zoeTools;
|