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

src/main/java/com/algorand/algosdk/transaction/AssetParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public AssetParams(
9999
}
100100

101101
if(url != null) {
102-
if (url.length() > 32) throw new RuntimeException("asset url cannot be greater than 32 characters");
102+
if (url.length() > 96) throw new RuntimeException("url length must be between 0 and 96 characters (inclusive).");
103103
this.url = url;
104104
}
105105

src/main/java/com/algorand/algosdk/transaction/Transaction.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class Transaction implements Serializable {
3232
@JsonProperty("snd")
3333
public Address sender = new Address();
3434
@JsonProperty("fee")
35-
public BigInteger fee = Account.MIN_TX_FEE_UALGOS;
35+
public BigInteger fee = BigInteger.ZERO;
3636
@JsonProperty("fv")
3737
public BigInteger firstValid = BigInteger.valueOf(0);
3838
@JsonProperty("lv")
@@ -150,6 +150,9 @@ public class Transaction implements Serializable {
150150
@JsonProperty("apsu")
151151
public TEALProgram clearStateProgram = null;
152152

153+
@JsonProperty("apep")
154+
public Long extraPages = 0L;
155+
153156
/**
154157
* Create a payment transaction
155158
* @param fromAddr source address
@@ -272,6 +275,7 @@ public static Transaction createPaymentTransaction(Address sender, BigInteger fe
272275
null,
273276
null,
274277
null,
278+
null,
275279
null);
276280
}
277281

@@ -374,6 +378,7 @@ public static Transaction createKeyRegistrationTransaction(Address sender, BigIn
374378
null,
375379
null,
376380
null,
381+
null,
377382
null);
378383
}
379384

@@ -496,6 +501,7 @@ public static Transaction createAssetCreateTransaction(Address sender, BigIntege
496501
null,
497502
null,
498503
null,
504+
null,
499505
null);
500506
}
501507

@@ -645,7 +651,8 @@ private Transaction(@JsonProperty("type") Type type,
645651
@JsonProperty("apgs") StateSchema globalStateSchema,
646652
@JsonProperty("apid") Long applicationId,
647653
@JsonProperty("apls") StateSchema localStateSchema,
648-
@JsonProperty("apsu") byte[] clearStateProgram
654+
@JsonProperty("apsu") byte[] clearStateProgram,
655+
@JsonProperty("apep") Long extraPages
649656
) throws IOException {
650657
this(
651658
type,
@@ -692,7 +699,8 @@ private Transaction(@JsonProperty("type") Type type,
692699
globalStateSchema,
693700
applicationId,
694701
localStateSchema,
695-
clearStateProgram == null ? null : new TEALProgram(clearStateProgram)
702+
clearStateProgram == null ? null : new TEALProgram(clearStateProgram),
703+
extraPages
696704
);
697705
}
698706

@@ -747,7 +755,8 @@ public Transaction(
747755
StateSchema globalStateSchema,
748756
Long applicationId,
749757
StateSchema localStateSchema,
750-
TEALProgram clearStateProgram
758+
TEALProgram clearStateProgram,
759+
Long extraPages
751760
) {
752761
if (type != null) this.type = type;
753762
if (sender != null) this.sender = sender;
@@ -788,13 +797,11 @@ public Transaction(
788797
if (applicationId != null) this.applicationId = applicationId;
789798
if (localStateSchema != null) this.localStateSchema = globalStateSchema;
790799
if (clearStateProgram != null) this.clearStateProgram = clearStateProgram;
800+
if (extraPages != null) this.extraPages = extraPages;
791801
}
792802

793803
// Used by Jackson to determine "default" values.
794-
public Transaction() {
795-
// Override the default to 0 so that it will be serialized
796-
this.fee = BigInteger.valueOf(0);
797-
}
804+
public Transaction() {}
798805

799806
/**
800807
* Base constructor with flat fee for asset xfer/freeze/destroy transactions.
@@ -1280,7 +1287,8 @@ public boolean equals(Object o) {
12801287
assetFreezeID.equals(that.assetFreezeID) &&
12811288
freezeState == that.freezeState &&
12821289
rekeyTo.equals(that.rekeyTo) &&
1283-
Arrays.equals(lease, ((Transaction) o).lease);
1290+
Arrays.equals(lease, ((Transaction) o).lease) &&
1291+
extraPages.equals(that.extraPages);
12841292
}
12851293

12861294
/**

src/main/resources/langspec.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)