diff --git a/.changeset/slow-kangaroos-glow.md b/.changeset/slow-kangaroos-glow.md
new file mode 100644
index 00000000..10c25d02
--- /dev/null
+++ b/.changeset/slow-kangaroos-glow.md
@@ -0,0 +1,7 @@
+---
+"@burnt-labs/abstraxion-core": minor
+"@burnt-labs/abstraxion": minor
+"demo-app": minor
+---
+
+Introduce treasury contract parameter. Look into the Abstraxion/README or the demo-app/layout for more information
diff --git a/apps/demo-app/src/app/layout.tsx b/apps/demo-app/src/app/layout.tsx
index 4ac92dca..ff657102 100644
--- a/apps/demo-app/src/app/layout.tsx
+++ b/apps/demo-app/src/app/layout.tsx
@@ -10,6 +10,34 @@ const inter = Inter({ subsets: ["latin"] });
const seatContractAddress =
"xion1z70cvc08qv5764zeg3dykcyymj5z6nu4sqr7x8vl4zjef2gyp69s9mmdka";
+const legacyConfig = {
+ contracts: [
+ // Usually, you would have a list of different contracts here
+ seatContractAddress,
+ {
+ address: seatContractAddress,
+ amounts: [{ denom: "uxion", amount: "1000000" }],
+ },
+ ],
+ stake: true,
+ bank: [
+ {
+ denom: "uxion",
+ amount: "1000000",
+ },
+ ],
+ // Optional params to activate mainnet config
+ // rpcUrl: "https://rpc.xion-mainnet-1.burnt.com:443",
+ // restUrl: "https://api.xion-mainnet-1.burnt.com:443",
+};
+
+const treasuryConfig = {
+ treasury: "xion17ah4x9te3sttpy2vj5x6hv4xvc0td526nu0msf7mt3kydqj4qs2s9jhe90", // Example XION treasury contract
+ // Optional params to activate mainnet config
+ // rpcUrl: "https://rpc.xion-mainnet-1.burnt.com:443",
+ // restUrl: "https://api.xion-mainnet-1.burnt.com:443",
+};
+
export default function RootLayout({
children,
}: {
@@ -18,25 +46,7 @@ export default function RootLayout({
return (
-
+
{children}
diff --git a/packages/abstraxion-core/src/AbstraxionAuth.ts b/packages/abstraxion-core/src/AbstraxionAuth.ts
index b4e75d8f..c7d61f83 100644
--- a/packages/abstraxion-core/src/AbstraxionAuth.ts
+++ b/packages/abstraxion-core/src/AbstraxionAuth.ts
@@ -12,6 +12,7 @@ export class AbstraxionAuth {
stake?: boolean;
bank?: SpendLimit[];
callbackUrl?: string;
+ treasury?: string;
// Signer
private client?: GranteeSignerClient;
@@ -38,6 +39,7 @@ export class AbstraxionAuth {
* @param {boolean} [stake] - Indicates whether staking is enabled.
* @param {SpendLimit[]} [bank] - The spend limits for the user.
* @param {string} callbackUrl - preferred callback url to override default
+ * @param {string} treasury - treasury contract instance address
*/
configureAbstraxionInstance(
rpc: string,
@@ -46,6 +48,7 @@ export class AbstraxionAuth {
stake?: boolean,
bank?: SpendLimit[],
callbackUrl?: string,
+ treasury?: string,
) {
this.rpcUrl = rpc;
this.restUrl = restUrl;
@@ -53,6 +56,7 @@ export class AbstraxionAuth {
this.stake = stake;
this.bank = bank;
this.callbackUrl = callbackUrl;
+ this.treasury = treasury;
}
/**
@@ -242,6 +246,10 @@ export class AbstraxionAuth {
const currentUrl = this.callbackUrl || window.location.href;
const urlParams = new URLSearchParams();
+ if (this.treasury) {
+ urlParams.set("treasury", this.treasury);
+ }
+
if (this.bank) {
urlParams.set("bank", JSON.stringify(this.bank));
}
@@ -250,12 +258,11 @@ export class AbstraxionAuth {
urlParams.set("stake", "true");
}
- urlParams.set("grantee", userAddress);
-
if (this.grantContracts) {
urlParams.set("contracts", JSON.stringify(this.grantContracts));
}
+ urlParams.set("grantee", userAddress);
urlParams.set("redirect_uri", currentUrl);
const queryString = urlParams.toString(); // Convert URLSearchParams to string
diff --git a/packages/abstraxion/README.md b/packages/abstraxion/README.md
index 5a594bf1..a62c8792 100644
--- a/packages/abstraxion/README.md
+++ b/packages/abstraxion/README.md
@@ -14,7 +14,7 @@ npm i @burnt-labs/abstraxion
Find an implementation demo here: [abstraxion demo](../../apps/demo-app)
-First, wrap your app in the `AbstraxionProvider` at the top level
+First, wrap your app in the `AbstraxionProvider` at the top level with the appropriate config
```
"use client";
@@ -29,55 +29,35 @@ const inter = Inter({ subsets: ["latin"] });
const seatContractAddress =
"xion1z70cvc08qv5764zeg3dykcyymj5z6nu4sqr7x8vl4zjef2gyp69s9mmdka";
-export default function RootLayout({
- children,
-}: {
- children: React.ReactNode;
-}): JSX.Element {
- return (
-
-
-
- {children}
-
-
-
- );
-}
-```
-
-to activate Mainnet just add rpcUrl and restUrl endpoints to the config:
-
-```
-"use client";
-import "./globals.css";
-import { Inter } from "next/font/google";
-import { AbstraxionProvider } from "@burnt-labs/abstraxion";
-import "@burnt-labs/abstraxion/dist/index.css";
-
-const inter = Inter({ subsets: ["latin"] });
-
-// Example XION seat contract
-const seatContractAddress =
- "xion1z70cvc08qv5764zeg3dykcyymj5z6nu4sqr7x8vl4zjef2gyp69s9mmdka";
+// Legacy config with individual params for stake, bank and contracts
+const legacyConfig = {
+ contracts: [
+ // Usually, you would have a list of different contracts here
+ seatContractAddress,
+ {
+ address: seatContractAddress,
+ amounts: [{ denom: "uxion", amount: "1000000" }],
+ },
+ ],
+ stake: true,
+ bank: [
+ {
+ denom: "uxion",
+ amount: "1000000",
+ },
+ ],
+ // Optional params to activate mainnet config
+ // rpcUrl: "https://rpc.xion-mainnet-1.burnt.com:443",
+ // restUrl: "https://api.xion-mainnet-1.burnt.com:443",
+};
+
+// New treasury contract config
+const treasuryConfig = {
+ treasury: "xion17ah4x9te3sttpy2vj5x6hv4xvc0td526nu0msf7mt3kydqj4qs2s9jhe90", // Example XION treasury contract
+ // Optional params to activate mainnet config
+ // rpcUrl: "https://rpc.xion-mainnet-1.burnt.com:443",
+ // restUrl: "https://api.xion-mainnet-1.burnt.com:443",
+};
export default function RootLayout({
children,
@@ -87,27 +67,7 @@ export default function RootLayout({
return (
-
+
{children}
diff --git a/packages/abstraxion/src/components/Abstraxion/index.tsx b/packages/abstraxion/src/components/Abstraxion/index.tsx
index 51ffcae3..f34551cf 100644
--- a/packages/abstraxion/src/components/Abstraxion/index.tsx
+++ b/packages/abstraxion/src/components/Abstraxion/index.tsx
@@ -66,6 +66,7 @@ export interface AbstraxionConfig {
stake?: boolean;
bank?: SpendLimit[];
callbackUrl?: string;
+ treasury?: string;
}
export function AbstraxionProvider({
@@ -83,6 +84,7 @@ export function AbstraxionProvider({
stake={config.stake}
bank={config.bank}
callbackUrl={config.callbackUrl}
+ treasury={config.treasury}
>
{children}
diff --git a/packages/abstraxion/src/components/AbstraxionContext/index.tsx b/packages/abstraxion/src/components/AbstraxionContext/index.tsx
index 1de87cb9..c252db61 100644
--- a/packages/abstraxion/src/components/AbstraxionContext/index.tsx
+++ b/packages/abstraxion/src/components/AbstraxionContext/index.tsx
@@ -33,6 +33,7 @@ export interface AbstraxionContextProps {
restUrl: string;
stake?: boolean;
bank?: SpendLimit[];
+ treasury?: string;
logout: () => void;
}
@@ -48,6 +49,7 @@ export function AbstraxionContextProvider({
stake = false,
bank,
callbackUrl,
+ treasury,
}: {
children: ReactNode;
contracts?: ContractGrantDescription[];
@@ -57,6 +59,7 @@ export function AbstraxionContextProvider({
stake?: boolean;
bank?: SpendLimit[];
callbackUrl?: string;
+ treasury?: string;
}): JSX.Element {
const [abstraxionError, setAbstraxionError] = useState("");
const [isConnected, setIsConnected] = useState(false);
@@ -77,8 +80,9 @@ export function AbstraxionContextProvider({
stake,
bank,
callbackUrl,
+ treasury,
);
- }, [rpcUrl, restUrl, contracts, stake, bank, callbackUrl]);
+ }, [rpcUrl, restUrl, contracts, stake, bank, callbackUrl, treasury]);
useEffect(() => {
const searchParams = new URLSearchParams(window.location.search);
@@ -116,6 +120,7 @@ export function AbstraxionContextProvider({
restUrl,
stake,
bank,
+ treasury,
logout,
}}
>