Skip to content

Commit

Permalink
Add Wallet Address Parsing (#68)
Browse files Browse the repository at this point in the history
* redeploy

* use transaction instead of payload

* update transaction payload

* fix demo

* update button text

* working transaction flow

* add validation for signMessage

* add sign message end to end testing

* update args payload

* add eruda

* update payload

* is installed later

* try again

* test

* temp test

* testa gain

* temp fix

* add console log back

* remove logs

* fix validation

* add transaction failed error

* update address

* remove reference

* add textbox back

* change payload

* fix response

* add sound check

* push nonce fix

* remove second transaciton

* remove second permit

* change to 0.01 cents

* remove useCallback

* test multiple transactions

* nested transations

* use different nonces

* move text box

* typed data changes

* improve errors

* add Andy NFT

* wallet address
  • Loading branch information
andy-t-wang authored Sep 19, 2024
1 parent b302a21 commit a9db869
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions demo/with-next/components/ClientContent/WalletAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const WalletAuth = () => {
}

setReceivedWalletAuthPayload(payload);
console.log("From object", MiniKit?.walletAddress);
//@ts-ignore
console.log("From static", window.MiniKit?.walletAddress);
});

return () => {
Expand Down
21 changes: 20 additions & 1 deletion src/minikit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class MiniKit {
[ResponseEvent.MiniAppSignTypedData]: () => {},
};

public static walletAddress: string | null = null;

private static sendInit() {
sendWebviewEvent({
command: "init",
Expand All @@ -71,7 +73,24 @@ export class MiniKit {
event: E,
handler: EventHandler<E>
) {
this.listeners[event] = handler;
if (event === ResponseEvent.MiniAppWalletAuth) {
const originalHandler =
handler as EventHandler<ResponseEvent.MiniAppWalletAuth>;

const wrappedHandler: EventHandler<ResponseEvent.MiniAppWalletAuth> = (
payload
) => {
if (payload.status === "success") {
MiniKit.walletAddress = payload.address;
}

originalHandler(payload);
};

this.listeners[event] = wrappedHandler as EventHandler<E>;
} else {
this.listeners[event] = handler;
}
}

public static unsubscribe(event: ResponseEvent) {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@worldcoin/minikit-js",
"version": "0.0.28-internal-alpha",
"version": "0.0.29-internal-alpha",
"homepage": "https://docs.worldcoin.org/id/minikit",
"description": "Internal Alpha: Mini-kit JS is a lightweight sdk for building mini-apps compatible with World App",
"license": "MIT",
Expand Down

0 comments on commit a9db869

Please sign in to comment.