Skip to content

Commit

Permalink
3.0.0: Type and formatting changes (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpaulos committed Feb 5, 2024
1 parent 1947079 commit 2a25f7a
Show file tree
Hide file tree
Showing 75 changed files with 2,615 additions and 1,715 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
6 changes: 3 additions & 3 deletions examples/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function main() {
});

await client.sendRawTransaction(fundMsigTxn.signTxn(funder.privateKey)).do();
await algosdk.waitForConfirmation(client, fundMsigTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, fundMsigTxn.txID(), 3);

// example: MULTISIG_SIGN
const msigTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
Expand All @@ -74,7 +74,7 @@ async function main() {
).blob;

await client.sendRawTransaction(msigWithSecondSig).do();
await algosdk.waitForConfirmation(client, msigTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, msigTxn.txID(), 3);
// example: MULTISIG_SIGN

// example: ACCOUNT_GENERATE
Expand All @@ -96,7 +96,7 @@ async function main() {
});

await client.sendRawTransaction(rekeyTxn.signTxn(acct1.privateKey)).do();
await algosdk.waitForConfirmation(client, rekeyTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, rekeyTxn.txID(), 3);

const acctInfo = await client.accountInformation(acct1.addr).do();

Expand Down
50 changes: 9 additions & 41 deletions examples/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function main() {
.do();
const result = await algosdk.waitForConfirmation(
algodClient,
appCreateTxn.txID().toString(),
appCreateTxn.txID(),
3
);
// Grab app id from confirmed transaction result
Expand All @@ -86,11 +86,7 @@ async function main() {
await algodClient
.sendRawTransaction(appOptInTxn.signTxn(caller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appOptInTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appOptInTxn.txID(), 3);
// example: APP_OPTIN

// example: APP_NOOP
Expand All @@ -103,11 +99,7 @@ async function main() {
await algodClient
.sendRawTransaction(appNoOpTxn.signTxn(caller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appNoOpTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appNoOpTxn.txID(), 3);
// example: APP_NOOP

const anotherCaller = accounts[2];
Expand All @@ -121,11 +113,7 @@ async function main() {
await algodClient
.sendRawTransaction(anotherAppOptInTxn.signTxn(anotherCaller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
anotherAppOptInTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, anotherAppOptInTxn.txID(), 3);

// example: APP_CALL
const now = new Date().toString();
Expand All @@ -139,11 +127,7 @@ async function main() {
await algodClient
.sendRawTransaction(simpleAddTxn.signTxn(caller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
simpleAddTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, simpleAddTxn.txID(), 3);
// example: APP_CALL

// example: APP_READ_STATE
Expand Down Expand Up @@ -183,11 +167,7 @@ async function main() {
await algodClient
.sendRawTransaction(appCloseOutTxn.signTxn(caller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appCloseOutTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appCloseOutTxn.txID(), 3);
// example: APP_CLOSEOUT

// example: APP_UPDATE
Expand All @@ -209,11 +189,7 @@ async function main() {
await algodClient
.sendRawTransaction(appUpdateTxn.signTxn(creator.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appUpdateTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appUpdateTxn.txID(), 3);
// example: APP_UPDATE

// example: APP_CLEAR
Expand All @@ -226,11 +202,7 @@ async function main() {
await algodClient
.sendRawTransaction(appClearTxn.signTxn(anotherCaller.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appClearTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appClearTxn.txID(), 3);
// example: APP_CLEAR

// example: APP_DELETE
Expand All @@ -243,11 +215,7 @@ async function main() {
await algodClient
.sendRawTransaction(appDeleteTxn.signTxn(creator.privateKey))
.do();
await algosdk.waitForConfirmation(
algodClient,
appDeleteTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, appDeleteTxn.txID(), 3);
// example: APP_DELETE
}

Expand Down
36 changes: 8 additions & 28 deletions examples/asa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ async function main() {

const signedTxn = txn.signTxn(creator.privateKey);
await algodClient.sendRawTransaction(signedTxn).do();
const result = await algosdk.waitForConfirmation(
algodClient,
txn.txID().toString(),
3
);
const result = await algosdk.waitForConfirmation(algodClient, txn.txID(), 3);

const assetIndex = Number(result.assetIndex);
console.log(`Asset ID created: ${assetIndex}`);
Expand Down Expand Up @@ -76,7 +72,7 @@ async function main() {
await algodClient.sendRawTransaction(signedConfigTxn).do();
const configResult = await algosdk.waitForConfirmation(
algodClient,
txn.txID().toString(),
txn.txID(),
3
);
console.log(`Result confirmed in round: ${configResult.confirmedRound}`);
Expand All @@ -96,7 +92,7 @@ async function main() {

const signedOptInTxn = optInTxn.signTxn(receiver.privateKey);
await algodClient.sendRawTransaction(signedOptInTxn).do();
await algosdk.waitForConfirmation(algodClient, optInTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(algodClient, optInTxn.txID(), 3);
// example: ASSET_OPTIN

// example: ASSET_XFER
Expand All @@ -110,7 +106,7 @@ async function main() {

const signedXferTxn = xferTxn.signTxn(creator.privateKey);
await algodClient.sendRawTransaction(signedXferTxn).do();
await algosdk.waitForConfirmation(algodClient, xferTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(algodClient, xferTxn.txID(), 3);
// example: ASSET_XFER

// example: ASSET_FREEZE
Expand All @@ -126,11 +122,7 @@ async function main() {

const signedFreezeTxn = freezeTxn.signTxn(manager.privateKey);
await algodClient.sendRawTransaction(signedFreezeTxn).do();
await algosdk.waitForConfirmation(
algodClient,
freezeTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, freezeTxn.txID(), 3);
// example: ASSET_FREEZE

// example: ASSET_CLAWBACK
Expand All @@ -148,11 +140,7 @@ async function main() {

const signedClawbackTxn = clawbackTxn.signTxn(manager.privateKey);
await algodClient.sendRawTransaction(signedClawbackTxn).do();
await algosdk.waitForConfirmation(
algodClient,
clawbackTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, clawbackTxn.txID(), 3);
// example: ASSET_CLAWBACK

// example: ASSET_OPT_OUT
Expand All @@ -171,11 +159,7 @@ async function main() {

const signedOptOutTxn = optOutTxn.signTxn(receiver.privateKey);
await algodClient.sendRawTransaction(signedOptOutTxn).do();
await algosdk.waitForConfirmation(
algodClient,
optOutTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, optOutTxn.txID(), 3);
// example: ASSET_OPT_OUT

// example: ASSET_DELETE
Expand All @@ -187,11 +171,7 @@ async function main() {

const signedDeleteTxn = deleteTxn.signTxn(manager.privateKey);
await algodClient.sendRawTransaction(signedDeleteTxn).do();
await algosdk.waitForConfirmation(
algodClient,
deleteTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(algodClient, deleteTxn.txID(), 3);
// example: ASSET_DELETE
}

Expand Down
2 changes: 1 addition & 1 deletion examples/atc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
await client.sendRawTransaction(createTxn.signTxn(sender.privateKey)).do();
const response = await algosdk.waitForConfirmation(
client,
createTxn.txID().toString(),
createTxn.txID(),
3
);
const appIndex = Number(response.applicationIndex);
Expand Down
6 changes: 4 additions & 2 deletions examples/atomics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ async function main() {

// example: ATOMIC_GROUP_SEND
await client.sendRawTransaction(signedTxns).do();
await algosdk.waitForConfirmation(client, alicesTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, alicesTxn.txID(), 3);
// example: ATOMIC_GROUP_SEND

// example: CONST_MIN_FEE
const minFee = algosdk.ALGORAND_MIN_TX_FEE;
console.log(minFee);
// example: CONST_MIN_FEE

// example: TRANSACTION_FEE_OVERRIDE
Expand All @@ -61,7 +62,8 @@ async function main() {
// example: TRANSACTION_FEE_OVERRIDE

// example: SP_MIN_FEE
// Not supported because getTransactionParams erases the information
const params = await client.getTransactionParams().do();
console.log(params.minFee);
// example: SP_MIN_FEE
}

Expand Down
2 changes: 1 addition & 1 deletion examples/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function main() {
});

await client.sendRawTransaction(txn.signTxn(sender.privateKey)).do();
await algosdk.waitForConfirmation(client, txn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, txn.txID(), 3);

await new Promise((f) => setTimeout(f, 1000)); // sleep to ensure indexer is caught up

Expand Down
6 changes: 1 addition & 5 deletions examples/lsig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ async function main() {
await client
.sendRawTransaction(fundSmartSigTxn.signTxn(funder.privateKey))
.do();
await algosdk.waitForConfirmation(
client,
fundSmartSigTxn.txID().toString(),
3
);
await algosdk.waitForConfirmation(client, fundSmartSigTxn.txID(), 3);

// example: LSIG_SIGN_FULL
const smartSigTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
Expand Down
14 changes: 6 additions & 8 deletions examples/participation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ async function main() {
const keyDilution = numRounds ** 0.5;

// create transaction
const onlineKeyreg = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject(
{
const onlineKeyreg =
algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
sender: addr,
voteKey,
selectionKey,
Expand All @@ -35,8 +35,7 @@ async function main() {
voteLast: params.firstValid + numRounds,
voteKeyDilution: keyDilution,
suggestedParams: params,
}
);
});

console.log(onlineKeyreg.get_obj_for_encoding());
// example: TRANSACTION_KEYREG_ONLINE_CREATE
Expand All @@ -45,13 +44,12 @@ async function main() {
// get suggested parameters
const suggestedParams = await algodClient.getTransactionParams().do();
// create keyreg transaction to take this account offline
const offlineKeyReg = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject(
{
const offlineKeyReg =
algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
sender: addr,
suggestedParams,
nonParticipation: true,
}
);
});
console.log(offlineKeyReg.get_obj_for_encoding());
// example: TRANSACTION_KEYREG_OFFLINE_CREATE
}
Expand Down
2 changes: 1 addition & 1 deletion examples/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function deployCalculatorApp(

const result = await algosdk.waitForConfirmation(
algodClient,
appCreateTxn.txID().toString(),
appCreateTxn.txID(),
3
);
const appId = Number(result.applicationIndex);
Expand Down
Loading

0 comments on commit 2a25f7a

Please sign in to comment.