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

Fixed & improved engine token transferring #164

Merged
merged 16 commits into from
Nov 9, 2024
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
2 changes: 1 addition & 1 deletion public/sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/sw.js.map

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions src/api/hive-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const getTokenBalances = (account: string): Promise<TokenBalance[]> => {
});
};

const getTokens = (tokens: string[]): Promise<Token[]> => {
export const getTokens = (tokens: string[]): Promise<Token[]> => {
const data = {
jsonrpc: "2.0",
method: "find",
Expand Down Expand Up @@ -140,10 +140,3 @@ export const getMetrics: any = async (symbol?: any, account?: any) => {
return [];
});
};

export const getMarketData = async (symbol: any) => {
const { data: history } = await appAxios.get(apiBase(`${engine.chartAPI}`), {
params: { symbol, interval: "daily" }
});
return history;
};
351 changes: 0 additions & 351 deletions src/api/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,357 +1422,6 @@ export const updatePassword = (
ownerKey: PrivateKey
): Promise<TransactionConfirmation> => hiveClient.broadcast.updateAccount(update, ownerKey);

// HE Operations
export const transferHiveEngineKc = (
from: string,
to: string,
symbol: string,
amount: string,
memo: string
) => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "transfer",
contractPayload: {
symbol,
to,
quantity: amount.toString(),
memo
}
});

return keychain.customJson(from, "ssc-mainnet-hive", "Active", json, "Transfer");
};
export const delegateHiveEngineKc = (from: string, to: string, symbol: string, amount: string) => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "delegate",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

return keychain.customJson(from, "ssc-mainnet-hive", "Active", json, "Transfer");
};
export const undelegateHiveEngineKc = (
from: string,
to: string,
symbol: string,
amount: string
) => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "undelegate",
contractPayload: {
symbol,
from: to,
quantity: amount.toString()
}
});

return keychain.customJson(from, "ssc-mainnet-hive", "Active", json, "Transfer");
};
export const stakeHiveEngineKc = (from: string, to: string, symbol: string, amount: string) => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "stake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

return keychain.customJson(from, "ssc-mainnet-hive", "Active", json, "Transfer");
};
export const unstakeHiveEngineKc = (from: string, to: string, symbol: string, amount: string) => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "unstake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

return keychain.customJson(from, "ssc-mainnet-hive", "Active", json, "Transfer");
};

// HE Hive Signer Operations
export const transferHiveEngineHs = (
from: string,
to: string,
symbol: string,
amount: string,
memo: string
): any => {
const params = {
authority: "active",
required_auths: `["${from}"]`,
required_posting_auths: "[]",
id: "ssc-mainnet-hive",
json: JSON.stringify({
contractName: "tokens",
contractAction: "transfer",
contractPayload: {
symbol,
to,
quantity: amount.toString(),
memo
}
})
};

return hotSign("custom-json", params, `@${from}/engine`);
};

export const delegateHiveEngineHs = (
from: string,
to: string,
symbol: string,
amount: string
): any => {
const params = {
authority: "active",
required_auths: `["${from}"]`,
required_posting_auths: "[]",
id: "ssc-mainnet-hive",
json: JSON.stringify({
contractName: "tokens",
contractAction: "delegate",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
})
};

return hotSign("custom-json", params, `@${from}/engine`);
};

export const undelegateHiveEngineHs = (
from: string,
to: string,
symbol: string,
amount: string
): any => {
const params = {
authority: "active",
required_auths: `["${from}"]`,
required_posting_auths: "[]",
id: "ssc-mainnet-hive",
json: JSON.stringify({
contractName: "tokens",
contractAction: "undelegate",
contractPayload: {
symbol,
from: to,
quantity: amount.toString()
}
})
};

return hotSign("custom-json", params, `@${from}/engine`);
};

export const stakeHiveEngineHs = (
from: string,
to: string,
symbol: string,
amount: string
): any => {
const params = {
authority: "active",
required_auths: `["${from}"]`,
required_posting_auths: "[]",
id: "ssc-mainnet-hive",
json: JSON.stringify({
contractName: "tokens",
contractAction: "stake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
})
};

return hotSign("custom-json", params, `@${from}/engine`);
};

export const unstakeHiveEngineHs = (
from: string,
to: string,
symbol: string,
amount: string
): any => {
const params = {
authority: "active",
required_auths: `["${from}"]`,
required_posting_auths: "[]",
id: "ssc-mainnet-hive",
json: JSON.stringify({
contractName: "tokens",
contractAction: "unstake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
})
};

return hotSign("custom-json", params, `@${from}/engine`);
};

//HE Key Operations
export const transferHiveEngineKey = async (
from: string,
key: PrivateKey,
symbol: string,
to: string,
amount: string,
memo: string
): Promise<TransactionConfirmation> => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "transfer",
contractPayload: {
symbol,
to,
quantity: amount.toString(),
memo
}
});

const op = {
id: "ssc-mainnet-hive",
json,
required_auths: [from],
required_posting_auths: []
};

const result = await hiveClient.broadcast.json(op, key);

return result;
};

export const delegateHiveEngineKey = async (
from: string,
key: PrivateKey,
symbol: string,
to: string,
amount: string
): Promise<TransactionConfirmation> => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "delegate",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

const op = {
id: "ssc-mainnet-hive",
json,
required_auths: [from],
required_posting_auths: []
};

const result = await hiveClient.broadcast.json(op, key);
return result;
};

export const undelegateHiveEngineKey = async (
from: string,
key: PrivateKey,
symbol: string,
to: string,
amount: string
): Promise<TransactionConfirmation> => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "undelegate",
contractPayload: {
symbol,
from: to,
quantity: amount.toString()
}
});

const op = {
id: "ssc-mainnet-hive",
json,
required_auths: [from],
required_posting_auths: []
};

const result = await hiveClient.broadcast.json(op, key);
return result;
};

export const stakeHiveEngineKey = async (
from: string,
key: PrivateKey,
symbol: string,
to: string,
amount: string
): Promise<TransactionConfirmation> => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "stake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

const op = {
id: "ssc-mainnet-hive",
json,
required_auths: [from],
required_posting_auths: []
};

const result = await hiveClient.broadcast.json(op, key);
return result;
};

export const unstakeHiveEngineKey = async (
from: string,
key: PrivateKey,
symbol: string,
to: string,
amount: string
): Promise<TransactionConfirmation> => {
const json = JSON.stringify({
contractName: "tokens",
contractAction: "stake",
contractPayload: {
symbol,
to,
quantity: amount.toString()
}
});

const op = {
id: "ssc-mainnet-hive",
json,
required_auths: [from],
required_posting_auths: []
};

const result = await hiveClient.broadcast.json(op, key);
return result;
};

export const Revoke = (
account: string,
weight_threshold: number,
Expand Down
Loading
Loading