Skip to content

Commit

Permalink
Merge pull request #37 from DIMO-Network/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
MoizAhmedd authored Dec 7, 2024
2 parents edfbeae + 647ead9 commit e7682d5
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 48 deletions.
Binary file modified example-dimo-auth/dimo-network-login-with-dimo-0.0.11.tgz
Binary file not shown.
Binary file not shown.
101 changes: 63 additions & 38 deletions example-dimo-auth/package-lock.json

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

2 changes: 1 addition & 1 deletion example-dimo-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@types/node": "^16.18.114",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.11.tgz",
"@dimo-network/login-with-dimo": "file:./dimo-network-login-with-dimo-0.0.12.tgz",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
Expand Down
10 changes: 6 additions & 4 deletions example-dimo-auth/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ function App() {
mode="popup"
onSuccess={(authData: any) => console.log("Success:", authData)}
onError={(error: any) => console.error("Error:", error)}
permissionTemplateId={permissionsEnabled ? "1" : undefined}
permissionTemplateId={permissionsEnabled ? "2" : undefined}
// vehicles={["585","586"]}
/>

Expand All @@ -1146,17 +1146,19 @@ function App() {
mode="popup"
onSuccess={(authData: any) => console.log("Success:", authData)}
onError={(error: any) => console.error("Error:", error)}
permissionTemplateId={"1"}
permissionTemplateId={"2"}
/>

<ExecuteAdvancedTransactionWithDimo
mode="popup"
onSuccess={(transactionData: any) =>
onSuccess={(transactionData: any) => {
console.log(transactionData);
console.log(
"Transaction Hash:",
transactionData.transactionHash
)
}
}
onError={(error: any) => console.error("Error:", error)}
address="0x21cFE003997fB7c2B3cfe5cf71e7833B7B2eCe10"
value="0"
Expand Down Expand Up @@ -1193,7 +1195,7 @@ function App() {
mode="redirect"
onSuccess={(authData: any) => console.log("Success:", authData)}
onError={(error: any) => console.error("Error:", error)}
permissionTemplateId={"1"}
permissionTemplateId={"2"}
/>

<ExecuteAdvancedTransactionWithDimo
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dimo-network/login-with-dimo",
"version": "0.0.11",
"version": "0.0.12",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/components/LoginWithDimo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LoginWithDimo: React.FC<LoginWithDimoProps> = ({
return (
<BaseDimoButton
mode={mode}
entryState={EntryState.EMAIL_INPUT} // Default state for login
entryState={permissionTemplateId ? EntryState.VEHICLE_MANAGER : EntryState.EMAIL_INPUT} // Go to vehicle sharing if permissions are toggled, otherwise only login
onSuccess={onSuccess}
onError={onError}
buttonLabel={(authenticated) =>
Expand Down
5 changes: 2 additions & 3 deletions sdk/src/utils/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ export const handleMessageForPopup = (
setAuthenticated,
onSuccess
);
if (popup && !popup.closed) popup.close();
}

if (eventType === MessageEventType.TRANSACTION_RESPONSE && transactionHash) {
onSuccess({ token: "", transactionHash });
onSuccess({ token, transactionHash });
}

if (eventType === MessageEventType.LOGOUT) {
Expand Down Expand Up @@ -172,7 +171,7 @@ export const handleMessageForEmbed = (basePayload: BasePayload, data: any) => {

if (eventType === MessageEventType.TRANSACTION_RESPONSE) {
if (transactionHash || transactionReceipt) {
onSuccess({ token: "", transactionHash, transactionReceipt });
onSuccess({ token, transactionHash, transactionReceipt });
} else {
onError(new Error("Could not execute transaction"));
}
Expand Down

0 comments on commit e7682d5

Please sign in to comment.