-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from greymass/dev
Next Release
- Loading branch information
Showing
43 changed files
with
1,565 additions
and
239 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
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,13 @@ | ||
<script lang="ts"> | ||
import Code from '../code.svelte'; | ||
interface Props { | ||
data: Record<string, unknown>; | ||
} | ||
let props: Props = $props(); | ||
</script> | ||
|
||
{#if props.data} | ||
<Code>{JSON.stringify(props.data, null, 2)}</Code> | ||
{/if} |
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
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,78 @@ | ||
<script lang="ts"> | ||
import { PublicKey } from '@wharfkit/antelope'; | ||
import type { ComponentProps } from 'svelte'; | ||
import TextInput from './text.svelte'; | ||
interface PublicKeyInputProps extends ComponentProps<typeof TextInput> { | ||
valid?: boolean; | ||
value: PublicKey | undefined; | ||
debug?: boolean; | ||
} | ||
let { | ||
autofocus = false, | ||
ref = $bindable(), | ||
valid = $bindable(false), | ||
value: _value = $bindable(), | ||
debug = false, | ||
...props | ||
}: PublicKeyInputProps = $props(); | ||
/** The string value bound to the form input */ | ||
let input: string = $state(''); | ||
/** The derived public key from the formatted input */ | ||
const pubkey: PublicKey | undefined = $derived.by(() => { | ||
try { | ||
return PublicKey.from(input); | ||
} catch (e) { | ||
console.warn(e); | ||
return; | ||
} | ||
}); | ||
/** Validation states */ | ||
const satisfiesPublicKeyMatch = $derived( | ||
String(pubkey) === input || String(pubkey?.toLegacyString()) === input | ||
); | ||
/** Whether or not the input value is valid */ | ||
const satisfies: boolean = $derived(satisfiesPublicKeyMatch); | ||
/** Set the input value from a parent */ | ||
export function set(publickey: string) { | ||
input = publickey; | ||
} | ||
/** Set the bindable values on form input changes */ | ||
$effect(() => { | ||
valid = satisfies; | ||
if (satisfies) { | ||
_value = pubkey; | ||
} else { | ||
_value = undefined; | ||
} | ||
}); | ||
if (debug) { | ||
$inspect({ | ||
input, | ||
satisfies | ||
}); | ||
} | ||
</script> | ||
|
||
<TextInput bind:ref bind:value={input} {autofocus} {...props} /> | ||
|
||
{#if debug} | ||
<h3>Component State</h3> | ||
<pre> | ||
input (string): "{input}" | ||
Public Key: {pubkey} | ||
|
||
--- | ||
|
||
Valid Input: {satisfies} | ||
Valid Public Key: {satisfiesPublicKeyMatch} | ||
</pre> | ||
{/if} |
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
Oops, something went wrong.