Skip to content

Commit

Permalink
Added support for sign transaction and a little bit of refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mmjee committed Nov 1, 2023
1 parent 8686b87 commit 7e27321
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export class ArcanaSolanaAPI {
case 'signMessage': {
return this.parseSignatureResponse(response as SignatureResRaw)
}
case 'signTransaction': {
return this.web3Module.VersionedTransaction.deserialize(
bs58.decode(response as string)
)
}
default: {
return response
}
Expand All @@ -48,15 +53,26 @@ export class ArcanaSolanaAPI {
}
}

async signMessage(data: Uint8Array, display: string): Promise<SignatureRes> {
const response = (await this.p.request({
signMessage(data: Uint8Array, display: string): Promise<SignatureRes> {
const r = this.request({
method: 'signMessage',
params: {
message: this.bs58Module.encode(data),
display,
},
})) as SignatureResRaw
})
return r as Promise<SignatureRes>
}

return this.parseSignatureResponse(response)
signTransaction(
tx: Web3Module.VersionedTransaction | Web3Module.Transaction
): Promise<Web3Module.VersionedTransaction> {
const r = this.request({
method: 'signTransaction',
params: {
message: this.bs58Module.encode(tx.serialize()),
},
})
return r as Promise<Web3Module.VersionedTransaction>
}
}

0 comments on commit 7e27321

Please sign in to comment.