@@ -27,6 +42,45 @@ export const ClientContent = () => {
+
+
+ {/* Display search results */}
+ {searchResults && (
+
+ {searchResults.status === 200 ? (
+
+ {searchResults.data?.map((user) => (
+ -
+ {user.profile_picture_url && (
+
+ )}
+ {user.username} - {user.address}
+
+ ))}
+
+ ) : (
+
Error: {searchResults.error}
+ )}
+
+ )}
+
@@ -42,6 +96,8 @@ export const ClientContent = () => {
+
+
diff --git a/demo/with-next/next.config.mjs b/demo/with-next/next.config.mjs
index 4678774..12e388a 100644
--- a/demo/with-next/next.config.mjs
+++ b/demo/with-next/next.config.mjs
@@ -1,4 +1,8 @@
/** @type {import('next').NextConfig} */
-const nextConfig = {};
+const nextConfig = {
+ images: {
+ domains: ["static.usernames.app-backend.toolsforhumanity.com"],
+ },
+};
export default nextConfig;
diff --git a/packages/core/minikit.ts b/packages/core/minikit.ts
index 42dcc0a..d3a36c5 100644
--- a/packages/core/minikit.ts
+++ b/packages/core/minikit.ts
@@ -14,6 +14,7 @@ import {
MiniAppSignTypedDataPayload,
MiniAppVerifyActionPayload,
MiniAppWalletAuthPayload,
+ MiniAppShareContactsPayload,
ResponseEvent,
} from "./types/responses";
import { Network } from "types/payment";
@@ -23,6 +24,7 @@ import {
PayCommandPayload,
SendTransactionInput,
SendTransactionPayload,
+ ShareContactsPayload,
SignMessageInput,
SignMessagePayload,
SignTypedDataInput,
@@ -62,6 +64,7 @@ export class MiniKit {
[Command.SendTransaction]: 1,
[Command.SignMessage]: 1,
[Command.SignTypedData]: 1,
+ [Command.ShareContacts]: 1,
};
private static isCommandAvailable = {
@@ -71,6 +74,7 @@ export class MiniKit {
[Command.SendTransaction]: false,
[Command.SignMessage]: false,
[Command.SignTypedData]: false,
+ [Command.ShareContacts]: false,
};
private static listeners: Record = {
@@ -80,6 +84,7 @@ export class MiniKit {
[ResponseEvent.MiniAppSendTransaction]: () => {},
[ResponseEvent.MiniAppSignMessage]: () => {},
[ResponseEvent.MiniAppSignTypedData]: () => {},
+ [ResponseEvent.MiniAppShareContacts]: () => {},
};
public static appId: string | null = null;
@@ -432,6 +437,29 @@ export class MiniKit {
return payload;
},
+
+ shareContacts: (
+ payload: ShareContactsPayload
+ ): ShareContactsPayload | null => {
+ if (
+ typeof window === "undefined" ||
+ !this.isCommandAvailable[Command.SignTypedData]
+ ) {
+ console.error(
+ "'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
+ );
+
+ return null;
+ }
+
+ sendMiniKitEvent({
+ command: Command.ShareContacts,
+ version: 1,
+ payload,
+ });
+
+ return payload;
+ },
};
/**
@@ -556,5 +584,24 @@ export class MiniKit {
}
});
},
+ shareContacts: async (
+ payload: ShareContactsPayload
+ ): AsyncHandlerReturn<
+ ShareContactsPayload | null,
+ MiniAppShareContactsPayload
+ > => {
+ return new Promise(async (resolve, reject) => {
+ try {
+ const response = await MiniKit.awaitCommand(
+ ResponseEvent.MiniAppShareContacts,
+ Command.ShareContacts,
+ () => this.commands.shareContacts(payload)
+ );
+ return resolve(response);
+ } catch (error) {
+ reject(error);
+ }
+ });
+ },
};
}
diff --git a/packages/core/types/commands.ts b/packages/core/types/commands.ts
index 7507a1e..3cca984 100644
--- a/packages/core/types/commands.ts
+++ b/packages/core/types/commands.ts
@@ -11,6 +11,7 @@ export enum Command {
SendTransaction = "send-transaction",
SignMessage = "sign-message",
SignTypedData = "sign-typed-data",
+ ShareContacts = "share-contacts",
}
export type WebViewBasePayload = {
@@ -93,6 +94,12 @@ export type SignTypedDataInput = {
export type SignTypedDataPayload = SignTypedDataInput;
+// Anchor: Share Contacts Payload
+export type ShareContactsInput = {
+ isMultiSelectEnabled: boolean;
+};
+export type ShareContactsPayload = ShareContactsInput;
+
type CommandReturnPayloadMap = {
[Command.Verify]: VerifyCommandPayload;
[Command.Pay]: PayCommandPayload;
@@ -100,6 +107,7 @@ type CommandReturnPayloadMap = {
[Command.SendTransaction]: SendTransactionPayload;
[Command.SignMessage]: SignMessagePayload;
[Command.SignTypedData]: SignTypedDataPayload;
+ [Command.ShareContacts]: ShareContactsPayload;
};
export type CommandReturnPayload =
T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
diff --git a/packages/core/types/errors.ts b/packages/core/types/errors.ts
index 6dd5379..63e0045 100644
--- a/packages/core/types/errors.ts
+++ b/packages/core/types/errors.ts
@@ -147,3 +147,13 @@ export const MiniKitInstallErrorMessage = {
[MiniKitInstallErrorCodes.AppOutOfDate]:
"WorldApp is out of date. Please update the app.",
};
+
+export enum ShareContactsErrorCodes {
+ UserRejected = "user_rejected",
+ GenericError = "generic_error",
+}
+
+export const ShareContactsErrorMessage = {
+ [ShareContactsErrorCodes.UserRejected]: "User rejected the request.",
+ [ShareContactsErrorCodes.GenericError]: "Something unexpected went wrong.",
+};
diff --git a/packages/core/types/responses.ts b/packages/core/types/responses.ts
index c794ff5..c3ae7c3 100644
--- a/packages/core/types/responses.ts
+++ b/packages/core/types/responses.ts
@@ -2,6 +2,7 @@ import { Network } from "./payment";
import {
PaymentErrorCodes,
SendTransactionErrorCodes,
+ ShareContactsErrorCodes,
SignMessageErrorCodes,
SignTypedDataErrorCodes,
VerificationErrorCodes,
@@ -17,6 +18,7 @@ export enum ResponseEvent {
MiniAppSendTransaction = "miniapp-send-transaction",
MiniAppSignMessage = "miniapp-sign-message",
MiniAppSignTypedData = "miniapp-sign-typed-data",
+ MiniAppShareContacts = "miniapp-share-contacts",
}
export type MiniAppVerifyActionSuccessPayload = {
@@ -136,6 +138,30 @@ export type MiniAppSignTypedDataPayload =
| MiniAppSignTypedDataSuccessPayload
| MiniAppSignTypedDataErrorPayload;
+// Anchor: Share Contacts Payload
+export type Contact = {
+ username: string;
+ walletAddress: string;
+ profilePictureUrl: string | null;
+};
+
+export type MiniAppShareContactsSuccessPayload = {
+ status: "success";
+ contacts: Contact[];
+ version: number;
+ timestamp: string;
+};
+
+export type MiniAppShareContactsErrorPayload = {
+ status: "error";
+ error_code: ShareContactsErrorCodes;
+ version: number;
+};
+
+export type MiniAppShareContactsPayload =
+ | MiniAppShareContactsSuccessPayload
+ | MiniAppShareContactsErrorPayload;
+
type EventPayloadMap = {
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -143,6 +169,7 @@ type EventPayloadMap = {
[ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
[ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
+ [ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
};
export type EventPayload =