Skip to content

Commit

Permalink
resolveObject remove from project (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefdegroot authored Mar 31, 2023
1 parent 57af6ab commit b4c8a6d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 80 deletions.
38 changes: 0 additions & 38 deletions src/functions/promise.ts

This file was deleted.

13 changes: 6 additions & 7 deletions src/interface/fixedBid/buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { hashAbiMethod } from "../../functions/abi"
import { getGlobalState } from './getGlobalState'
import { addressAssetBalance } from "../../functions/balance"
import { TxnFormatter } from "../../functions/txn"
import { resolveObject } from '../../functions/promise'

export interface BuyFixedBidParams {
appId: number
Expand All @@ -35,12 +34,12 @@ export async function buy(provider: Provider, {

const state = await getGlobalState(provider,{ appId })

const { appNftBalance, buyerNftBalance, params, account } = await resolveObject({
appNftBalance: addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
buyerNftBalance: addressAssetBalance(provider.indexer, buyerAddress, state.nftIndex),
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(buyerAddress).do()
})
const [appNftBalance, buyerNftBalance, params, account] = await Promise.all([
addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
addressAssetBalance(provider.indexer, buyerAddress, state.nftIndex),
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(buyerAddress).do()
])

if (appNftBalance === -1) {
throw new Error('The listing still needs to be set up. It is currently not opted into the NFT.')
Expand Down
9 changes: 4 additions & 5 deletions src/interface/fixedBid/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
encodeUint64,
} from "algosdk"
import { convertProgram } from "../../functions/program"
import { resolveObject } from '../../functions/promise'

import acApprovalProgram from '../../contracts/acFixedBid/approval'
import acClearProgram from '../../contracts/acFixedBid/clearState'
Expand Down Expand Up @@ -72,10 +71,10 @@ export async function deploy(provider: Provider, {

const txnFormater = new TxnFormatter(provider)

const { params, account } = await resolveObject({
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(sellerAddress).do()
})
const [params, account] = await Promise.all([
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(sellerAddress).do()
])

params.fee = ALGORAND_MIN_TX_FEE
params.flatFee = true
Expand Down
13 changes: 6 additions & 7 deletions src/interface/fixedBid/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Provider } from "../../contracts"
import { getGlobalState } from './getGlobalState'
import { addressAssetBalance } from "../../functions/balance"
import { TxnFormatter } from "../../functions/txn"
import { resolveObject } from '../../functions/promise'
import {
ALGORAND_MIN_TX_FEE,
makeAssetTransferTxnWithSuggestedParams
Expand All @@ -24,12 +23,12 @@ export async function deposit(provider: Provider, {

const state = await getGlobalState(provider,{ appId })

const { appNftBalance, creatorNftBalance, params, account } = await resolveObject({
appNftBalance: addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
creatorNftBalance: addressAssetBalance(provider.indexer, state.creatorAddress, state.nftIndex),
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(state.creatorAddress).do()
})
const [appNftBalance, creatorNftBalance, params, account] = await Promise.all([
addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
addressAssetBalance(provider.indexer, state.creatorAddress, state.nftIndex),
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(state.creatorAddress).do()
])

if (appNftBalance === -1) {
throw new Error('The listing still needs to be set up. It is currently not opted into the NFT.')
Expand Down
11 changes: 5 additions & 6 deletions src/interface/fixedBid/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Provider } from "../../contracts"
import { getGlobalState } from './getGlobalState'
import { addressAssetBalance } from "../../functions/balance"
import { TxnFormatter } from "../../functions/txn"
import { resolveObject } from '../../functions/promise'
import {
ALGORAND_MIN_TX_FEE,
makeApplicationDeleteTxn
Expand All @@ -18,11 +17,11 @@ export async function destroy(provider: Provider, {

const state = await getGlobalState(provider,{ appId })

const { appNftBalance, params, account } = await resolveObject({
appNftBalance: addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(state.creatorAddress).do()
})
const [appNftBalance, params, account] = await Promise.all([
addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(state.creatorAddress).do()
])

const txnFormater = new TxnFormatter(provider)

Expand Down
11 changes: 5 additions & 6 deletions src/interface/fixedBid/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getGlobalState } from './getGlobalState'
import { addressAssetBalance } from "../../functions/balance"
import { hashAbiMethod } from "../../functions/abi"
import { TxnFormatter } from "../../functions/txn"
import { resolveObject } from '../../functions/promise'
import {
ALGORAND_MIN_TX_FEE,
makeApplicationNoOpTxn,
Expand All @@ -22,11 +21,11 @@ export async function extract(provider: Provider, {

const state = await getGlobalState(provider,{ appId })

const { appNftBalance, params, account } = await resolveObject({
appNftBalance: addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(state.creatorAddress).do()
})
const [appNftBalance, params, account] = await Promise.all([
addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(state.creatorAddress).do()
])

if (appNftBalance === -1) {
throw new Error('The listing still needs to be set up. It is currently not opted into the NFT.')
Expand Down
11 changes: 5 additions & 6 deletions src/interface/fixedBid/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { TxnFormatter } from "../../functions/txn"
import { getGlobalState } from './getGlobalState'
import { addressAssetBalance } from "../../functions/balance"
import { hashAbiMethod } from "../../functions/abi"
import { resolveObject } from '../../functions/promise'
import {
ALGORAND_MIN_TX_FEE,
makePaymentTxnWithSuggestedParams,
Expand All @@ -30,11 +29,11 @@ export async function setup(provider: Provider, {

const txnFormater = new TxnFormatter(provider)

const { appNftBalance, params, account } = await resolveObject({
appNftBalance: addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(state.creatorAddress).do()
})
const [appNftBalance, params, account] = await Promise.all([
addressAssetBalance(provider.indexer, state.contractAddress, state.nftIndex),
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(state.creatorAddress).do()
])

if (appNftBalance !== -1) {
throw new Error('The listing is already set.')
Expand Down
9 changes: 4 additions & 5 deletions src/interface/fixedBid/updatePrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Provider } from "../../contracts"
import { getGlobalState } from './getGlobalState'
import { TxnFormatter } from "../../functions/txn"
import { hashAbiMethod } from "../../functions/abi"
import { resolveObject } from '../../functions/promise'
import {
ALGORAND_MIN_TX_FEE,
makeApplicationNoOpTxn,
Expand All @@ -21,10 +20,10 @@ export async function updatePrice(provider: Provider, {

const state = await getGlobalState(provider,{ appId })

const { params, account } = await resolveObject({
params: provider.algod.getTransactionParams().do(),
account: provider.algod.accountInformation(state.creatorAddress).do()
})
const [params, account] = await Promise.all([
provider.algod.getTransactionParams().do(),
provider.algod.accountInformation(state.creatorAddress).do()
])

params.fee = ALGORAND_MIN_TX_FEE
params.flatFee = true
Expand Down

0 comments on commit b4c8a6d

Please sign in to comment.