Skip to content

Commit

Permalink
chore(contracts): Convert account addresses to strings in test assert…
Browse files Browse the repository at this point in the history
…ions for algosdk v3 changes.

Also update to latest algokit-client-generator and commit latest generated clients
  • Loading branch information
pbennett committed Dec 4, 2024
1 parent c020c51 commit 16cd48c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
20 changes: 10 additions & 10 deletions contracts/__test__/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ describe('reti', () => {

// ....and verify data for the 'staker' is correct as well
const stakerInfo = await getStakerInfo(ourPoolClient, stakerAccount)
expect(stakerInfo.account).toEqual(stakerAccount.addr)
expect(stakerInfo.account).toEqual(stakerAccount.addr.toString())
// should be full 2000 algos (we included extra for mbr to begin with)
expect(stakerInfo.balance).toEqual(AlgoAmount.Algos(2000).microAlgos)

Expand Down Expand Up @@ -658,7 +658,7 @@ describe('reti', () => {
})
// The amount 'actually' staked won't include the MBR amount
const stakerInfo = await getStakerInfo(ourPoolClient, stakerAccount)
expect(stakerInfo.account).toEqual(stakerAccount.addr)
expect(stakerInfo.account).toEqual(stakerAccount.addr.toString())
expect(stakerInfo.balance).toEqual(amountStaked - mbrs.addStakerMbr)

// Get Pool info before removing stake..
Expand Down Expand Up @@ -719,7 +719,7 @@ describe('reti', () => {
})
// The amount 'actually' staked won't include the MBR amount
const stakerInfo = await getStakerInfo(ourPoolClient, stakerAccount)
expect(stakerInfo.account).toEqual(stakerAccount.addr)
expect(stakerInfo.account).toEqual(stakerAccount.addr.toString())
expect(stakerInfo.balance).toEqual(amountStaked - mbrs.addStakerMbr)

// Get Pool info before removing stake..
Expand Down Expand Up @@ -3518,9 +3518,9 @@ describe('reti', () => {

// ledger should be staker 0, 2, 1, {empty}
let stakerData = await getStakeInfoFromBoxValue(firstPoolClient)
expect(stakerData[0].account).toEqual(stakers[0].addr)
expect(stakerData[1].account).toEqual(stakers[2].addr)
expect(stakerData[2].account).toEqual(stakers[1].addr)
expect(stakerData[0].account).toEqual(stakers[0].addr.toString())
expect(stakerData[1].account).toEqual(stakers[2].addr.toString())
expect(stakerData[2].account).toEqual(stakers[1].addr.toString())
expect(stakerData[3].account).toEqual(ALGORAND_ZERO_ADDRESS_STRING)
expect(stakerData[0].balance).toEqual(1000n * 1000000n)
expect(stakerData[1].balance).toEqual(1000n * 1000000n)
Expand All @@ -3530,9 +3530,9 @@ describe('reti', () => {
// now remove staker 2's stake - and we should end up with ledger of 0, {empty}, 1, {empty}
await removeStake(firstPoolClient, stakers[2], AlgoAmount.Algos(1000))
stakerData = await getStakeInfoFromBoxValue(firstPoolClient)
expect(stakerData[0].account).toEqual(stakers[0].addr)
expect(stakerData[0].account).toEqual(stakers[0].addr.toString())
expect(stakerData[1].account).toEqual(ALGORAND_ZERO_ADDRESS_STRING)
expect(stakerData[2].account).toEqual(stakers[1].addr)
expect(stakerData[2].account).toEqual(stakers[1].addr.toString())
expect(stakerData[3].account).toEqual(ALGORAND_ZERO_ADDRESS_STRING)
expect(stakerData[0].balance).toEqual(1000n * 1000000n)
expect(stakerData[1].balance).toEqual(0n)
Expand All @@ -3552,9 +3552,9 @@ describe('reti', () => {
expect(poolKey.id).toEqual(firstPoolKey.id)

stakerData = await getStakeInfoFromBoxValue(firstPoolClient)
expect(stakerData[0].account).toEqual(stakers[0].addr)
expect(stakerData[0].account).toEqual(stakers[0].addr.toString())
expect(stakerData[1].account).toEqual(ALGORAND_ZERO_ADDRESS_STRING)
expect(stakerData[2].account).toEqual(stakers[1].addr)
expect(stakerData[2].account).toEqual(stakers[1].addr.toString())
expect(stakerData[3].account).toEqual(ALGORAND_ZERO_ADDRESS_STRING)
expect(stakerData[0].balance).toEqual(1000n * 1000000n)
expect(stakerData[1].balance).toEqual(0n)
Expand Down
24 changes: 12 additions & 12 deletions contracts/contracts/clients/StakingPoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'
import {
AppClient,
AppClient as _AppClient,
AppClientMethodCallParams,
AppClientParams,
AppClientBareCallParams,
Expand All @@ -18,7 +18,7 @@ import {
ResolveAppClientByNetwork,
CloneAppClientParams,
} from '@algorandfoundation/algokit-utils/types/app-client'
import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
Expand Down Expand Up @@ -725,15 +725,15 @@ export class StakingPoolFactory {
/**
* The underlying `AppFactory` for when you want to have more flexibility
*/
public readonly appFactory: AppFactory
public readonly appFactory: _AppFactory

/**
* Creates a new instance of `StakingPoolFactory`
*
* @param params The parameters to initialise the app factory with
*/
constructor(params: Omit<AppFactoryParams, 'appSpec'>) {
this.appFactory = new AppFactory({
this.appFactory = new _AppFactory({
...params,
appSpec: APP_SPEC,
})
Expand Down Expand Up @@ -832,10 +832,10 @@ export class StakingPoolFactory {
* Initialize the staking pool w/ owner and manager, but can only be created by the validator contract.
*
* @param params The params for the smart contract call
* @returns The create params
* @returns The create transaction
*/
createApplication: (params: CallParams<StakingPoolArgs['obj']['createApplication(uint64,uint64,uint64,uint64)void'] | StakingPoolArgs['tuple']['createApplication(uint64,uint64,uint64,uint64)void']> & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}) => {
return this.appFactory.params.create(StakingPoolParamsFactory.create.createApplication(params))
return this.appFactory.createTransaction.create(StakingPoolParamsFactory.create.createApplication(params))
},
},

Expand Down Expand Up @@ -873,22 +873,22 @@ export class StakingPoolClient {
/**
* The underlying `AppClient` for when you want to have more flexibility
*/
public readonly appClient: AppClient
public readonly appClient: _AppClient

/**
* Creates a new instance of `StakingPoolClient`
*
* @param appClient An `AppClient` instance which has been created with the StakingPool app spec
*/
constructor(appClient: AppClient)
constructor(appClient: _AppClient)
/**
* Creates a new instance of `StakingPoolClient`
*
* @param params The parameters to initialise the app client with
*/
constructor(params: Omit<AppClientParams, 'appSpec'>)
constructor(appClientOrParams: AppClient | Omit<AppClientParams, 'appSpec'>) {
this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({
constructor(appClientOrParams: _AppClient | Omit<AppClientParams, 'appSpec'>) {
this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({
...appClientOrParams,
appSpec: APP_SPEC,
})
Expand All @@ -908,7 +908,7 @@ export class StakingPoolClient {
* @param params The parameters to create the app client
*/
public static async fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<StakingPoolClient> {
return new StakingPoolClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
return new StakingPoolClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
}

/**
Expand All @@ -921,7 +921,7 @@ export class StakingPoolClient {
static async fromNetwork(
params: Omit<ResolveAppClientByNetwork, 'appSpec'>
): Promise<StakingPoolClient> {
return new StakingPoolClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
return new StakingPoolClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
}

/** The ID of the app instance this client is linked to. */
Expand Down
24 changes: 12 additions & 12 deletions contracts/contracts/clients/ValidatorRegistryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'
import {
AppClient,
AppClient as _AppClient,
AppClientMethodCallParams,
AppClientParams,
AppClientBareCallParams,
Expand All @@ -18,7 +18,7 @@ import {
ResolveAppClientByNetwork,
CloneAppClientParams,
} from '@algorandfoundation/algokit-utils/types/app-client'
import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
Expand Down Expand Up @@ -1440,15 +1440,15 @@ export class ValidatorRegistryFactory {
/**
* The underlying `AppFactory` for when you want to have more flexibility
*/
public readonly appFactory: AppFactory
public readonly appFactory: _AppFactory

/**
* Creates a new instance of `ValidatorRegistryFactory`
*
* @param params The parameters to initialise the app factory with
*/
constructor(params: Omit<AppFactoryParams, 'appSpec'>) {
this.appFactory = new AppFactory({
this.appFactory = new _AppFactory({
...params,
appSpec: APP_SPEC,
})
Expand Down Expand Up @@ -1543,10 +1543,10 @@ export class ValidatorRegistryFactory {
* Creates a new instance of the ValidatorRegistry smart contract using the createApplication()void ABI method.
*
* @param params The params for the smart contract call
* @returns The create params
* @returns The create transaction
*/
createApplication: (params: CallParams<ValidatorRegistryArgs['obj']['createApplication()void'] | ValidatorRegistryArgs['tuple']['createApplication()void']> & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => {
return this.appFactory.params.create(ValidatorRegistryParamsFactory.create.createApplication(params))
return this.appFactory.createTransaction.create(ValidatorRegistryParamsFactory.create.createApplication(params))
},
},

Expand Down Expand Up @@ -1582,22 +1582,22 @@ export class ValidatorRegistryClient {
/**
* The underlying `AppClient` for when you want to have more flexibility
*/
public readonly appClient: AppClient
public readonly appClient: _AppClient

/**
* Creates a new instance of `ValidatorRegistryClient`
*
* @param appClient An `AppClient` instance which has been created with the ValidatorRegistry app spec
*/
constructor(appClient: AppClient)
constructor(appClient: _AppClient)
/**
* Creates a new instance of `ValidatorRegistryClient`
*
* @param params The parameters to initialise the app client with
*/
constructor(params: Omit<AppClientParams, 'appSpec'>)
constructor(appClientOrParams: AppClient | Omit<AppClientParams, 'appSpec'>) {
this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({
constructor(appClientOrParams: _AppClient | Omit<AppClientParams, 'appSpec'>) {
this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({
...appClientOrParams,
appSpec: APP_SPEC,
})
Expand All @@ -1617,7 +1617,7 @@ export class ValidatorRegistryClient {
* @param params The parameters to create the app client
*/
public static async fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<ValidatorRegistryClient> {
return new ValidatorRegistryClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
return new ValidatorRegistryClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
}

/**
Expand All @@ -1630,7 +1630,7 @@ export class ValidatorRegistryClient {
static async fromNetwork(
params: Omit<ResolveAppClientByNetwork, 'appSpec'>
): Promise<ValidatorRegistryClient> {
return new ValidatorRegistryClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
return new ValidatorRegistryClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
}

/** The ID of the app instance this client is linked to. */
Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"algosdk": "3.0.0"
},
"devDependencies": {
"@algorandfoundation/algokit-client-generator": "4.0.0",
"@algorandfoundation/algokit-client-generator": "4.0.2",
"@algorandfoundation/tealscript": "0.106.0",
"@joe-p/algokit-generate-component": "0.2.1",
"@typescript-eslint/eslint-plugin": "8.8.1",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 16cd48c

Please sign in to comment.