From 27d94188c2522f22a14aaf5ed5857c23cb88d259 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 27 Feb 2024 21:34:45 -0700 Subject: [PATCH 1/2] feat(ui): create time periods, create grant pool working --- .../zomes/integrity/grants/src/application.rs | 4 +- .../zomes/integrity/grants/src/evaluation.rs | 6 +- .../grants/src/evaluation_template.rs | 6 +- .../zomes/integrity/grants/src/grant_pool.rs | 2 +- package-lock.json | 203 +++++++++++++++++- ui/package.json | 6 +- ui/src/config.ts | 3 + .../grant_pools/grants/AllTimePeriods.svelte | 69 ------ .../grants/CreateTimePeriod.svelte | 86 -------- .../grants/TimePeriodDetail.svelte | 42 +--- ui/src/grant_pools/grants/types.ts | 13 ++ ui/src/lib/components/BaseNavbar.svelte | 1 + ui/src/lib/components/InputTokenAmount.svelte | 73 +++++++ .../components/InputTokenAmountRange.svelte | 19 ++ ui/src/lib/stores/holochainClient.ts | 69 +++--- ui/src/lib/utils/u256.ts | 3 + ui/src/routes/grant-pools/create/+page.svelte | 40 ++-- .../create/CreateEvaluationTemplate.svelte | 2 - .../create/InputEvaluationTemplate.svelte | 1 - ui/src/routes/time-periods/+page.svelte | 36 ++++ ui/src/routes/time-periods/+page.ts | 4 + .../routes/time-periods/AllTimePeriods.svelte | 45 ++++ .../time-periods/CreateTimePeriod.svelte | 56 +++++ 23 files changed, 537 insertions(+), 252 deletions(-) create mode 100644 ui/src/config.ts delete mode 100644 ui/src/grant_pools/grants/AllTimePeriods.svelte delete mode 100644 ui/src/grant_pools/grants/CreateTimePeriod.svelte create mode 100644 ui/src/lib/components/InputTokenAmount.svelte create mode 100644 ui/src/lib/components/InputTokenAmountRange.svelte create mode 100644 ui/src/lib/utils/u256.ts create mode 100644 ui/src/routes/time-periods/+page.svelte create mode 100644 ui/src/routes/time-periods/+page.ts create mode 100644 ui/src/routes/time-periods/AllTimePeriods.svelte create mode 100644 ui/src/routes/time-periods/CreateTimePeriod.svelte diff --git a/dnas/grant_pools/zomes/integrity/grants/src/application.rs b/dnas/grant_pools/zomes/integrity/grants/src/application.rs index e360753..314f238 100644 --- a/dnas/grant_pools/zomes/integrity/grants/src/application.rs +++ b/dnas/grant_pools/zomes/integrity/grants/src/application.rs @@ -1,11 +1,11 @@ use alloy_primitives::U256; use hdi::prelude::*; -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, SerializedBytes)] pub struct ApplicationOutcome { approved: bool, grant_pool: ActionHash, } -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, SerializedBytes)] #[serde(tag = "type")] pub enum ApplicationStatus { Draft, diff --git a/dnas/grant_pools/zomes/integrity/grants/src/evaluation.rs b/dnas/grant_pools/zomes/integrity/grants/src/evaluation.rs index 34d0c83..53d518e 100644 --- a/dnas/grant_pools/zomes/integrity/grants/src/evaluation.rs +++ b/dnas/grant_pools/zomes/integrity/grants/src/evaluation.rs @@ -1,18 +1,18 @@ use hdi::prelude::*; -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, SerializedBytes)] #[serde(tag = "type")] pub enum EvaluationStatus { Draft, Submitted, } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, SerializedBytes)] pub struct AttributeScore { label: String, value: u64, } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, SerializedBytes)] pub enum Score { Single(u64), Weighted(Vec), diff --git a/dnas/grant_pools/zomes/integrity/grants/src/evaluation_template.rs b/dnas/grant_pools/zomes/integrity/grants/src/evaluation_template.rs index 54a360a..76b3dc9 100644 --- a/dnas/grant_pools/zomes/integrity/grants/src/evaluation_template.rs +++ b/dnas/grant_pools/zomes/integrity/grants/src/evaluation_template.rs @@ -1,19 +1,19 @@ use hdi::prelude::*; use serde_json::Value; -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, SerializedBytes)] pub struct NumberRange { min: u32, max: u32, } -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, SerializedBytes)] pub struct AttributeScoreTemplate { label: String, weight: u32, } -#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, SerializedBytes)] #[serde(tag = "type", content = "content")] pub enum ScoreTemplate { Single, diff --git a/dnas/grant_pools/zomes/integrity/grants/src/grant_pool.rs b/dnas/grant_pools/zomes/integrity/grants/src/grant_pool.rs index b35b829..f6074c8 100644 --- a/dnas/grant_pools/zomes/integrity/grants/src/grant_pool.rs +++ b/dnas/grant_pools/zomes/integrity/grants/src/grant_pool.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use hdi::prelude::*; -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, SerializedBytes)] pub struct AmountRange { min: U256, max: U256, diff --git a/package-lock.json b/package-lock.json index f1c15ae..045c262 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,11 @@ "node": ">=0.10.0" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", + "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + }, "node_modules/@alenaksu/json-viewer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@alenaksu/json-viewer/-/json-viewer-2.0.1.tgz", @@ -71,6 +76,18 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/runtime-corejs3": { + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.23.9.tgz", + "integrity": "sha512-oeOFTrYWdWXCvXGB5orvMTJ6gCZ9I6FBjR+M38iKNXCsPxr4xT0RTdg5uz1H7QP8pp74IzPtwritEr+JscqHXQ==", + "dependencies": { + "core-js-pure": "^3.30.2", + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@bitgo/blake2b": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/@bitgo/blake2b/-/blake2b-3.2.4.tgz", @@ -1036,6 +1053,17 @@ "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, + "node_modules/@imask/svelte": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@imask/svelte/-/svelte-7.4.0.tgz", + "integrity": "sha512-62dRCeqAp+wW35ixIxU9XOTxf63kOn5i6/rAHkGpt29PcACIGsjYsC+tpDeqtOeJv9QEF/wqGKycCCHKsLE0tA==", + "dependencies": { + "imask": "^7.4.0" + }, + "peerDependencies": { + "svelte": "^4.2.10" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -2057,6 +2085,28 @@ "integrity": "sha512-SmksyaJAdSlMa9cTidVSIqYo1qti+WTsviNDwgjNVm+KQ3DRP2Df9umDIzC4vCcpEYY+chQe0i2IKnLw03AT8Q==", "dev": true }, + "node_modules/@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2420,6 +2470,39 @@ "lodash-es": "^4.17.21" } }, + "node_modules/@scure/base": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", + "integrity": "sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==", + "dependencies": { + "@noble/curves": "~1.2.0", + "@noble/hashes": "~1.3.2", + "@scure/base": "~1.1.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", + "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "dependencies": { + "@noble/hashes": "~1.3.0", + "@scure/base": "~1.1.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@shoelace-style/animations": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@shoelace-style/animations/-/animations-1.1.0.tgz", @@ -3372,6 +3455,26 @@ "resolved": "https://registry.npmjs.org/@zerodevx/svelte-toast/-/svelte-toast-0.8.2.tgz", "integrity": "sha512-EDtZ/Hw37T/UWCQ5drhMss0J9vItYUSDivQ3+mET5My6No7YNiNQklj2bkE61UAzut2TjHJfOJNBZsj78ODFtw==" }, + "node_modules/abitype": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", + "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -3982,6 +4085,16 @@ "node": ">= 0.6" } }, + "node_modules/core-js-pure": { + "version": "3.36.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.36.0.tgz", + "integrity": "sha512-cN28qmhRNgbMZZMc/RFu5w8pK9VJzpb2rJVR/lHuZJKwmXnoWOpXmMkxqBB514igkp1Hu8WGROsiOAzUcKdHOQ==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cose-base": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", @@ -4150,6 +4263,14 @@ "url": "https://opencollective.com/date-fns" } }, + "node_modules/date-picker-svelte": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/date-picker-svelte/-/date-picker-svelte-2.11.0.tgz", + "integrity": "sha512-iaYxY2mZN6uJ1AidZUFy0MorGzdMUeaD5G8z6NIbg22GIn/9ZdnkonTY7I3+zrPp85eGZx/Ws9sCJVhMyV7sog==", + "peerDependencies": { + "svelte": "^3.24.0 || ^4.0.0" + } + }, "node_modules/dayjs": { "version": "1.11.10", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", @@ -5508,6 +5629,17 @@ "node": ">= 4" } }, + "node_modules/imask": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/imask/-/imask-7.4.0.tgz", + "integrity": "sha512-fU6mCo5YiTeDI8aVreuOKLOWxXIrRVnuQhZQXbjhwHxQb3GOQyCtlDGMyHxu2gq//LnKDxTwDBq1teRHmkzA3Q==", + "dependencies": { + "@babel/runtime-corejs3": "^7.23.9" + }, + "engines": { + "npm": ">=4.0.0" + } + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -5671,6 +5803,20 @@ "ws": "*" } }, + "node_modules/isows": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.3.tgz", + "integrity": "sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wagmi-dev" + } + ], + "peerDependencies": { + "ws": "*" + } + }, "node_modules/jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", @@ -8323,7 +8469,7 @@ "version": "5.3.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8420,6 +8566,55 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/viem": { + "version": "2.7.15", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.7.15.tgz", + "integrity": "sha512-I2RMQpg1/MC7fXVjHxeXRPU9k/WEOvZajK/KZSr7DChS0AaZ7uovsQWppwBn2wvZWguTCIRAHqzMwIEGku95yQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "dependencies": { + "@adraffy/ens-normalize": "1.10.0", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@scure/bip32": "1.3.2", + "@scure/bip39": "1.2.1", + "abitype": "1.0.0", + "isows": "1.0.3", + "ws": "8.13.0" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/vite": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/vite/-/vite-5.1.4.tgz", @@ -9576,6 +9771,7 @@ "dependencies": { "@holochain-open-dev/profiles": "^0.17.3", "@holochain/client": "^0.16.7", + "@imask/svelte": "^7.4.0", "@material/mwc-button": "^0.27.0", "@material/mwc-checkbox": "^0.27.0", "@material/mwc-formfield": "^0.27.0", @@ -9588,10 +9784,13 @@ "@msgpack/msgpack": "^2.7.2", "@pragmatic-engineering/svelte-form-builder-community": "^1.0.2", "@vaadin/date-time-picker": "^23.2.8", + "date-picker-svelte": "^2.11.0", "dayjs": "^1.11.10", "flowbite-svelte-icons": "^1.4.0", + "imask": "^7.4.0", "lodash": "^4.17.21", - "uuid": "^9.0.1" + "uuid": "^9.0.1", + "viem": "^2.7.15" }, "devDependencies": { "@fontsource/fira-mono": "^4.5.10", diff --git a/ui/package.json b/ui/package.json index 4444f19..033ae78 100644 --- a/ui/package.json +++ b/ui/package.json @@ -16,6 +16,7 @@ "dependencies": { "@holochain-open-dev/profiles": "^0.17.3", "@holochain/client": "^0.16.7", + "@imask/svelte": "^7.4.0", "@material/mwc-button": "^0.27.0", "@material/mwc-checkbox": "^0.27.0", "@material/mwc-formfield": "^0.27.0", @@ -28,10 +29,13 @@ "@msgpack/msgpack": "^2.7.2", "@pragmatic-engineering/svelte-form-builder-community": "^1.0.2", "@vaadin/date-time-picker": "^23.2.8", + "date-picker-svelte": "^2.11.0", "dayjs": "^1.11.10", "flowbite-svelte-icons": "^1.4.0", + "imask": "^7.4.0", "lodash": "^4.17.21", - "uuid": "^9.0.1" + "uuid": "^9.0.1", + "viem": "^2.7.15" }, "devDependencies": { "@fontsource/fira-mono": "^4.5.10", diff --git a/ui/src/config.ts b/ui/src/config.ts new file mode 100644 index 0000000..3515e46 --- /dev/null +++ b/ui/src/config.ts @@ -0,0 +1,3 @@ +export const ACCEPTED_TOKEN_DECIMALS = 6; +export const ACCEPTED_TOKEN_SYMBOL = 'USDC'; +export const ACCEPTED_TOKEN_ADDRESS_ETHEREUM = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; diff --git a/ui/src/grant_pools/grants/AllTimePeriods.svelte b/ui/src/grant_pools/grants/AllTimePeriods.svelte deleted file mode 100644 index 0155d98..0000000 --- a/ui/src/grant_pools/grants/AllTimePeriods.svelte +++ /dev/null @@ -1,69 +0,0 @@ - - -{#if loading} -
- -
-{:else if error} - Error fetching the time periods: {error.data.data}. -{:else if hashes.length === 0} - No time periods found. -{:else} -
- {#each hashes as hash} -
- fetchTimePeriods()} - > -
- {/each} -
-{/if} diff --git a/ui/src/grant_pools/grants/CreateTimePeriod.svelte b/ui/src/grant_pools/grants/CreateTimePeriod.svelte deleted file mode 100644 index b08acbb..0000000 --- a/ui/src/grant_pools/grants/CreateTimePeriod.svelte +++ /dev/null @@ -1,86 +0,0 @@ - - - -
- Create TimePeriod - -
- { - startAt = new Date(e.target.value).valueOf() * 1000; - }} - required - > -
- -
- { - endAt = new Date(e.target.value).valueOf() * 1000; - }} - required - > -
- - createTimePeriod()} - > -
diff --git a/ui/src/grant_pools/grants/TimePeriodDetail.svelte b/ui/src/grant_pools/grants/TimePeriodDetail.svelte index 40b1a34..10a6744 100644 --- a/ui/src/grant_pools/grants/TimePeriodDetail.svelte +++ b/ui/src/grant_pools/grants/TimePeriodDetail.svelte @@ -1,51 +1,27 @@ {#if loading} -
+
-{:else if error} - Error fetching the time period: {error.data.data} {:else}
diff --git a/ui/src/grant_pools/grants/types.ts b/ui/src/grant_pools/grants/types.ts index 6cc0650..ccfcdd1 100644 --- a/ui/src/grant_pools/grants/types.ts +++ b/ui/src/grant_pools/grants/types.ts @@ -54,6 +54,17 @@ export interface ApplicationTemplate { name: string; } +export interface AmountRange { + min: Uint8Array; + max: Uint8Array; +}; + +export interface AmountRangeBigInt { + min: bigint; + max: bigint; +}; + + export interface NumberRange { min: number; max: number; @@ -103,6 +114,8 @@ export interface GrantPool { evaluation_template: ActionHash; + amount_range: AmountRange; + evaluators: AgentPubKey[]; } diff --git a/ui/src/lib/components/BaseNavbar.svelte b/ui/src/lib/components/BaseNavbar.svelte index 9a5a678..bd8e5d7 100644 --- a/ui/src/lib/components/BaseNavbar.svelte +++ b/ui/src/lib/components/BaseNavbar.svelte @@ -17,6 +17,7 @@
+ Time Periods Grant Pools My Applications My Evaluations diff --git a/ui/src/lib/components/InputTokenAmount.svelte b/ui/src/lib/components/InputTokenAmount.svelte new file mode 100644 index 0000000..7adaa1c --- /dev/null +++ b/ui/src/lib/components/InputTokenAmount.svelte @@ -0,0 +1,73 @@ + + +
+
+ + + {#if maxValue} +
+ +
+ {/if} + + {#if symbol} + + {symbol} + + {/if} +
+ {#if decimals === 0} + + + This token does not specify a number of decimals.
You are inputting the raw integer + amount with 0 decimal places. +
+ {/if} +
diff --git a/ui/src/lib/components/InputTokenAmountRange.svelte b/ui/src/lib/components/InputTokenAmountRange.svelte new file mode 100644 index 0000000..a690835 --- /dev/null +++ b/ui/src/lib/components/InputTokenAmountRange.svelte @@ -0,0 +1,19 @@ + + +
+
+ + +
+
+ + +
+
diff --git a/ui/src/lib/stores/holochainClient.ts b/ui/src/lib/stores/holochainClient.ts index f203014..60a54d7 100644 --- a/ui/src/lib/stores/holochainClient.ts +++ b/ui/src/lib/stores/holochainClient.ts @@ -1,5 +1,5 @@ import { derived, get, writable } from 'svelte/store'; -import { AppAgentWebsocket } from '@holochain/client'; +import { AppAgentWebsocket, type AgentPubKey } from '@holochain/client'; import { toasts } from './toast'; import { ProfilesClient, ProfilesStore } from '@holochain-open-dev/profiles'; @@ -14,6 +14,41 @@ function holochainClientStore() { isConnecting: $isConnecting, })); + function setupProfileStore() { + profilesStore.set(new ProfilesStore(new ProfilesClient(get(client), 'grant_pools'), { + avatarMode: 'avatar-optional', + additionalFields: [ + { + label: 'About Me', + name: 'bio', + required: true, + }, + { + label: 'Email', + name: 'email', + required: false, + }, + { + label: 'Website', + name: 'website', + required: false, + }, + { + label: 'LinkedIn', + name: 'linkedin', + required: false, + }, + { + label: 'X', + name: 'x', + required: false, + }, + + ] + })); + } + + async function connect(url: URL, happId: string) { if(get(client) !== undefined) return; @@ -21,37 +56,7 @@ function holochainClientStore() { try { const res = await AppAgentWebsocket.connect(url, happId); client.set(res); - profilesStore.set(new ProfilesStore(new ProfilesClient(res, 'grant_pools'), { - avatarMode: 'avatar-optional', - additionalFields: [ - { - label: 'About Me', - name: 'bio', - required: true, - }, - { - label: 'Email', - name: 'email', - required: false, - }, - { - label: 'Website', - name: 'website', - required: false, - }, - { - label: 'LinkedIn', - name: 'linkedin', - required: false, - }, - { - label: 'X', - name: 'x', - required: false, - }, - - ] - })); + await setupProfileStore(); } catch(e) { toasts.error(`Failed to connect to holochain client: ${e as string}`); } diff --git a/ui/src/lib/utils/u256.ts b/ui/src/lib/utils/u256.ts new file mode 100644 index 0000000..95b9af9 --- /dev/null +++ b/ui/src/lib/utils/u256.ts @@ -0,0 +1,3 @@ +import { pad, toBytes } from 'viem'; + +export const bigintToU256 = (val: bigint) => pad(toBytes(val)); diff --git a/ui/src/routes/grant-pools/create/+page.svelte b/ui/src/routes/grant-pools/create/+page.svelte index 1a316c4..11a22a6 100644 --- a/ui/src/routes/grant-pools/create/+page.svelte +++ b/ui/src/routes/grant-pools/create/+page.svelte @@ -1,16 +1,18 @@ @@ -62,7 +70,7 @@
- +
@@ -70,7 +78,7 @@