Skip to content

Commit

Permalink
app-sol: support instruction type
Browse files Browse the repository at this point in the history
  • Loading branch information
rus7hex committed Mar 22, 2024
1 parent b36d74f commit 061a8e6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/app-sol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@secux/app-sol",
"version": "3.0.10",
"version": "3.0.11",
"description": "SecuX Hardware Wallet SOL API",
"keywords": [
"secux",
Expand Down
24 changes: 15 additions & 9 deletions packages/app-sol/src/app-sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,21 @@ export class SecuxSOL {
continue;
}

const { programId, keys, data } = ins as Instruction;
tx.addInstruction({
programId: toPublickey(programId),
accounts: keys.map(x => ({
...x,
publickey: toPublickey(x.pubkey),
})),
data: getBuffer(data)
});
try {
const { programId, keys, data } = ins as Instruction;
tx.addInstruction({
programId: toPublickey(programId),
accounts: keys.map(x => ({
...x,
publickey: toPublickey(x.pubkey),
})),
data: getBuffer(data)
});
}
catch {
//@ts-ignore
tx.addInstruction(ins);
}
}

tx.dataForSign(toPublickey(feePayer));
Expand Down
18 changes: 17 additions & 1 deletion packages/app-sol/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ export const ow_instruction = ow.object.partialShape({
data: ow.any(ow.string.empty, ow_communicationData)
});

export type HexInstruction = {
programId: HexString,
accounts: Array<{ publickey: HexString, isSigner: boolean, isWritable: boolean }>,
data: communicationData
};

export const ow_hexInstruction = ow.object.partialShape({
programId: ow_publickey,
accounts: ow.array.ofType(ow.object.partialShape({
publickey: ow_publickey,
isSigner: ow.boolean,
isWritable: ow.boolean
})),
data: ow.any(ow.string.empty, ow_communicationData)
});

export enum InstructionType {
SetUnitLimit = "setComputeUnitLimit",
SetUnitPrice = "setComputeUnitPrice",
Expand Down Expand Up @@ -118,7 +134,7 @@ export const ow_ownership = ow.object.partialShape({
});
export const ow_txDetail = ow.object.partialShape({
recentBlockhash: ow_address,
instructions: ow.array.ofType(ow.any(ow_instruction, ow_builtinInstruction)).nonEmpty,
instructions: ow.array.ofType(ow.any(ow_builtinInstruction, ow_instruction, ow_hexInstruction)).nonEmpty,
ownerships: ow.array.ofType(ow_ownership).nonEmpty,
txType: ow.any(ow.undefined, ow_TransactionType)
});
Expand Down

0 comments on commit 061a8e6

Please sign in to comment.