Skip to content

Commit

Permalink
Merge pull request #799 from gofractally/add-temp-login-functionality
Browse files Browse the repository at this point in the history
Add temporary login functionality
  • Loading branch information
James-Mart authored Aug 15, 2024
2 parents 9049afd + d5ae3b9 commit 98f3198
Show file tree
Hide file tree
Showing 41 changed files with 653 additions and 238 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ psinode_db
psinode_db_secure
__pycache__
ccache.conf
bindings.rs
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ add_rs_component(services/user/Invite/plugin:InvitesPlugin invite.wasm wasm32-wa
add_rs_component(services/user/Tokens/plugin:TokensPlugin tokens.wasm wasm32-wasi )
add_rs_component(services/user/Supervisor/plugin:TestsPlugin test.wasm wasm32-wasi )
add_rs_component(services/user/Webmail/plugin:WebmailPlugin webmail_plugin.wasm wasm32-wasi)
add_rs_component(services/user/ClientData/plugin:ClientDataPlugin clientdata.wasm wasm32-wasi )

set(WASM_PSIBASE_BYPRODUCTS
${CMAKE_CURRENT_SOURCE_DIR}/services/user/XAdmin/ui/wasm-psibase/wasm-psibase_bg.js
Expand Down Expand Up @@ -397,6 +398,17 @@ psibase_package(
PACKAGE_DEPENDS "AuthAny(^${PSIBASE_VERSION})" "HttpServer(^${PSIBASE_VERSION})"
)

psibase_package(
OUTPUT ${SERVICE_DIR}/ClientData.psi
NAME ClientData
DESCRIPTION "Plugin for enabling simpler interactions with client-side data storage"
VERSION ${PSIBASE_VERSION}
PACKAGE_DEPENDS "Nft(^${PSIBASE_VERSION})" "HttpServer(^${PSIBASE_VERSION})" "Sites(^${PSIBASE_VERSION})" "Accounts(^${PSIBASE_VERSION})" "CommonApi(^${PSIBASE_VERSION})" "Supervisor(^${PSIBASE_VERSION})"
SERVICE clientdata
DATA ${COMPONENT_BIN_DIR}/${ClientDataPlugin_OUTPUT_FILE} /plugin.wasm
DEPENDS ${ClientDataPlugin_DEP}
)

psibase_package(
OUTPUT ${SERVICE_DIR}/AuthSig.psi
NAME AuthSig
Expand Down Expand Up @@ -739,7 +751,7 @@ psibase_package(
NAME Default
VERSION ${PSIBASE_VERSION}
DESCRIPTION "All default services"
PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate AuthK1 CommonApi CpuLimit Docs
PACKAGE_DEPENDS Accounts AuthAny AuthSig AuthDelegate AuthK1 ClientData CommonApi CpuLimit Docs
Webmail Events Explorer Fractal Invite Nft Packages Producers HttpServer
Sites SetCode Supervisor Symbol TokenUsers Tokens Transact
)
Expand Down Expand Up @@ -767,7 +779,7 @@ function(write_package_index target dir)
endfunction()

write_package_index(package-index ${SERVICE_DIR}
Accounts AuthAny AuthSig AuthK1 CommonApi CpuLimit Default
Accounts AuthAny AuthSig AuthK1 ClientData CommonApi CpuLimit Default
Docs Events Explorer Fractal Invite Nft Nop Minimal Packages Producers HttpServer
Sites SetCode Supervisor Symbol TokenUsers Tokens Transact)

Expand All @@ -778,6 +790,7 @@ install(
${SERVICE_DIR}/AuthDelegate.psi
${SERVICE_DIR}/AuthSig.psi
${SERVICE_DIR}/AuthK1.psi
${SERVICE_DIR}/ClientData.psi
${SERVICE_DIR}/CommonApi.psi
${SERVICE_DIR}/Default.psi
${SERVICE_DIR}/CpuLimit.psi
Expand Down
7 changes: 2 additions & 5 deletions dev/DemoApp1/plugin/wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ interface intf {
multiply: func(a: u32, b: u32) -> result<string, error>;
}

world example {
world impl {
import invite:plugin/inviter;
import host:common/server;
import host:common/client;
include host:common/imports;

export helloworld: func() -> string;
export intf;


}
43 changes: 43 additions & 0 deletions dev/DemoApp1/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,45 @@ function App() {
}
};

const run8 = async () => {
try {
await supervisor.functionCall({
service: "accounts",
intf: "accounts",
method: "loginTemp",
params: ["alice"],
});

await supervisor.functionCall({
service: "tokens",
intf: "transfer",
method: "credit",
params: ["1", "bob", "12.0000", ""],
});

await supervisor.functionCall({
service: "accounts",
intf: "accounts",
method: "loginTemp",
params: ["bob"],
});

await supervisor.functionCall({
service: "tokens",
intf: "transfer",
method: "credit",
params: ["1", "alice", "6.0000", ""],
});

} catch (e) {
if (e instanceof Error) {
console.error(`Error: ${e.message}\nStack: ${e.stack}`);
} else {
console.error(`Caught exception: ${JSON.stringify(e, null, 2)}`);
}
}
};

const [a, setA] = useState("");
const [b, setB] = useState("");
const [c, setC] = useState("");
Expand Down Expand Up @@ -231,6 +270,10 @@ function App() {
<button onClick={() => run7()}>{"Set key"}</button>
<FileSelector onLoad={setC} />
</div>

<div className="card">
<button onClick={() => run8()}>{"Example login functionality"}</button>
</div>
</>
);
}
Expand Down
Loading

0 comments on commit 98f3198

Please sign in to comment.