okx / js-wallet-sdk

Multi-chain typescript signature sdk, supports bitcoin, ethereum, solana, cosmos, etc.
https://okx.github.io/js-wallet-sdk/#/
MIT License
234 stars 87 forks source link

OKX web3 wallet using "@okwallet/aptos-wallet-adapter": "^0.0.3" Network fee estimation failed #115

Closed yenkhoon closed 3 months ago

yenkhoon commented 4 months ago

telegram-cloud-photo-size-5-6129517703124337497-y

code snipplet

let transaction: InputTransactionData = {
            data: {
                function: "0x1::code::publish_package_txn",
                typeArguments: undefined,
                functionArguments: [hexToByteArray(metadataBytes), [hexToByteArray(byteCode)]],
            },
            options: {
                gasUnitPrice: processedGasUnitPrice
            }
        };

   const pendingTransaction = await signAndSubmitTransaction(transaction);     
evieyee commented 4 months ago

Perhaps you could provide more detailed test cases or examples of your modified code to help us diagnose the issue. I noticed that "signAndSubmitTransaction" is not a method provided by the SDK. You can refer to the SDK's AptosCustomParam and createRawTransactionByABI to complete other formats of signing.

yenkhoon commented 4 months ago

Perhaps you could provide more detailed test cases or examples of your modified code to help us diagnose the issue. I noticed that "signAndSubmitTransaction" is not a method provided by the SDK. You can refer to the SDK's AptosCustomParam and createRawTransactionByABI to complete other formats of signing.

Could you link me the url on these information?

currently the signandsubmit is using aptos library.

yenkhoon commented 4 months ago

btw this is publish package txn there is no module data.

For other transaction like transfer, bondingcurve buy sell, it has no problem. Only publish package is having problem, I think you might wanna escalate this issue to the web3 wallet team on this, because upon publish package there is only 3 things needed (function, typeArugments and functionArguments). Prolly, the core web3 okx wallet doesn't allow typeArguments to be empty. @evieyee

evieyee commented 4 months ago

Perhaps you could provide more detailed test cases or examples of your modified code to help us diagnose the issue. I noticed that "signAndSubmitTransaction" is not a method provided by the SDK. You can refer to the SDK's AptosCustomParam and createRawTransactionByABI to complete other formats of signing.

Could you link me the url on these information?

currently the signandsubmit is using aptos library.

Here's an example, see if you find it helpful here: https://github.com/okx/js-wallet-sdk/blob/main/packages/coin-aptos/tests/aptos.test.ts#L99

yenkhoon commented 4 months ago

Perhaps you could provide more detailed test cases or examples of your modified code to help us diagnose the issue. I noticed that "signAndSubmitTransaction" is not a method provided by the SDK. You can refer to the SDK's AptosCustomParam and createRawTransactionByABI to complete other formats of signing.

Could you link me the url on these information? currently the signandsubmit is using aptos library.

Here's an example, see if you find it helpful here: https://github.com/okx/js-wallet-sdk/blob/main/packages/coin-aptos/tests/aptos.test.ts#L99

I have checked the test files, none of them suitable, we do not have abi. As this is a publish package txn as I mentioned earlier.

evieyee commented 3 months ago

Here is a code reference that you can modify on your fork. You might see this update in the latest code in the future, but it is not mandatory! Thank you for your feedback.


export function publishPackagePayload(metadata: string | HexString, bytecode: string | HexString) {
    let metadataBytes = metadata instanceof HexString ? metadata.toUint8Array() : hexToBytes(metadata)
    let bytecodeBytes = bytecode instanceof HexString ? bytecode.toUint8Array() : hexToBytes(bytecode)

    metadataBytes = BCS.bcsSerializeBytes(metadataBytes)
    bytecodeBytes = BCS.serializeVectorWithFunc([bytecodeBytes], "serializeBytes");
    return new TxnBuilderTypes.TransactionPayloadEntryFunction(

        TxnBuilderTypes.EntryFunction.natural(
            '0x1::code',
            'publish_package_txn',
            [],
            [metadataBytes, bytecodeBytes],
        ),
    );
}
test("buildRawTransaction with publishPackagePayload ", async () => {
        const account = new AptosAccount(base.fromHex("privateKey"))
        const sequenceNumber= 0
        const chainId= 1
        const maxGasAmount = 500000;
        const gasUnitPrice = 100
        const expirationTimestampSecs = 1723028868
        const metadataHex = ""
        const bytecodeHex = ""

        const payload = publishPackagePayload(metadataHex,bytecodeHex)
        let sender = account.address()
        const rawTxn = createRawTransaction(
            sender,
            payload,
            BigInt(sequenceNumber),
            chainId,
            BigInt(maxGasAmount),
            BigInt(gasUnitPrice),
            BigInt(expirationTimestampSecs))
        const RawTx = generateBCSTransaction(account, rawTxn);
    });

Perhaps you could provide more detailed test cases or examples of your modified code to help us diagnose the issue. I noticed that "signAndSubmitTransaction" is not a method provided by the SDK. You can refer to the SDK's AptosCustomParam and createRawTransactionByABI to complete other formats of signing.

Could you link me the url on these information? currently the signandsubmit is using aptos library.

Here's an example, see if you find it helpful here: https://github.com/okx/js-wallet-sdk/blob/main/packages/coin-aptos/tests/aptos.test.ts#L99

I have checked the test files, none of them suitable, we do not have abi. As this is a publish package txn as I mentioned earlier.