Skip to content

Commit

Permalink
Merge pull request #1168 from Agoric/revert-1166-changes
Browse files Browse the repository at this point in the history
Revert "Fix dapp tutorial intro" accidental changes to #1140
  • Loading branch information
amessbee authored Aug 6, 2024
2 parents 2db92e1 + 49c7215 commit 1bcb3be
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 2 deletions.
25 changes: 25 additions & 0 deletions main/guides/ertp/assets/ertp-interfaces-1.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "ERTP: Mint, Issuer, Brand"
---
classDiagram
class IssuerKit
IssuerKit "1" *-- "1" Mint
IssuerKit "1" *-- "1" Issuer
IssuerKit "1" *-- "1" Brand

class ertp["@agoric/ertp"] {
makeIssuerKit() IssuerKit
...
}
ertp --> IssuerKit : makeIssuerKit

class Mint {
getIssuer()
}
Mint --> Issuer: getIssuer
class Issuer {
getBrand()
}
Issuer --> Brand: getBrand
class Brand
```
1 change: 1 addition & 0 deletions main/guides/ertp/assets/ertp-interfaces-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions main/guides/ertp/assets/ertp-interfaces-2.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "ERTP: Amount, Payment, Purse"
---
classDiagram
class IssuerKit
IssuerKit "1" *-- "1" Mint
IssuerKit "1" *-- "1" Issuer
IssuerKit "1" *-- "1" Brand

class ertp["@agoric/ertp"] {
makeIssuerKit() IssuerKit
AmountMath
...
}
ertp *-- AmountMath : import
class AmountMath {
make(brand: Brand, value) Amount
}
ertp --> IssuerKit : makeIssuerKit
AmountMath --> Amount : make

class Mint {
getIssuer()
mintPayment(amount: Amount)
}
Mint --> Issuer: getIssuer
Mint --> Payment : mintPayment
class Issuer {
getBrand()
makeEmptyPurse()
getAmountOf(payment: Payment)
}
Issuer --> Brand: getBrand
Issuer --> Purse: makeEmptyPurse()
Issuer "1" *-- "many" Payment
Payment
class Brand
class Payment
class Amount {
brand: Brand
value: Value
}
class Purse {
+getCurrentAmount()
+deposit(payment: Payment, expectedAmount?: Amount)
+withdraw(amount: Amount)
}
Purse --> Payment : withdraw
```
1 change: 1 addition & 0 deletions main/guides/ertp/assets/ertp-interfaces-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions main/guides/ertp/assets/ertp-interfaces-3.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "ERTP: Fungible and Non-Fungible Assets"
---
classDiagram
class IssuerKit~Kind~
IssuerKit "1" *-- "1" Mint~Kind~
IssuerKit "1" *-- "1" Issuer~Kind~
IssuerKit "1" *-- "1" Brand~Kind~

class ertp["@agoric/ertp"] {
makeIssuerKit() IssuerKit
AmountMath
AssetKind
}
ertp *-- AmountMath : import
ertp *-- AssetKind : import
class AmountMath {
make(brand: Brand~K~, value~K~) Amount~K~
}
ertp --> IssuerKit~K~ : makeIssuerKit
AmountMath --> Amount~K~ : make

class Mint~Kind~ {
getIssuer()
mintPayment(amount: Amount~Kind~)
}
Mint --> Issuer: getIssuer
Mint --> Payment~Kind~ : mintPayment
class Issuer~Kind~ {
getBrand()
makeEmptyPurse()
getAmountOf(payment: Payment)
}
Issuer --> Brand: getBrand
Issuer --> Purse~Kind~: makeEmptyPurse()
Issuer "1" *-- "many" Payment
Payment
class Brand~Kind~
class Payment~Kind~
class Amount~Kind~ {
brand: Brand~Kind~
value: Value~Kind~
}
class Purse~Kind~ {
+getCurrentAmount()
+deposit(payment: Payment~Kind~, expectedAmount?: Amount~Kind~)
+withdraw(amount: Amount~Kind~)
}
Purse --> Payment : withdraw

class AssetKind {
NAT // fungible
COPY_BAG // non-fungible
...
}
<<Enumeration>> AssetKind
```
1 change: 1 addition & 0 deletions main/guides/ertp/assets/ertp-interfaces-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions main/guides/ertp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ So, using the fictional currency Quatloos, you could have an asset described as
where `400n` is the `value` and `Quatloos` is the `brand`. For now, we'll just look at fungible assets
whose values have to be non-negative integers represented as BigInts (thus the appended "n" on that `value`).

![ERTP object relationships](./assets/ertp-interfaces-3.svg)

### AmountMath

ERTP uses the **[AmountMath](./amount-math)** library for operations such as adding, subtracting,
Expand All @@ -70,14 +72,15 @@ one-to-one relationships with each other.
is used to validate `payments` received from untrusted parties for the `brand` with which
it is associated.

![ERTP object relationships](./assets/relationships1.svg)
<!-- ![ERTP object relationships](./assets/relationships1.svg) -->

Let's look at an example. Suppose there is the "Quatloos" `brand`. That means there is also:
- A "Quatloos `mint`" that is the only ERTP `mint` that can ever create new Quatloos assets.
- A "Quatloos `issuer`" that is the only `issuer` that can create a new `purse` to contain Quatloos and
operate on a `payment` containing Quatloos.

![ERTP object relationships 2](./assets/relationships2.svg)
<!-- ![ERTP object relationships 2](./assets/relationships2.svg) -->
![ERTP object relationships 2](./assets/ertp-interfaces-1.svg){ width=200 height=200 }

### Purses and Payments

Expand All @@ -95,6 +98,8 @@ Quatloos purse or Quatloos payment, it can never hold anything other than Quatlo
However, these are not one-to-one relationships. There can be thousands or more
`purses` or `payments` that hold Quatloos or any other `brand`.

![ERTP object relationships](./assets/ertp-interfaces-2.svg)

## Method Naming Structure

ERTP methods use a template for their names. Knowing what a particular method name prefix represents
Expand Down

0 comments on commit 1bcb3be

Please sign in to comment.