Skip to content

Commit fa70f8e

Browse files
committed
Merge branch 'release/1.7.0'
2 parents 26f0553 + d9085ed commit fa70f8e

File tree

18 files changed

+431
-56
lines changed

18 files changed

+431
-56
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
# 1.7.0
2+
- Implement dynamic opcode accounting, backward jumps, loops, callsub, retsub
3+
- Implement ability to pool fees
4+
- Update asset URL length to 96 bytes
5+
- Implement ability to pay for extra pages
6+
- Don't override values with lookupParams/suggestedParams
7+
18
# 1.6.0
2-
- Add static qualifiers to json creators for onCompletion enum serialization.
9+
- Add static qualifiers to json creators for onCompletion enum serialization.
310
- Bump guava from 28.2-android to 29.0-android in /generator.
411
- Bump guava from 28.2-android to 29.0-android.
512
- Corrected Exception message for Keccak-256 hash function.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
unit:
2-
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231"
2+
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest"
33

44
integration:
55
mvn test -Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @template or @indexer or @rekey or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @applications.evaldelta or @indexer.231"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Maven:
2323
<dependency>
2424
<groupId>com.algorand</groupId>
2525
<artifactId>algosdk</artifactId>
26-
<version>1.6.0</version>
26+
<version>1.7.0</version>
2727
</dependency>
2828
```
2929

generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
<dependency>
169169
<groupId>com.algorand</groupId>
170170
<artifactId>algosdk</artifactId>
171-
<version>1.6.0</version>
171+
<version>1.7.0</version>
172172
</dependency>
173173

174174
<!-- testing -->

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.algorand</groupId>
66
<artifactId>algosdk</artifactId>
7-
<version>1.6.0</version>
7+
<version>1.7.0</version>
88
<packaging>jar</packaging>
99

1010
<name>${project.groupId}:${project.artifactId}</name>

src/main/java/com/algorand/algosdk/builder/transaction/ApplicationCreateTransactionBuilder.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
public class ApplicationCreateTransactionBuilder<T extends ApplicationCreateTransactionBuilder<T>> extends ApplicationUpdateTransactionBuilder<T> {
88
private StateSchema localStateSchema;
99
private StateSchema globalStateSchema;
10+
private Long extraPages = 0L;
1011

1112
/**
1213
* Initialize a {@link ApplicationCreateTransactionBuilder}.
@@ -24,6 +25,7 @@ public ApplicationCreateTransactionBuilder() {
2425
protected void applyTo(Transaction txn) {
2526
txn.localStateSchema = localStateSchema;
2627
txn.globalStateSchema = globalStateSchema;
28+
txn.extraPages = extraPages;
2729

2830
super.applyTo(txn);
2931
}
@@ -71,4 +73,16 @@ public T globalStateSchema(StateSchema globalStateSchema) {
7173
this.globalStateSchema = globalStateSchema;
7274
return (T) this;
7375
}
76+
77+
/**
78+
* extraPages allows you to rent extra pages of memory for the application. Each page is 2048 bytes of shared
79+
* memory between approval and clear state programs. extraPages parameter must be an integer between 0 and 3 inclusive.
80+
*/
81+
public T extraPages(Long extraPages) {
82+
if (extraPages == null || extraPages < 0 || extraPages > 3) {
83+
throw new IllegalArgumentException("extraPages must be an integer between 0 and 3 inclusive");
84+
}
85+
this.extraPages = extraPages;
86+
return (T) this;
87+
}
7488
}

src/main/java/com/algorand/algosdk/builder/transaction/AssetCreateTransactionBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,14 @@ public T assetName(String assetName) {
169169
}
170170

171171
/**
172-
* Set url. This value must be between 0 and 32 characters (inclusive).
172+
* Set url. This value must be between 0 and 96 characters (inclusive).
173173
* @param url The asset url.
174174
* @return this builder.
175175
*/
176176
public T url(String url) {
177+
if (url != null && url.length() > 96) {
178+
throw new IllegalArgumentException("url length must be between 0 and 96 characters (inclusive).");
179+
}
177180
this.url = url;
178181
return (T) this;
179182
}

src/main/java/com/algorand/algosdk/builder/transaction/TransactionBuilder.java

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,31 @@ final public Transaction build() {
7171
if(fee != null && flatFee != null) {
7272
throw new IllegalArgumentException("Cannot set both fee and flatFee.");
7373
}
74+
if(fee == null && flatFee == null){
75+
txn.fee = Account.MIN_TX_FEE_UALGOS;
76+
return txn;
77+
}
7478
if(fee != null) {
7579
try {
7680
Account.setFeeByFeePerByte(txn, fee);
7781
} catch (NoSuchAlgorithmException e) {
7882
throw new UnsupportedOperationException(e);
7983
}
84+
if (txn.fee == null || txn.fee.equals(BigInteger.valueOf(0))) {
85+
txn.fee = Account.MIN_TX_FEE_UALGOS;
86+
}
8087
}
8188
if (flatFee != null) {
8289
txn.fee = flatFee;
8390
}
84-
if (txn.fee == null || txn.fee == BigInteger.valueOf(0)) {
85-
txn.fee = Account.MIN_TX_FEE_UALGOS;
86-
}
91+
8792

8893
return txn;
8994
}
9095

9196
/**
9297
* Query the V1 REST API with {@link AlgodApi} for Transaction Parameters:
93-
* Initialize fee, genesisID, genesisHash, firstValid, lastValid using {@link TransactionParams}.
98+
* Initialize fee, genesisID, genesisHash, firstValid, lastValid by querying algod if not already set.
9499
* @param client The backend client connection.
95100
* @return This builder.
96101
* @throws ApiException When the client fails to retrieve {@link TransactionParams} from the backend.
@@ -101,22 +106,32 @@ public T lookupParams(AlgodApi client) throws ApiException {
101106
}
102107

103108
/**
104-
* Initialize fee, genesisID, genesisHash, firstValid and lastValid using {@link TransactionParams}.
109+
* Initialize fee, genesisID, genesisHash, firstValid, lastValid using {@link TransactionParams} if not already set.
105110
* @param params The suggested transaction parameters.
106111
* @return This builder.
107112
*/
108113
public T suggestedParams(TransactionParams params) {
109-
fee(params.getFee());
110-
genesisID(params.getGenesisID());
111-
genesisHash(params.getGenesishashb64());
112-
firstValid(params.getLastRound());
113-
lastValid(params.getLastRound().add(BigInteger.valueOf(1000L)));
114+
if (this.fee == null) {
115+
fee(params.getFee());
116+
}
117+
if (this.genesisID == null) {
118+
genesisID(params.getGenesisID());
119+
}
120+
if (this.genesisHash == null) {
121+
genesisHash(params.getGenesishashb64());
122+
}
123+
if (this.firstValid == null) {
124+
firstValid(params.getLastRound());
125+
}
126+
if (this.lastValid == null) {
127+
lastValid(params.getLastRound().add(BigInteger.valueOf(1000L)));
128+
}
114129
return (T) this;
115130
}
116131

117132
/**
118133
* Query the V2 REST API with {@link com.algorand.algosdk.v2.client.common.AlgodClient} for Transaction Parameters:
119-
* Initialize fee, genesisID, genesisHash, firstValid, lastValid using {@link TransactionParametersResponse}.
134+
* Initialize fee, genesisID, genesisHash, firstValid, lastValid using {@link TransactionParametersResponse} if not already set.
120135
* @param client The backend client connection.
121136
* @return This builder.
122137
* @throws ApiException When the client fails to retrieve {@link TransactionParametersResponse} from the backend.
@@ -210,7 +225,9 @@ public T fee(Long fee) {
210225
}
211226

212227
/**
213-
* Set the flatFee. This value will be used for the transaction fee, or 1000, whichever is higher.
228+
* Set the flatFee. This value will be used for the transaction fee.
229+
* This fee may fall to zero but a group of N atomic transactions must
230+
* still have a fee of at least N*MinTxnFee.
214231
* This field cannot be combined with fee.
215232
* @param flatFee The flatFee to use for the transaction.
216233
* @return This builder.
@@ -221,7 +238,9 @@ public T flatFee(BigInteger flatFee) {
221238
}
222239

223240
/**
224-
* Set the flatFee. This value will be used for the transaction fee, or 1000, whichever is higher.
241+
* Set the flatFee. This value will be used for the transaction fee.
242+
* This fee may fall to zero but a group of N atomic transactions must
243+
* still have a fee of at least N*MinTxnFee.
225244
* This field cannot be combined with fee.
226245
* @param flatFee The flatFee to use for the transaction.
227246
* @return This builder.
@@ -233,7 +252,9 @@ public T flatFee(Integer flatFee) {
233252
}
234253

235254
/**
236-
* Set the flatFee. This value will be used for the transaction fee, or 1000, whichever is higher.
255+
* Set the flatFee. This value will be used for the transaction fee.
256+
* This fee may fall to zero but a group of N atomic transactions must
257+
* still have a fee of at least N*MinTxnFee.
237258
* This field cannot be combined with fee.
238259
* @param flatFee The flatFee to use for the transaction.
239260
* @return This builder.
@@ -516,4 +537,3 @@ public T groupB64(String group) {
516537
return (T) this;
517538
}
518539
}
519-

src/main/java/com/algorand/algosdk/crypto/TEALProgram.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public TEALProgram() {
2929
@JsonCreator
3030
public TEALProgram(byte[] program) {
3131
if (program == null) return;
32-
try {
33-
Logic.readProgram(program, null);
34-
} catch (Exception e) {
35-
throw new RuntimeException(e);
36-
}
32+
// try {
33+
// Logic.readProgram(program, null);
34+
// } catch (Exception e) {
35+
// throw new RuntimeException(e);
36+
// }
3737
this.program = Arrays.copyOf(program, program.length);
3838
}
3939

src/main/java/com/algorand/algosdk/logic/Logic.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ public static ProgramData readProgram(byte[] program, List<byte[]> args) throws
248248
}
249249
pc += size;
250250
}
251-
252-
if (cost > MAX_COST) {
253-
throw new IllegalArgumentException("program too costly to run");
251+
// costs calculated dynamically starting in v4
252+
if (version < 4 && cost > MAX_COST) {
253+
throw new IllegalArgumentException("program too costly for Teal version < 4. consider using v4.");
254254
}
255-
255+
256256
return new ProgramData(true, ints, bytes);
257257
}
258258

0 commit comments

Comments
 (0)