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

Unexpected fuel_price Value in ixObject Despite Setting fuelPrice to 0 #79

Closed
sarvalabs-pawankalyan opened this issue Aug 21, 2024 · 1 comment · Fixed by #80
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers signer Issues related to signer

Comments

@sarvalabs-pawankalyan
Copy link

Description

Note

We recently enabled zero-fuel interactions on the Sephorum network.

When attempting to deploy the contract, I encounter the following error:

Screenshot 2024-08-21 at 2 30 17 PM

Code:

fuel = {
        fuelPrice: 0,
        fuelLimit: 100000,
};

private async initWallet(): Promise<moi.Wallet> {
        const wallet = await moi.Wallet.fromMnemonic(mnemonic, keyPath);
        wallet.connect(provider);
        return wallet;
    }

    private async getLogicDriver(): Promise<moi.LogicDriver<any>> {
        const wallet = await this.initWallet();
        const logicDriver = await moi.getLogicDriver(logicID, wallet);
        return logicDriver;
    }

    async deploy() {
        try {
            const wallet = await this.initWallet();
            console.log(wallet.address);
            const factory = new moi.LogicFactory(manifest, wallet);
            const ix = await factory.deploy("Init", [this.fuel]);
            const result = await ix.result();
            const response: ixResponse = {
                status: "success",
                result: result,
            };
            return response;
        } catch (err) {
            console.log(err);
            const result: ixResponse = {
                status: "failed",
                error: err,
            };
            return result;
        }
    }

Potential Cause:

Despite passing the fuelPrice as 0 in the deploy() function

fuel = {
        fuelPrice: 0,
        fuelLimit: 100000,
};

const ix = await factory.deploy("Init", [this.fuel]);

The ixObject parameter in js-moi-wallet > wallet.js is receiving a fuel_price value of 1.

signInteraction(ixObject, sigAlgo) {
        try {
            console.log(ixObject);
            const ixData = (0, serializer_1.serializeIxObject)(ixObject);
            const signature = this.sign(ixData, sigAlgo);
            return {
                ix_args: (0, js_moi_utils_1.bytesToHex)(ixData),
                signature: signature,
            };
        }
        catch (err) {
            js_moi_utils_1.ErrorUtils.throwError("Failed to sign interaction", js_moi_utils_1.ErrorCode.UNKNOWN_ERROR, { originalError: err });
        }
    }

ixObject Data:

Screenshot 2024-08-21 at 2 40 06 PM

Expected Output:

The fuel_price should be set according to the value provided by the user.

Actual Output:

The fuel_price is set to 1, despite the user passing it as 0.

@sarvalabs-harshrastogi sarvalabs-harshrastogi added signer Issues related to signer bug Something isn't working labels Aug 21, 2024
@sarvalabs-harshrastogi sarvalabs-harshrastogi linked a pull request Aug 21, 2024 that will close this issue
7 tasks
@sarvalabs-harshrastogi sarvalabs-harshrastogi added the good first issue Good for newcomers label Aug 21, 2024
@sarvalabs-harshrastogi
Copy link
Member

Closed in #80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers signer Issues related to signer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants