Skip to content

Commit a8231d0

Browse files
author
Jeff Yanta
committed
Add support for VM airdrop virtual instruction
1 parent eed91c1 commit a8231d0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/solana/cvm/types_opcode.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const (
1414
OpcodeExternalRelay Opcode = 20
1515

1616
OpcodeConditionalTransfer Opcode = 12
17+
18+
OpcodeAirdrop Opcode = 30
1719
)
1820

1921
func putOpcode(dst []byte, v Opcode, offset *int) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cvm
2+
3+
const (
4+
AirdropVirtrualInstructionDataSize = (SignatureSize + // signature
5+
8 + // amount
6+
1) // count
7+
)
8+
9+
type AirdropVirtualInstructionArgs struct {
10+
Amount uint64
11+
Count uint8
12+
Signature Signature
13+
}
14+
15+
func NewAirdropVirtualInstruction(
16+
args *AirdropVirtualInstructionArgs,
17+
) VirtualInstruction {
18+
var offset int
19+
data := make([]byte, AirdropVirtrualInstructionDataSize)
20+
putSignature(data, args.Signature, &offset)
21+
putUint64(data, args.Amount, &offset)
22+
putUint8(data, args.Count, &offset)
23+
24+
return VirtualInstruction{
25+
Opcode: OpcodeAirdrop,
26+
Data: data,
27+
}
28+
}

0 commit comments

Comments
 (0)