-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
127 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
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
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 |
---|---|---|
@@ -1,13 +1,53 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { prepareDurablePublishKit } from '@agoric/notifier'; | ||
import { M } from '@endo/patterns'; | ||
import { CctpTxEvidenceShape } from '../typeGuards.js'; | ||
|
||
/** | ||
* @import {Zone} from '@agoric/zone'; | ||
* @import {CctpTxEvidence} from '../types.js'; | ||
*/ | ||
|
||
const trace = makeTracer('TxFeed', true); | ||
|
||
export const INVITATION_MAKERS_DESC = 'transaction oracle invitation'; | ||
|
||
const TransactionFeedKitI = harden({ | ||
admin: M.interface('Transaction Feed Admin', { | ||
submitEvidence: M.call(CctpTxEvidenceShape).returns(), | ||
}), | ||
public: M.interface('Transaction Feed Public', { | ||
getEvidenceStream: M.call().returns(M.remotable()), | ||
}), | ||
}); | ||
|
||
/** | ||
* @param {Zone} zone | ||
*/ | ||
export const prepareTransactionFeed = zone => { | ||
return zone.exo('Fast USDC Feed', undefined, {}); | ||
export const prepareTransactionFeedKit = zone => { | ||
const kinds = zone.mapStore('Kinds'); | ||
const makeDurablePublishKit = prepareDurablePublishKit( | ||
kinds, | ||
'Transaction Feed', | ||
); | ||
/** @type {PublishKit<CctpTxEvidence>} */ | ||
const { publisher, subscriber } = makeDurablePublishKit(); | ||
|
||
return zone.exoClassKit('Fast USDC Feed', TransactionFeedKitI, () => ({}), { | ||
admin: { | ||
/** @param {CctpTxEvidence } evidence */ | ||
submitEvidence: evidence => { | ||
trace('TEMPORARY: Add evidence:', evidence); | ||
// TODO decentralize | ||
// TODO validate that it's valid to publish | ||
publisher.publish(evidence); | ||
}, | ||
}, | ||
public: { | ||
getEvidenceStream: () => subscriber, | ||
}, | ||
}); | ||
}; | ||
harden(prepareTransactionFeed); | ||
harden(prepareTransactionFeedKit); | ||
|
||
/** @typedef {ReturnType<typeof prepareTransactionFeed>} TransactionFeed */ | ||
/** @typedef {ReturnType<typeof prepareTransactionFeedKit>} TransactionFeedKit */ |
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
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
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,11 @@ | ||
// Must be first to set up globals | ||
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import { makeHeapZone } from '@agoric/zone'; | ||
import { prepareTransactionFeedKit } from '../../src/exos/transaction-feed.js'; | ||
|
||
test('basics', t => { | ||
const zone = makeHeapZone(); | ||
const kit = prepareTransactionFeedKit(zone); | ||
t.deepEqual(Object.values(kit), []); | ||
}); |
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