Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pay ui #45

Merged
merged 4 commits into from
Jun 4, 2024
Merged

feat: pay ui #45

merged 4 commits into from
Jun 4, 2024

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented May 22, 2024

fixes Agoric/documentation#1001
fixes #46

The UI is almost a copy-paste of the swap UI with the "Want" removed and a different makeOffer call.

Changed the postal service contract to be able to add issuers from invitation args, so swapping tickets works (#46)

Also removed an unused vbank query and added contract/,tx.json to gitignore.

Screenshot

image

@samsiegart samsiegart requested a review from dckc May 29, 2024 06:05
@samsiegart
Copy link
Contributor Author

Adding @dckc as a reviewer for the contract bits

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract change for issuers looks good except that issuerNumber shouldn't be static mutable state.

assert.typeof(recipient, 'string');
mustMatch(issuers, M.arrayOf(IssuerShape));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider making the issuers arg optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI is always just going to send the issuers anyway so it doesn't seem worth the complexity. We'd have to query and check which issuers are already added first, I'm not sure if they're published anywhere either.

@@ -12,16 +12,18 @@ export const meta = harden({
// compatibility with an earlier contract metadata API
export const { customTermsShape } = meta;

let issuerNumber = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this inside start(), please. No static mutable state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered making it durable, but saw that this was what the swap contract does already ,so I figured it's not critical to preserve the issuer numbers. Is no static mutable state a hard rule? I can update it in both contracts if needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update it in both contracts if needed.

Please do.

Is no static mutable state a hard rule?

It's part of OCap Discipline that isn't (yet?) enforced by our platform.

SES lockdown docs say:

SES introduces the lockdown() function. Calling lockdown() alters the surrounding execution environment, or realm, such that no two programs running in the same realm can observe or affect each other until they have been introduced, and even then can only interact through their own exposed interfaces.

But that's not quite true: SES doesn't (yet?) get rid of module-level static mutable state such as

let callCount = 0;

export const complementaryColor = _ => {
  callCount += 1;
  return 'green';
}

export const colorCallCount = () => callCount;

So one program could do

import { complementaryColor } from './fun-stuff.js';

console.log(complementaryColor('blue');

and another could do

import { colorCallCount } from './fun-stuff.js`;

console.log('there have been', colorCallCount(), 'calls to complementaryColor');

cc @kriskowal @erights

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in the postal service contract is durable, so that would be above end beyond the call of duty here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what you mean, move it into the function scope but don't necessarily make it durable. Done.

@@ -12,16 +12,18 @@ export const meta = harden({
// compatibility with an earlier contract metadata API
export const { customTermsShape } = meta;

let issuerNumber = 1;
const IssuerShape = M.remotable('Issuer');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import from ertp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I did a deep import because of a comment in the swap contract about minimizing bundle size.

@@ -44,15 +40,9 @@ export const startPostalService = async (powers, config) => {
const namesByAddress = await fixHub(namesByAddressAdmin);
const terms = harden({ namesByAddress });

const issuerKeywordRecord = await allValues(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regression is a little surprising. But I guess I don't mind too much.

@samsiegart samsiegart requested a review from dckc May 29, 2024 18:19
Copy link

@Jovonni Jovonni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🚀

thought: since we have docs for our templates, should we consider including descriptions where we use @param etc, then we can just generate the docs for our templates. I know we use it for type reasons primarily.

@samsiegart
Copy link
Contributor Author

thought: since we have docs for our templates, should we consider including descriptions where we use @param etc, then we can just generate the docs for our templates. I know we use it for type reasons primarily.

This is a good option to have, but I don't have a vision of which docs we'd want to generate for this specifically. It's more useful for component libraries, but we can't import parts of dapp-agoric-basics in another project.

@samsiegart samsiegart merged commit 3729be1 into main Jun 4, 2024
2 checks passed
@samsiegart samsiegart deleted the pay-ui branch June 4, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postal service limited to issuers from startInstance How to Pay Someone aka Transfer (Wireframe + UI)
3 participants