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

generate only signature with json format tx transaction #947

Open
minemos opened this issue Apr 25, 2023 · 2 comments
Open

generate only signature with json format tx transaction #947

minemos opened this issue Apr 25, 2023 · 2 comments
Assignees
Labels

Comments

@minemos
Copy link

minemos commented Apr 25, 2023

Is your feature request related to a problem? Please describe.

I am using wallet connect v2 and when transaction sign request received, it give me json format transactions.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "solana_signTransaction",
    "params": {
        "feePayer": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm",
        "instructions": [{
            "programId": "Vote111111111111111111111111111111111111111",
            "data": "37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7",
            "keys": [{
                "isSigner": true,
                "isWritable": true,
                "pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm"
            }]
        }],
        "recentBlockhash": "2bUz6wu3axM8cDDncLB5chWuZaoscSjnoMD2nVvC1swe",
        "signatures": [{
            "pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm",
            "signature": "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4"
        }]
    }
}

I have to response signature, but I can't find how to do that.

I tried many things, but noting worked. Still singnature verify Failed

// this cause RangeError (byteOffset): Index out of range: index should be less than 3199: 3199
SignedTx.fromBytes(utf8.encode(jsonEncode(parameters))).toString()
// this cause verify Failed
final instructionsJson = parameters['instructions'] as List<dynamic>;
        final instructions = instructionsJson.map((json) {
          return Instruction(
              programId: Ed25519HDPublicKey.fromBase58(json['programId']),
              accounts: json['key'].runtimeType == List
                  ? (json['key'] as List<Map<String, dynamic>>)
                      .map((e) => AccountMeta(
                          pubKey: Ed25519HDPublicKey.fromBase58(e['pubKey']),
                          isWriteable: e['isWriteable'],
                          isSigner: e['isSigner']))
                      .toList()
                  : [],
              data: ByteArray.fromString(jsonEncode(json['data'])));
        }).toList();

        final message = Message(instructions: instructions);
        final compiledMessage = message.compile(
            recentBlockhash: parameters['recentBlockhash'],
            feePayer: Ed25519HDPublicKey.fromBase58(parameters['feePayer']));

        Signature sign = await wallet.sign(compiledMessage.toByteArray());

Describe the solution you'd like
A clear and concise description of what you want to happen.

I want to generate signature from json format transaction

@rhbrunetto rhbrunetto self-assigned this Jun 23, 2023
@elvinasn
Copy link

Any updates? have the same problem

@quetool
Copy link

quetool commented May 21, 2024

Hello @minemos @elvinasn! I hope I am not coming late to the party. I'm working on Supporting Solana (along with other chains on WalletConnectFlutterV2 sample wallet and I'm handling your scenario. It's a long shot but in case you are still seeking for help here it is the draft PR https://github.com/WalletConnect/WalletConnectFlutterV2/pull/289/files
You'll be interested mainly in example/wallet/lib/dependencies/chains/solana_service.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants