From 0893b42c47a96efb0295d9699bd88f3fd97d1494 Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Fri, 8 Nov 2024 18:31:27 +0100 Subject: [PATCH 1/3] Update ui wrapper idl for making refer optional --- client/idl/ui_wrapper.json | 1 + .../src/ui_wrapper/instructions/SettleFunds.ts | 18 +++++++++++++----- programs/ui-wrapper/src/instruction.rs | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/idl/ui_wrapper.json b/client/idl/ui_wrapper.json index 6be74d855..f8901fbe5 100644 --- a/client/idl/ui_wrapper.json +++ b/client/idl/ui_wrapper.json @@ -649,6 +649,7 @@ "name": "referrerTokenAccount", "isMut": true, "isSigner": false, + "isOptional": true, "docs": [ "Referrer fee token account" ] diff --git a/client/ts/src/ui_wrapper/instructions/SettleFunds.ts b/client/ts/src/ui_wrapper/instructions/SettleFunds.ts index 570b1d07c..3bef7158c 100644 --- a/client/ts/src/ui_wrapper/instructions/SettleFunds.ts +++ b/client/ts/src/ui_wrapper/instructions/SettleFunds.ts @@ -52,7 +52,7 @@ export const SettleFundsStruct = new beet.BeetArgsStruct< * @property [] tokenProgramQuote * @property [] manifestProgram * @property [_writable_] platformTokenAccount - * @property [_writable_] referrerTokenAccount + * @property [_writable_] referrerTokenAccount (optional) * @category Instructions * @category SettleFunds * @category generated @@ -71,7 +71,7 @@ export type SettleFundsInstructionAccounts = { tokenProgramQuote: web3.PublicKey; manifestProgram: web3.PublicKey; platformTokenAccount: web3.PublicKey; - referrerTokenAccount: web3.PublicKey; + referrerTokenAccount?: web3.PublicKey; }; export const settleFundsInstructionDiscriminator = 5; @@ -79,6 +79,11 @@ export const settleFundsInstructionDiscriminator = 5; /** * Creates a _SettleFunds_ instruction. * + * Optional accounts that are not provided will be omitted from the accounts + * array passed with the instruction. + * An optional account that is set cannot follow an optional account that is unset. + * Otherwise an Error is raised. + * * @param accounts that will be accessed while the instruction is processed * @param args to provide as instruction data to the program * @@ -161,12 +166,15 @@ export function createSettleFundsInstruction( isWritable: true, isSigner: false, }, - { + ]; + + if (accounts.referrerTokenAccount != null) { + keys.push({ pubkey: accounts.referrerTokenAccount, isWritable: true, isSigner: false, - }, - ]; + }); + } const ix = new web3.TransactionInstruction({ programId, diff --git a/programs/ui-wrapper/src/instruction.rs b/programs/ui-wrapper/src/instruction.rs index 830103d61..bd5df041b 100644 --- a/programs/ui-wrapper/src/instruction.rs +++ b/programs/ui-wrapper/src/instruction.rs @@ -111,8 +111,7 @@ pub enum ManifestWrapperInstruction { #[account(10, name = "token_program_quote", desc = "Token program for quote token")] #[account(11, name = "manifest_program", desc = "Manifest program")] #[account(12, writable, name = "platform_token_account", desc = "Platform fee token account")] - // optional - #[account(13, writable, name = "referrer_token_account", desc = "Referrer fee token account")] + #[account(13, writable, name = "referrer_token_account", desc = "Referrer fee token account", optional)] SettleFunds = 5, } From 239a43c2c80980f58157ac2625779ce82bb59e1c Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Fri, 8 Nov 2024 18:44:10 +0100 Subject: [PATCH 2/3] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b4e4f042..69a1fc4eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cks-systems/manifest-sdk", - "version": "0.1.64", + "version": "0.1.65", "files": [ "dist/", "README.md", From e2c7b6ecfeec629c82879e1480e4e141ef9a91ea Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Fri, 8 Nov 2024 20:35:49 +0100 Subject: [PATCH 3/3] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69a1fc4eb..26aeb150c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cks-systems/manifest-sdk", - "version": "0.1.65", + "version": "0.1.67", "files": [ "dist/", "README.md",