Skip to content

Commit

Permalink
Merge pull request #40 from aldrin-labs/feature/refund-manager-updates
Browse files Browse the repository at this point in the history
Feature/refund manager updates
  • Loading branch information
avernikoz authored Mar 21, 2024
2 parents 4511af7 + 9b55abe commit cce316f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
13 changes: 13 additions & 0 deletions examples/refund/get-current-refund-phase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { RefundManagerSingleton } from "../../src";
import { suiProviderUrl } from "../common";

// yarn ts-node examples/refund/get-current-refund-phase.ts
(async () => {
const refundManager = RefundManagerSingleton.getInstance(suiProviderUrl);

const result = await refundManager.getCurrentRefundPhase({
poolObjectId: RefundManagerSingleton.REFUND_POOL_OBJECT_ID,
});

console.debug("result: ", result);
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@avernikoz/rinbot-sui-sdk",
"version": "2.4.7",
"version": "2.4.8",
"description": "Sui Trading Bot SDK (typescript)",
"files": [
"dist"
Expand Down
44 changes: 41 additions & 3 deletions src/managers/refund/RefundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import { hexStringToByteArray } from "./utils";
* This class encapsulates the business logic for a Refund smart contract.
*/
export class RefundManagerSingleton {
public static REFUND_PACKAGE_ADDRESS = "";
public static SIMLATION_ACCOUNT_ADDRESS = "0xca9711c3de3ef474209ebd920b894e4d374ff09e210bc31cbd2d266f7bff90ca";
public static REFUND_PACKAGE_ADDRESS = "0xba5e4e9f24b0d7c329667e847c2173052fe2b21705bdb7f178b9ee5c063a0d13";
public static REFUND_PACKAGE_ADDRESS_READ = "";
public static REFUND_POOL_OBJECT_ID = "";
public static REFUND_POOL_PUBLISHER_OBJECT_ID = "";
public static REFUND_POOL_OBJECT_ID = "0x8ef9b807343db13b7659b443b2f687f2125b91e346893d94c3437b2121eac3b3";
public static REFUND_POOL_PUBLISHER_OBJECT_ID = "0x283c2f73647488150f294601a6fd36d2fec39773ce2060b052a7eccaf3ac448b";

public static REFUND_GAS_BUGET = 50_000_000;

Expand Down Expand Up @@ -102,6 +103,43 @@ export class RefundManagerSingleton {
return { tx, txRes };
}

public async getCurrentRefundPhase({
poolObjectId,
transaction,
}: {
poolObjectId: string;
transaction?: TransactionBlock;
}) {
const tx = transaction ?? new TransactionBlock();

const txRes = tx.moveCall({
target: `${RefundManagerSingleton.REFUND_PACKAGE_ADDRESS}::refund::phase`,
typeArguments: [],
arguments: [obj(tx, poolObjectId)],
});

tx.setGasBudget(RefundManagerSingleton.REFUND_GAS_BUGET);

const res = await this.provider.devInspectTransactionBlock({
sender: RefundManagerSingleton.SIMLATION_ACCOUNT_ADDRESS,
transactionBlock: tx,
});

if (!res.results) {
throw new Error("No results found for the request phase request");
}

const returnValues = res.results[0].returnValues;

if (!returnValues) {
throw new Error("Return values are undefined");
}

const phase = returnValues[0][0][0];

return phase;
}

public static getAllowBoostedClaim({
publisherObjectId,
poolObjectId,
Expand Down

0 comments on commit cce316f

Please sign in to comment.