-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstruction.go
45 lines (41 loc) · 1.47 KB
/
instruction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package transaction
import (
"github.com/code-payments/code-server/pkg/solana"
splitter_token "github.com/code-payments/code-server/pkg/solana/splitter"
"github.com/code-payments/code-server/pkg/solana/system"
"github.com/code-payments/code-server/pkg/code/common"
)
// todo: start moving instruction construction code here
func makeAdvanceNonceInstruction(nonce *common.Account) (solana.Instruction, error) {
return system.AdvanceNonce(
nonce.PublicKey().ToBytes(),
common.GetSubsidizer().PublicKey().ToBytes(),
), nil
}
func makeTransferWithCommitmentInstruction(
treasuryPool *common.Account,
treasuryPoolVault *common.Account,
destination *common.Account,
commitment *common.Account,
treasuryPoolBump uint8,
kinAmountInQuarks uint64,
transcript []byte,
recentRoot []byte,
) (solana.Instruction, error) {
return splitter_token.NewTransferWithCommitmentInstruction(
&splitter_token.TransferWithCommitmentInstructionAccounts{
Pool: treasuryPool.PublicKey().ToBytes(),
Vault: treasuryPoolVault.PublicKey().ToBytes(),
Destination: destination.PublicKey().ToBytes(),
Commitment: commitment.PublicKey().ToBytes(),
Authority: common.GetSubsidizer().PublicKey().ToBytes(),
Payer: common.GetSubsidizer().PublicKey().ToBytes(),
},
&splitter_token.TransferWithCommitmentInstructionArgs{
PoolBump: treasuryPoolBump,
Amount: kinAmountInQuarks,
Transcript: transcript,
RecentRoot: recentRoot,
},
).ToLegacyInstruction(), nil
}