Skip to content

Commit

Permalink
chore: Generate typescript (#48)
Browse files Browse the repository at this point in the history
* fix: correct u256 packing

* fix: double hash!

* chore: setup type generation

* fix: e2e build/publish types
  • Loading branch information
8e8b2c authored Jul 18, 2024
1 parent 6f15e78 commit a22fb2e
Show file tree
Hide file tree
Showing 80 changed files with 660 additions and 388 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ jobs:
key: node_modules-${{ hashFiles('**/package-lock.json')}}
- run: npm i
- run: npx puppeteer browsers install chrome
- run: npm run build:types
- run: npm run build:client
- run: npm run build:authority
- run: npm run build:mock-oracle

- name: Save types build for possible publish
uses: actions/upload-artifact@v4
with:
name: types-dist
path: packages/types/dist
retention-days: 1
- name: Save client build for possible publish
uses: actions/upload-artifact@v4
with:
Expand All @@ -162,15 +169,15 @@ jobs:
docker build \
-t holoom/external-id-attestor \
-f docker/external-id-attestor/Dockerfile \
packages/authority
packages
docker build \
-t holoom/mock-oracle \
-f docker/mock-oracle/Dockerfile \
packages/mock-oracle
docker build \
-t holoom/evm-bytes-signer \
-f docker/evm-bytes-signer/Dockerfile \
packages/authority
packages
docker build -t holoom/rocket docker/rocket
- name: Start frontend in background
run: npm run dev -w @holoom/e2e &
Expand Down Expand Up @@ -203,6 +210,11 @@ jobs:
- name: Move server binary
run: mv rocket-artifact/holoom_rocket_server ./holoom_rocket_server-bookworm

- name: Download types dist
uses: actions/download-artifact@v4
with:
name: types-dist
path: packages/types/dist
- name: Download client dist
uses: actions/download-artifact@v4
with:
Expand All @@ -224,6 +236,10 @@ jobs:
with:
node-version: "18.19.1"
registry-url: "https://registry.npmjs.org"
- name: Publish types to npm
run: npm publish --access public -w @holoom/types
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish client to npm
run: npm publish --access public -w @holoom/client
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/workdir/*.dna
/workdir/*.happ

/crates/holoom_types/bindings

node_modules
dist
/packages/client/docs
Expand Down
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/holoom_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ hdi = { workspace = true }
serde = { workspace = true }
alloy-primitives = { workspace = true }
ed25519-dalek = { workspace = true }
ts-rs = "9"
30 changes: 23 additions & 7 deletions crates/holoom_types/src/evm_signing_offer.rs
Original file line number Diff line number Diff line change
@@ -1,54 +1,70 @@
use hdi::prelude::*;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::{EvmAddress, EvmSignature};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, TS)]
#[serde(tag = "type")]
#[ts(export)]
pub enum EvmU256Item {
Uint,
Hex,
}

#[hdk_entry_helper]
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, TS)]
#[ts(export)]
pub struct EvmSigningOffer {
#[ts(type = "ActionHash")]
pub recipe_ah: ActionHash,
pub u256_items: Vec<EvmU256Item>,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct CreateEvmSigningOfferPayload {
pub identifier: String,
pub evm_signing_offer: EvmSigningOffer,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct EvmSignatureOverRecipeExecutionRequest {
pub request_id: String,
#[ts(type = "ActionHash")]
pub recipe_execution_ah: ActionHash,
#[ts(type = "ActionHash")]
pub signing_offer_ah: ActionHash,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct ResolveEvmSignatureOverRecipeExecutionRequestPayload {
pub request_id: String,
#[ts(type = "AgentPubKey")]
pub requestor: AgentPubKey,
pub signed_u256_array: SignedEvmU256Array,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct RejectEvmSignatureOverRecipeExecutionRequestPayload {
pub request_id: String,
#[ts(type = "AgentPubKey")]
pub requestor: AgentPubKey,
pub reason: String,
}

pub type EvmU256 = alloy_primitives::U256;

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct SignedEvmU256Array {
#[ts(type = "Uint8Array[]")]
pub raw: Vec<EvmU256>,
#[ts(type = "[Uint8Array, Uint8Array, number]")]
pub signature: EvmSignature,
#[ts(type = "Uint8Array")]
pub signer: EvmAddress,
}
19 changes: 14 additions & 5 deletions crates/holoom_types/src/external_id.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
use hdi::prelude::*;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[hdk_entry_helper]
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, TS)]
#[ts(export)]
pub struct ExternalIdAttestation {
pub request_id: String,
#[ts(type = "AgentPubKey")]
pub internal_pubkey: AgentPubKey,
pub external_id: String,
pub display_name: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct SendExternalIdAttestationRequestPayload {
pub request_id: String,
pub code_verifier: String,
pub code: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct IngestExternalIdAttestationRequestPayload {
pub request_id: String,
pub code_verifier: String,
pub code: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct ConfirmExternalIdRequestPayload {
pub request_id: String,
pub external_id: String,
pub display_name: String,
#[ts(type = "AgentPubKey")]
pub requestor: AgentPubKey,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct RejectExternalIdRequestPayload {
pub request_id: String,
#[ts(type = "AgentPubKey")]
pub requestor: AgentPubKey,
pub reason: String,
}
15 changes: 12 additions & 3 deletions crates/holoom_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use evm_signing_offer::{EvmU256, SignedEvmU256Array};
use hdi::prelude::*;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

pub mod external_id;
pub use external_id::*;
Expand All @@ -15,17 +16,20 @@ pub use username::*;
pub mod oracle;
pub use oracle::*;

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[serde(tag = "type")]
#[ts(export)]
pub enum LocalHoloomSignal {
ExternalIdAttestationRequested {
request_id: String,
#[ts(type = "AgentPubKey")]
requestor_pubkey: AgentPubKey,
code_verifier: String,
code: String,
},
ExternalIdAttested {
request_id: String,
#[ts(type = "Record")]
record: Record,
},
ExternalIdRejected {
Expand All @@ -34,7 +38,9 @@ pub enum LocalHoloomSignal {
},
EvmSignatureRequested {
request_id: String,
#[ts(type = "AgentPubKey")]
requestor_pubkey: AgentPubKey,
#[ts(type = "Uint8Array[]")]
u256_array: Vec<EvmU256>,
},
EvmSignatureProvided {
Expand All @@ -47,10 +53,12 @@ pub enum LocalHoloomSignal {
},
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub enum RemoteHoloomSignal {
ExternalIdAttested {
request_id: String,
#[ts(type = "Record")]
record: Record,
},
ExternalIdRejected {
Expand All @@ -67,7 +75,8 @@ pub enum RemoteHoloomSignal {
},
}

#[derive(Serialize, Deserialize, Debug, Clone, SerializedBytes)]
#[derive(Serialize, Deserialize, Debug, Clone, SerializedBytes, TS)]
#[ts(export)]
pub struct SignableBytes(pub Vec<u8>);

#[dna_properties]
Expand Down
12 changes: 9 additions & 3 deletions crates/holoom_types/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
use hdi::prelude::*;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct MetadataItem {
pub name: String,
pub value: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct UpdateMetadataItemPayload {
#[ts(type = "AgentPubKey")]
pub agent_pubkey: AgentPubKey,
pub name: String,
pub value: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct GetMetadataItemValuePayload {
#[ts(type = "AgentPubKey")]
pub agent_pubkey: AgentPubKey,
pub name: String,
}
Loading

0 comments on commit a22fb2e

Please sign in to comment.