Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: plugin-omniflix #2902

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/plugin-omniflix/src/actions/bank/send_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SendTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,21 @@ const buildTransferDetails = async (
message: Memory,
state: State
): Promise<SendTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);

// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const transferContext = composeContext({
state,
state: currentState,
template: sendTokensTemplate,
});

Expand Down
18 changes: 12 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/cancel_unbonding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CancelUnbondingAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -135,14 +135,20 @@ const buildCancelUnbondingContent = async (
message: Memory,
state: State
): Promise<CancelUnbondingContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const cancelUnbondingContext = composeContext({
state,
state: currentState,
template: cancelUnbondingTemplate,
});

Expand Down
19 changes: 13 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/delegate_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class DelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,21 @@ const buildDelegateTokensContent = async (
message: Memory,
state: State
): Promise<DelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);

// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const delegateContext = composeContext({
state,
state: currentState,
template: delegateTokensTemplate,
});

Expand Down
17 changes: 11 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/redelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class RedelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -150,14 +150,19 @@ const buildRedelegateDetails = async (
message: Memory,
state: State
): Promise<RedelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }
let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const redelegateContext = composeContext({
state,
state: currentState,
template: redelegateTokensTemplate,
});

Expand Down
18 changes: 12 additions & 6 deletions packages/plugin-omniflix/src/actions/staking/undelegate_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class UndelegateTokensAction {
if (typeof params.amount === "number") {
params.amount = params.amount * 1000000;
} else if (typeof params.amount === "string") {
params.amount = parseInt(params.amount) * 1000000;
params.amount = Number.parseInt(params.amount) * 1000000;
}
}

Expand All @@ -128,14 +128,20 @@ const buildUndelegateTokensContent = async (
message: Memory,
state: State
): Promise<UndelegateTokensContent> => {
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
state = await runtime.updateRecentMessageState(state);
// if (!state) {
// state = (await runtime.composeState(message)) as State;
// } else {
// state = await runtime.updateRecentMessageState(state);
// }

let currentState: State = state;
if (!currentState) {
currentState = (await runtime.composeState(message)) as State;
}
currentState = await runtime.updateRecentMessageState(currentState);

const undelegateContext = composeContext({
state,
state: currentState,
template: undelegateTokensTemplate,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Plugin } from "@elizaos/core";
import type { Plugin } from "@elizaos/core";
import providers from "./providers/index.ts";
import actions from "./actions/index.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/providers/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class BankProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in sendTokens: " + e);
elizaLogger.error(`Error in sendTokens: ${e}`);
throw e;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-omniflix/src/providers/gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GovProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in voteOnProposal: " + e);
elizaLogger.error(`Error in voteOnProposal: ${e}`);
throw e;
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-omniflix/src/providers/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in delegate: " + e);
elizaLogger.error(`Error in delegate: ${e}`);
throw e;
}
}
Expand All @@ -53,7 +53,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in undelegate: " + e);
elizaLogger.error(`Error in undelegate: ${e}`);
throw e;
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in redelegate: " + e);
elizaLogger.error(`Error in redelegate: ${e}`);
throw e;
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ export class StakingProvider {
);
return tx;
} catch (e) {
elizaLogger.error("Error in cancelUnbondingDelegation: " + e);
elizaLogger.error(`Error in cancelUnbondingDelegation: ${e}`);
throw e;
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/plugin-omniflix/src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ export const walletProvider: Provider = {
"omniflix"
);
elizaLogger.info("Wallet initialized with private key");
} else {
} else if (mnemonic) {
// Use mnemonic
wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic!, {
wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
prefix: "omniflix",
});
elizaLogger.info("Wallet initialized with mnemonic");
} else {
throw new Error("Neither private key nor mnemonic available");
}

const client = await SigningStargateClient.connectWithSigner(
Expand Down
Loading