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
// @ts-check | |
import { E } from '@agoric/eventual-send'; | |
import { assert, details } from '@agoric/assert'; | |
import { trade } from '../contractSupport'; | |
import '../../exported'; | |
/** | |
* This OTC Desk contract does not assume that the underlying assets |
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
/* eslint-disable no-use-before-define */ | |
import harden from '@agoric/harden'; | |
import produceIssuer from '@agoric/ertp'; | |
//import { makeZoeHelpers } from './contractSupport'; | |
import { makeZoeHelpers, defaultAcceptanceMsg } from '@agoric/zoe/src/contractSupport'; | |
// zcf is the Zoe Contract Facet, i.e. the contract-facing API of Zoe | |
export const makeContract = harden(zcf => { | |
const helpers = makeZoeHelpers(zcf); | |
const { assertKeywords, checkHook, swap } = helpers; |
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
const offerHook = userOfferHandle => { | |
const ticketsAmount = baytownBucks(1000); | |
const ticketsPayment = baytownBucksMint.mintPayment(ticketsAmount); | |
let tempContractHandle; | |
const contractSelfInvite = zcf.makeInvitation( | |
offerHandle => (tempContractHandle = offerHandle), | |
); | |
zcf | |
.getZoeService() | |
.offer( |
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
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Run Test", |
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
const refundOk = payoutRules.every((payoutRule, i) => { | |
if (payoutRule.kind === 'offer') { | |
return extentOpsArray[i].includes( | |
extents[i], | |
payoutRule.units.extent | |
); | |
} | |
return true; | |
}); |
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
function without(whole, part) { | |
insist(listExtentOps.includes(whole, part))`part is not in whole`; | |
const wholeMinusPart = []; | |
for (const wholeElement of whole) { | |
if (!includesElement(part, wholeElement)) { | |
wholeMinusPart.push(wholeElement); | |
} | |
} | |
return harden(wholeMinusPart); | |
} |
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
const makeNatExtentOps = () => { | |
insistKind: Nat, | |
empty: _ => 0, | |
isEmpty: nat => nat === 0, | |
includes: (whole, part) => whole >= part, | |
equals: (left, right) => left === right, | |
with: (left, right) => Nat(left + right), | |
without: (whole, part) => Nat(whole - part), | |
}; |
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
// Alice withdraws a payment for Bob from her purse. | |
import { makeMint } from '@agoric/ertp/core/mint'; | |
const bucksMint = makeMint('bucks'); | |
const purse = bucksMint.mint(1000, `alice's purse`); | |
const paymentForBob = purse.withdraw(10, `bob's money`); | |
// The particular methods of the bobsAgent object are up to Bob. | |
bobsAgent.receivePayment(paymentForBob); | |
// Bob receives an alleged payment from Alice. | |
// Bob claims it exclusively and validates it |
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
const offerRules = harden({ | |
payoutRules: [ | |
{ | |
kind: 'want', | |
units: tickets(1), | |
}, | |
{ | |
kind: 'offer', | |
units: dollars(10), | |
}, |
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
export const makeContract = (zoe, terms) => { | |
return { | |
instance: { | |
makeOffer: async escrowReceipt => { | |
const { offerHandle } = await zoe.burnEscrowReceipt(escrowReceipt); | |
zoe.complete([offerHandle]); | |
}, | |
}, | |
assays: terms.assays, | |
}; |
NewerOlder