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

Organize request and response models vs. internal models #109

Open
callebtc opened this issue Feb 23, 2024 · 2 comments · Fixed by #153
Open

Organize request and response models vs. internal models #109

callebtc opened this issue Feb 23, 2024 · 2 comments · Fixed by #153
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@callebtc
Copy link
Contributor

src/model/types/index.ts hold all models – for the API And for internal representations without any particular ordering. Models should ideally be sorted together into these two categories or be even defined in separate files.

@callebtc callebtc added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Feb 23, 2024
@andrew-weber
Copy link

I think think this issue is very important. I am still learning my way through this repo, but so far I've spent a lot of time creating a mental map of the different models with nearly identical names.

As an example

This is from the Readme.md

async function invoiceHasBeenPaid() {
	const { proofs } = await wallet.requestTokens(200, hash);
	//Encoded proofs can be spent at the mint
	const encoded = getEncodedToken({
		token: [{ mint: '{MINT_URL}', proofs }]
	});
	console.log(encoded);
}

Here's the source for getEncodedToken

function getEncodedToken(token: Token): string {
	return TOKEN_PREFIX + TOKEN_VERSION + encodeJsonToBase64(token);
}

Here's the model Token definition:

export type Token = {
	/**
	 * token entries
	 */
	token: Array<TokenEntry>;
	/**
	 * a message to send along with the token
	 */
	memo?: string;
};

and heres the TokenEntry definition:

**export type TokenEntry = {
	/**
	 * a list of proofs
	 */
	proofs: Array<Proof>;
	/**
	 * the mints URL
	 */
	mint: string;
};**

Somewhere in here, I think we'd benefit from drawing differences between <Token> & <TokenEntry>. Also I think it's confusing to stay <Token>'s only required field is token: Array<TokenEntry>, are they tokens or tokenEntries?.

@cjbeery24
Copy link

@callebtc Pull request here.
#153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants