-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
427 additions
and
27 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
export const idlFactory = ({ IDL }) => { | ||
const UserPrincipal = IDL.Record({ | ||
username: IDL.Text, | ||
princi: IDL.Principal, | ||
wallet: IDL.Principal, | ||
}); | ||
return IDL.Service({ | ||
addUserPrincipal: IDL.Func([IDL.Text, IDL.Principal], [], []), | ||
getUserPrincipalArray: IDL.Func([], [IDL.Vec(UserPrincipal)], ["query"]), | ||
}); | ||
}; | ||
export const init = ({ IDL }) => { | ||
return []; | ||
}; |
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,39 @@ | ||
import { idlFactory } from "../idl/service.did"; | ||
import { Actor, HttpAgent } from "@dfinity/agent"; | ||
|
||
const nnsCanisterId = "7z2b7-ciaaa-aaaap-ahxba-cai"; | ||
const host = "https://ic0.app"; | ||
|
||
export async function connectWallet() { | ||
const whitelist = [nnsCanisterId]; | ||
try { | ||
await window?.ic?.plug?.requestConnect({ | ||
whitelist, | ||
}); | ||
return window.ic.plug.principalId; | ||
} catch (error) { | ||
console.log(error); | ||
return; | ||
} | ||
} | ||
|
||
export async function getActorWithoutLogin() { | ||
const agent = new HttpAgent({ host: host }); | ||
const actor = Actor.createActor(idlFactory, { | ||
agent, | ||
canisterId: nnsCanisterId, | ||
}); | ||
return actor; | ||
} | ||
|
||
export async function getActorWithLogin() { | ||
const publicKey = await window.ic.plug.agent.getPrincipal(); | ||
if (publicKey) { | ||
const agent = new HttpAgent({ publicKey, host: host }); | ||
const actor = Actor.createActor(idlFactory, { | ||
agent, | ||
canisterId: nnsCanisterId, | ||
}); | ||
return actor; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -422,4 +422,4 @@ export function CreateAuction() { | |
</div> | ||
</div> | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
import { defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react"; | ||
import rollupNodePolyFill from "rollup-plugin-polyfill-node"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
}) | ||
optimizeDeps: { | ||
esbuildOptions: { | ||
define: { | ||
global: "globalThis", | ||
}, | ||
}, | ||
}, | ||
build: { | ||
rollupOptions: { | ||
plugins: [rollupNodePolyFill()], | ||
}, | ||
}, | ||
}); |