Skip to content

Commit 0b67f4c

Browse files
committed
IDCOM-2129 Fixing the extend_transaction realloc issue. This was the problem: rust-lang/rust#39232
1 parent efbf73b commit 0b67f4c

File tree

2 files changed

+158
-3
lines changed

2 files changed

+158
-3
lines changed

packages/client/idl/src/cryptid.ts

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,84 @@ export type Cryptid = {
218218
}
219219
]
220220
},
221+
{
222+
"name": "extendTransaction",
223+
"accounts": [
224+
{
225+
"name": "cryptidAccount",
226+
"isMut": false,
227+
"isSigner": false,
228+
"docs": [
229+
"The Cryptid instance that can execute the transaction."
230+
]
231+
},
232+
{
233+
"name": "did",
234+
"isMut": false,
235+
"isSigner": false,
236+
"docs": [
237+
"The did account owner of the Cryptid instance"
238+
]
239+
},
240+
{
241+
"name": "didProgram",
242+
"isMut": false,
243+
"isSigner": false,
244+
"docs": [
245+
"The program for the DID"
246+
]
247+
},
248+
{
249+
"name": "authority",
250+
"isMut": true,
251+
"isSigner": true
252+
},
253+
{
254+
"name": "transactionAccount",
255+
"isMut": true,
256+
"isSigner": false
257+
},
258+
{
259+
"name": "systemProgram",
260+
"isMut": false,
261+
"isSigner": false
262+
}
263+
],
264+
"args": [
265+
{
266+
"name": "controllerChain",
267+
"type": {
268+
"vec": {
269+
"defined": "DIDReference"
270+
}
271+
}
272+
},
273+
{
274+
"name": "cryptidAccountBump",
275+
"type": "u8"
276+
},
277+
{
278+
"name": "cryptidAccountIndex",
279+
"type": "u32"
280+
},
281+
{
282+
"name": "didAccountBump",
283+
"type": "u8"
284+
},
285+
{
286+
"name": "instructions",
287+
"type": {
288+
"vec": {
289+
"defined": "AbbreviatedInstructionData"
290+
}
291+
}
292+
},
293+
{
294+
"name": "numAccounts",
295+
"type": "u8"
296+
}
297+
]
298+
},
221299
{
222300
"name": "sealTransaction",
223301
"accounts": [
@@ -911,6 +989,84 @@ export const IDL: Cryptid = {
911989
}
912990
]
913991
},
992+
{
993+
"name": "extendTransaction",
994+
"accounts": [
995+
{
996+
"name": "cryptidAccount",
997+
"isMut": false,
998+
"isSigner": false,
999+
"docs": [
1000+
"The Cryptid instance that can execute the transaction."
1001+
]
1002+
},
1003+
{
1004+
"name": "did",
1005+
"isMut": false,
1006+
"isSigner": false,
1007+
"docs": [
1008+
"The did account owner of the Cryptid instance"
1009+
]
1010+
},
1011+
{
1012+
"name": "didProgram",
1013+
"isMut": false,
1014+
"isSigner": false,
1015+
"docs": [
1016+
"The program for the DID"
1017+
]
1018+
},
1019+
{
1020+
"name": "authority",
1021+
"isMut": true,
1022+
"isSigner": true
1023+
},
1024+
{
1025+
"name": "transactionAccount",
1026+
"isMut": true,
1027+
"isSigner": false
1028+
},
1029+
{
1030+
"name": "systemProgram",
1031+
"isMut": false,
1032+
"isSigner": false
1033+
}
1034+
],
1035+
"args": [
1036+
{
1037+
"name": "controllerChain",
1038+
"type": {
1039+
"vec": {
1040+
"defined": "DIDReference"
1041+
}
1042+
}
1043+
},
1044+
{
1045+
"name": "cryptidAccountBump",
1046+
"type": "u8"
1047+
},
1048+
{
1049+
"name": "cryptidAccountIndex",
1050+
"type": "u32"
1051+
},
1052+
{
1053+
"name": "didAccountBump",
1054+
"type": "u8"
1055+
},
1056+
{
1057+
"name": "instructions",
1058+
"type": {
1059+
"vec": {
1060+
"defined": "AbbreviatedInstructionData"
1061+
}
1062+
}
1063+
},
1064+
{
1065+
"name": "numAccounts",
1066+
"type": "u8"
1067+
}
1068+
]
1069+
},
9141070
{
9151071
"name": "sealTransaction",
9161072
"accounts": [

programs/cryptid/src/instructions/extend_transaction.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::state::transaction_state::TransactionState;
99
use crate::util::SolDID;
1010
use anchor_lang::prelude::*;
1111
use itertools::Itertools;
12-
use std::borrow::BorrowMut;
1312

1413
#[derive(Accounts)]
1514
#[instruction(
@@ -97,11 +96,11 @@ impl ExtendTransaction<'_> {
9796
// if the account is not in all_accounts, add it to the transaction_accounts and update the index in the instruction
9897
new_instructions.iter_mut().for_each(
9998
|new_instruction: &mut &mut AbbreviatedInstructionData| {
100-
new_instruction.accounts.iter_mut().map(
99+
new_instruction.accounts.iter_mut().for_each(
101100
|mut new_instruction_account_meta: &mut AbbreviatedAccountMeta| {
102101
let account =
103102
new_instruction_accounts[new_instruction_account_meta.key as usize];
104-
if let Some((index, key)) = transaction_account
103+
if let Some((index, _key)) = transaction_account
105104
.accounts
106105
.iter()
107106
.find_position(|existing_account| *existing_account == account.key)

0 commit comments

Comments
 (0)