Skip to content

Commit 6d17cd3

Browse files
3.0.0: Convert algod responses to typed (#776)
1 parent a077ce1 commit 6d17cd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1444
-906
lines changed

examples/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function main() {
7070
3
7171
);
7272
// Grab app id from confirmed transaction result
73-
const appId = result['application-index'];
73+
const appId = result.applicationIndex;
7474
console.log(`Created app with index: ${appId}`);
7575
// example: APP_CREATE
7676

@@ -148,7 +148,7 @@ async function main() {
148148

149149
// example: APP_READ_STATE
150150
const appInfo = await algodClient.getApplicationByID(appId).do();
151-
const globalState = appInfo.params['global-state'][0];
151+
const globalState = appInfo.params.globalState[0];
152152
console.log(`Raw global state - ${JSON.stringify(globalState)}`);
153153

154154
// decode b64 string key with Buffer
@@ -162,7 +162,7 @@ async function main() {
162162
.accountApplicationInformation(caller.addr, appId)
163163
.do();
164164

165-
const localState = accountAppInfo['app-local-state']['key-value'][0];
165+
const localState = accountAppInfo.appLocalState.keyValue[0];
166166
console.log(`Raw local state - ${JSON.stringify(localState)}`);
167167

168168
// decode b64 string key with Buffer

examples/asa.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function main() {
3939
3
4040
);
4141

42-
const assetIndex = result['asset-index'];
42+
const { assetIndex } = result;
4343
console.log(`Asset ID created: ${assetIndex}`);
4444
// example: ASSET_CREATE
4545

@@ -49,7 +49,7 @@ async function main() {
4949
console.log(`Asset Params: ${JSON.stringify(assetInfo.params)}`);
5050
// example: ASSET_INFO
5151

52-
await new Promise((f) => setTimeout(f, 5000)); // sleep to ensure indexer is caught up
52+
await new Promise((f) => setTimeout(f, 45000)); // sleep to ensure indexer is caught up
5353

5454
// example: INDEXER_LOOKUP_ASSET
5555
const indexer = getLocalIndexerClient();
@@ -79,7 +79,7 @@ async function main() {
7979
txn.txID().toString(),
8080
3
8181
);
82-
console.log(`Result confirmed in round: ${configResult['confirmed-round']}`);
82+
console.log(`Result confirmed in round: ${configResult.confirmedRound}`);
8383
// example: ASSET_CONFIG
8484

8585
const receiver = accounts[2];

examples/atc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function main() {
4545
createTxn.txID().toString(),
4646
3
4747
);
48-
const appIndex = response['application-index'];
48+
const appIndex = response.applicationIndex;
4949

5050
// example: ATC_CREATE
5151
const atc = new algosdk.AtomicTransactionComposer();

examples/block_fetcher/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function removeNulls(obj) {
2929

3030
while (true) {
3131
// Get latest round number
32-
let lastRound = status['last-round'];
32+
let { lastRound } = status;
3333
console.log(`Round: ${lastRound}`);
3434

3535
// Fetch block

examples/debug.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ async function main() {
4949
// example: DEBUG_DRYRUN_SUBMIT
5050
const dryrunResponse = await algodClient.dryrun(dryrunRequest).do();
5151
dryrunResponse.txns.forEach((txn) => {
52-
console.log('Txn:', txn.txn);
53-
console.log('Txn Results:', txn.txnresults);
52+
console.log('Txn:', txn);
5453
});
5554
// example: DEBUG_DRYRUN_SUBMIT
5655
}

examples/overview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ async function main() {
3535
// example: TRANSACTION_PAYMENT_SIGN
3636

3737
// example: TRANSACTION_PAYMENT_SUBMIT
38-
const { txId } = await algodClient.sendRawTransaction(signedTxn).do();
39-
const result = await algosdk.waitForConfirmation(algodClient, txId, 4);
38+
const { txid } = await algodClient.sendRawTransaction(signedTxn).do();
39+
const result = await algosdk.waitForConfirmation(algodClient, txid, 4);
4040
console.log(result);
4141
console.log(`Transaction Information: ${JSON.stringify(result.txn)}`);
4242
console.log(

examples/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ export async function deployCalculatorApp(
130130
appCreateTxn.txID().toString(),
131131
3
132132
);
133-
const appId = result['application-index'];
133+
const appId = Number(result.applicationIndex);
134134
return appId;
135135
}

0 commit comments

Comments
 (0)