Skip to content

Commit

Permalink
feat: add governance flag
Browse files Browse the repository at this point in the history
  • Loading branch information
burnt-sun committed Nov 15, 2024
1 parent 4f1e335 commit 9890087
Show file tree
Hide file tree
Showing 4 changed files with 6,263 additions and 5,101 deletions.
10 changes: 9 additions & 1 deletion packages/abstraxion-core/src/AbstraxionAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export class AbstraxionAuth {
bank?: SpendLimit[];
callbackUrl?: string;
treasury?: string;

governance?: boolean;

// Signer
private client?: GranteeSignerClient;

Expand All @@ -44,6 +45,7 @@ export class AbstraxionAuth {
* @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
* @param {boolean} [governance] - Indicates whether governance is enabled.
*/
configureAbstraxionInstance(
rpc: string,
Expand All @@ -53,6 +55,7 @@ export class AbstraxionAuth {
bank?: SpendLimit[],
callbackUrl?: string,
treasury?: string,
governance?: boolean,
) {
this.rpcUrl = rpc;
this.restUrl = restUrl;
Expand All @@ -61,6 +64,7 @@ export class AbstraxionAuth {
this.bank = bank;
this.callbackUrl = callbackUrl;
this.treasury = treasury;
this.governance = governance;
}

/**
Expand Down Expand Up @@ -262,6 +266,10 @@ export class AbstraxionAuth {
urlParams.set("stake", "true");
}

if (this.governance) {
urlParams.set("governance", "true");
}

if (this.grantContracts) {
urlParams.set("contracts", JSON.stringify(this.grantContracts));
}
Expand Down
2 changes: 2 additions & 0 deletions packages/abstraxion/src/components/Abstraxion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface AbstraxionConfig {
callbackUrl?: string;
treasury?: string;
gasPrice?: string;
governance?: boolean;
}

export function AbstraxionProvider({
Expand All @@ -82,6 +83,7 @@ export function AbstraxionProvider({
return (
<AbstraxionContextProvider
contracts={config.contracts}
governance={config.governance}
rpcUrl={config.rpcUrl}
restUrl={config.restUrl}
stake={config.stake}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface AbstraxionContextProps {
stake?: boolean;
bank?: SpendLimit[];
treasury?: string;
governance?: boolean;
gasPrice: GasPrice;
logout: () => void;
}
Expand All @@ -52,6 +53,7 @@ export function AbstraxionContextProvider({
bank,
callbackUrl,
treasury,
governance,
gasPrice,
}: {
children: ReactNode;
Expand All @@ -63,6 +65,7 @@ export function AbstraxionContextProvider({
bank?: SpendLimit[];
callbackUrl?: string;
treasury?: string;
governance?: boolean;
gasPrice?: string;
}): JSX.Element {
const [abstraxionError, setAbstraxionError] = useState("");
Expand Down Expand Up @@ -91,8 +94,9 @@ export function AbstraxionContextProvider({
bank,
callbackUrl,
treasury,
governance,
);
}, [rpcUrl, restUrl, contracts, stake, bank, callbackUrl, treasury]);
}, [rpcUrl, restUrl, contracts, stake, bank, callbackUrl, treasury, governance]);

useEffect(() => {
configureInstance();
Expand Down Expand Up @@ -170,6 +174,7 @@ export function AbstraxionContextProvider({
stake,
bank,
treasury,
governance,
logout,
gasPrice: gasPrice ? GasPrice.fromString(gasPrice) : gasPriceDefault,
}}
Expand Down
Loading

0 comments on commit 9890087

Please sign in to comment.