Save solana signTransaction progress

This commit is contained in:
Ilja 2022-03-15 13:30:41 +02:00
parent 4d593758e7
commit dd81e04445
5 changed files with 16 additions and 9 deletions

View File

@ -28,9 +28,6 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
const { method } = request const { method } = request
const requestSession = await walletConnectClient.session.get(topic) const requestSession = await walletConnectClient.session.get(topic)
console.log(requestEvent, requestSession)
console.log(method)
switch (method) { switch (method) {
case EIP155_SIGNING_METHODS.ETH_SIGN: case EIP155_SIGNING_METHODS.ETH_SIGN:
case EIP155_SIGNING_METHODS.PERSONAL_SIGN: case EIP155_SIGNING_METHODS.PERSONAL_SIGN:

View File

@ -54,7 +54,6 @@ export default class CosmosLib {
} }
public async signDirect(address: string, signDoc: SignDoc) { public async signDirect(address: string, signDoc: SignDoc) {
console.log(signDoc)
const signDocBytes = makeSignBytes(signDoc) const signDocBytes = makeSignBytes(signDoc)
// @ts-expect-error // @ts-expect-error
return await this.directSigner.signDirect(address, signDocBytes) return await this.directSigner.signDirect(address, signDocBytes)

View File

@ -58,7 +58,6 @@ export class EIP155 {
} }
public async signDirect(address: string, signDoc: SignDoc) { public async signDirect(address: string, signDoc: SignDoc) {
console.log(signDoc)
const signDocBytes = makeSignBytes(signDoc) const signDocBytes = makeSignBytes(signDoc)
// @ts-expect-error // @ts-expect-error
return await this.directSigner.signDirect(address, signDocBytes) return await this.directSigner.signDirect(address, signDocBytes)

View File

@ -28,17 +28,28 @@ export class Solana {
public async signTransaction( public async signTransaction(
feePayer: string, feePayer: string,
recentBlockhash: string, recentBlockhash: string,
instructions: TransactionInstructionCtorFields instructions: TransactionInstructionCtorFields[]
) { ) {
const tx = new Transaction({ const tx = new Transaction({
feePayer: new PublicKey(feePayer), feePayer: new PublicKey(feePayer),
recentBlockhash recentBlockhash
}) })
tx.add(instructions)
tx.add(
...instructions.map(i => ({
programId: new PublicKey(i.programId),
data: i.data ? Buffer.from(i.data) : Buffer.from([]),
keys: i.keys.map(k => ({
...k,
pubkey: new PublicKey(k.pubkey)
}))
}))
)
await tx.sign(this.keypair) await tx.sign(this.keypair)
console.log(tx)
const { signature } = tx.signatures[tx.signatures.length - 1] const { signature } = tx.signatures[tx.signatures.length - 1]
return signature return { signature }
} }
} }

View File

@ -20,6 +20,7 @@ export async function approveSolanaRequest(requestEvent: RequestEvent) {
params.recentBlockhash, params.recentBlockhash,
params.instructions params.instructions
) )
return formatJsonRpcResult(id, signedTransaction) return formatJsonRpcResult(id, signedTransaction)
default: default: