Skip to content

Commit 015fdc0

Browse files
committed
Defensive index checks. Update gradle and deps.
1 parent a1c24db commit 015fdc0

5 files changed

Lines changed: 38 additions & 7 deletions

File tree

gradle/sava.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ developerName="Jim"
55
developerId="jpe7s"
66
developerEmail="james@glam.systems"
77
javaVersion=25
8-
solanaBOMVersion=25.0.1
8+
solanaBOMVersion=25.0.13

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ix-proxy/src/main/java/systems/glam/ix/proxy/IxMapConfig.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ public <A> IxProxy<A> createProxy(final AccountMeta invokedProxyProgram,
6363
throw new IllegalStateException("Invalid configuration: Only one or none dynamic accounts is supported for IxMapConfig without a proxy discriminator.");
6464
}
6565
} else {
66+
final boolean[] checkIndexes = new boolean[dynamicAccounts.size() + staticAccounts.size() + indexMap.length];
67+
for (final var account : dynamicAccounts) {
68+
final int index = account.index();
69+
if (checkIndexes[index]) {
70+
throw new IllegalStateException(String.format(
71+
"Duplicate index %d in dynamic accounts. CPI IX: %s, Proxy IX: %s",
72+
account.index(), cpiIxName, proxyIxName
73+
));
74+
} else {
75+
checkIndexes[index] = true;
76+
}
77+
}
78+
for (final var account : staticAccounts) {
79+
final int index = account.index();
80+
if (checkIndexes[index]) {
81+
throw new IllegalStateException(String.format(
82+
"Duplicate index %d in static accounts. CPI IX: %s, Proxy IX: %s",
83+
account.index(), cpiIxName, proxyIxName
84+
));
85+
} else {
86+
checkIndexes[index] = true;
87+
}
88+
}
89+
for (final var index : indexMap) {
90+
if (index >= 0) {
91+
if (checkIndexes[index]) {
92+
throw new IllegalStateException(String.format(
93+
"Duplicate index %d in index map. CPI IX: %s, Proxy IX: %s",
94+
index, cpiIxName, proxyIxName
95+
));
96+
} else {
97+
checkIndexes[index] = true;
98+
}
99+
}
100+
}
66101
return IxProxy.createProxy(
67102
invokedProxyProgram,
68103
cpiDiscriminator,

0 commit comments

Comments
 (0)