Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit 26809ab

Browse files
author
Richard Patel
authored
support upd_price_no_fail_on_error (#12)
1 parent 4402697 commit 26809ab

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

builder.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ func (i *InstructionBuilder) UpdPrice(
163163
}
164164
}
165165

166+
// UpdPriceNoFailOnError publishes a new component price to a price account, ignoring errors.
167+
func (i *InstructionBuilder) UpdPriceNoFailOnError(
168+
fundingKey solana.PublicKey,
169+
priceKey solana.PublicKey,
170+
payload CommandUpdPrice,
171+
) *Instruction {
172+
return &Instruction{
173+
programKey: i.programKey,
174+
Header: makeCommandHeader(Instruction_UpdPriceNoFailOnError),
175+
accounts: []*solana.AccountMeta{
176+
solana.Meta(fundingKey).SIGNER().WRITE(),
177+
solana.Meta(priceKey).WRITE(),
178+
solana.Meta(solana.SysVarClockPubkey),
179+
},
180+
Payload: &payload,
181+
}
182+
}
183+
166184
// AggPrice computes the aggregate price for a product account.
167185
func (i *InstructionBuilder) AggPrice(
168186
fundingKey solana.PublicKey,

instructions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
Instruction_InitTest
4545
Instruction_UpdTest
4646
Instruction_SetMinPub
47+
Instruction_UpdPriceNoFailOnError
4748
instruction_count // number of different instruction types
4849
)
4950

@@ -76,6 +77,8 @@ func InstructionIDToName(id int32) string {
7677
return "upd_test"
7778
case Instruction_SetMinPub:
7879
return "set_min_pub"
80+
case Instruction_UpdPriceNoFailOnError:
81+
return "upd_price_no_fail_on_error"
7982
default:
8083
return fmt.Sprintf("unsupported (%d)", id)
8184
}
@@ -241,7 +244,7 @@ func DecodeInstruction(
241244
case Instruction_DelPublisher:
242245
impl = new(CommandDelPublisher)
243246
numAccounts = 2
244-
case Instruction_UpdPrice:
247+
case Instruction_UpdPrice, Instruction_UpdPriceNoFailOnError:
245248
impl = new(CommandUpdPrice)
246249
numAccounts = 3
247250
case Instruction_AggPrice:

0 commit comments

Comments
 (0)