Skip to content

Commit afb8dda

Browse files
authored
feat: shank tuples support (#381)
1 parent 4c2204f commit afb8dda

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@subsquid/solana-typegen",
5+
"comment": "add support for Shank tuple types",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@subsquid/solana-typegen"
10+
}

solana/solana-typegen/src/program/anchor/old.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export type IdlType =
149149
| IdlTypeCOption
150150
| IdlTypeVec
151151
| IdlTypeArray
152+
| IdlTypeTuple
152153
| IdlTypeHashMap
153154
| IdlTypeHashSet
154155

@@ -173,6 +174,10 @@ export type IdlTypeArray = {
173174
array: [idlType: IdlType, size: number]
174175
}
175176

177+
export type IdlTypeTuple = {
178+
tuple: IdlType[]
179+
}
180+
176181
export type IdlTypeHashMap = {
177182
hashMap: [idlType: IdlType, idlType: IdlType]
178183
}
@@ -365,6 +370,11 @@ function fromType(type: IdlType): Type {
365370
kind: TypeKind.Array,
366371
type: fromType(type.vec),
367372
}
373+
} else if ('tuple' in type) {
374+
return {
375+
kind: TypeKind.Tuple,
376+
tuple: type.tuple.map(t => fromType(t as IdlType)),
377+
}
368378
} else if ('hashMap' in type) {
369379
return {
370380
kind: TypeKind.HashMap,

solana/solana-typegen/src/program/anchor/v0.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export type IdlType =
238238
| IdlTypeCOption
239239
| IdlTypeVec
240240
| IdlTypeArray
241+
| IdlTypeTuple
241242
| IdlTypeHashMap
242243
| IdlTypeHashSet
243244
| IdlTypeDefined
@@ -260,6 +261,10 @@ export type IdlTypeArray = {
260261
array: [idlType: IdlType, size: IdlArrayLen]
261262
}
262263

264+
export type IdlTypeTuple = {
265+
tuple: IdlType[]
266+
}
267+
263268
export type IdlTypeHashMap = {
264269
hashMap: [idlType: IdlType, idlType: IdlType]
265270
}
@@ -405,6 +410,11 @@ function fromType(type: IdlType): Type {
405410
kind: TypeKind.Array,
406411
type: fromType(type.vec),
407412
}
413+
} else if ('tuple' in type) {
414+
return {
415+
kind: TypeKind.Tuple,
416+
tuple: type.tuple.map(t => fromType(t as IdlType))
417+
}
408418
} else if ('hashMap' in type) {
409419
return {
410420
kind: TypeKind.HashMap,

0 commit comments

Comments
 (0)