Skip to content

Commit 8c2d679

Browse files
authored
* fix: add *FromTuple functions back
1 parent 7c9da43 commit 8c2d679

Some content is hidden

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

44 files changed

+806
-89
lines changed

examples/smart_contracts/artifacts/arc56_test/client.minimal.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,12 +61,28 @@ export type FooUint16BarUint16 = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a { foo: uint16; bar: uint16 } to the struct representation
66+
*/
67+
export function FooUint16BarUint16FromTuple(abiTuple: [number, number]) {
68+
const abiStructType = ABIStructType.fromStruct('FooUint16BarUint16', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as FooUint16BarUint16
70+
}
71+
6472
export type Outputs = {
6573
sum: bigint,
6674
difference: bigint
6775
}
6876

6977

78+
/**
79+
* Converts the ABI tuple representation of a Outputs to the struct representation
80+
*/
81+
export function OutputsFromTuple(abiTuple: [bigint, bigint]) {
82+
const abiStructType = ABIStructType.fromStruct('Outputs', APP_SPEC.structs)
83+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Outputs
84+
}
85+
7086
export type Inputs = {
7187
add: {
7288
a: bigint,
@@ -79,6 +95,14 @@ export type Inputs = {
7995
}
8096

8197

98+
/**
99+
* Converts the ABI tuple representation of a Inputs to the struct representation
100+
*/
101+
export function InputsFromTuple(abiTuple: [[bigint, bigint], [bigint, bigint]]) {
102+
const abiStructType = ABIStructType.fromStruct('Inputs', APP_SPEC.structs)
103+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Inputs
104+
}
105+
82106
/**
83107
* The argument types for the Arc56Test contract
84108
*/

examples/smart_contracts/artifacts/arc56_test/client.pn.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,12 +61,28 @@ export type _foo_uint16_bar_uint16_ = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a { foo: uint16; bar: uint16 } to the struct representation
66+
*/
67+
export function _foo_uint16_bar_uint16_FromTuple(abiTuple: [number, number]) {
68+
const abiStructType = ABIStructType.fromStruct('_foo_uint16_bar_uint16_', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as _foo_uint16_bar_uint16_
70+
}
71+
6472
export type Outputs = {
6573
sum: bigint,
6674
difference: bigint
6775
}
6876

6977

78+
/**
79+
* Converts the ABI tuple representation of a Outputs to the struct representation
80+
*/
81+
export function OutputsFromTuple(abiTuple: [bigint, bigint]) {
82+
const abiStructType = ABIStructType.fromStruct('Outputs', APP_SPEC.structs)
83+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Outputs
84+
}
85+
7086
export type Inputs = {
7187
add: {
7288
a: bigint,
@@ -79,6 +95,14 @@ export type Inputs = {
7995
}
8096

8197

98+
/**
99+
* Converts the ABI tuple representation of a Inputs to the struct representation
100+
*/
101+
export function InputsFromTuple(abiTuple: [[bigint, bigint], [bigint, bigint]]) {
102+
const abiStructType = ABIStructType.fromStruct('Inputs', APP_SPEC.structs)
103+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Inputs
104+
}
105+
82106
/**
83107
* Deploy-time template variables
84108
*/

examples/smart_contracts/artifacts/arc56_test/client.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,12 +61,28 @@ export type FooUint16BarUint16 = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a { foo: uint16; bar: uint16 } to the struct representation
66+
*/
67+
export function FooUint16BarUint16FromTuple(abiTuple: [number, number]) {
68+
const abiStructType = ABIStructType.fromStruct('FooUint16BarUint16', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as FooUint16BarUint16
70+
}
71+
6472
export type Outputs = {
6573
sum: bigint,
6674
difference: bigint
6775
}
6876

6977

78+
/**
79+
* Converts the ABI tuple representation of a Outputs to the struct representation
80+
*/
81+
export function OutputsFromTuple(abiTuple: [bigint, bigint]) {
82+
const abiStructType = ABIStructType.fromStruct('Outputs', APP_SPEC.structs)
83+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Outputs
84+
}
85+
7086
export type Inputs = {
7187
add: {
7288
a: bigint,
@@ -79,6 +95,14 @@ export type Inputs = {
7995
}
8096

8197

98+
/**
99+
* Converts the ABI tuple representation of a Inputs to the struct representation
100+
*/
101+
export function InputsFromTuple(abiTuple: [[bigint, bigint], [bigint, bigint]]) {
102+
const abiStructType = ABIStructType.fromStruct('Inputs', APP_SPEC.structs)
103+
return getStructValueFromTupleValue(abiStructType, abiTuple) as Inputs
104+
}
105+
82106
/**
83107
* Deploy-time template variables
84108
*/

examples/smart_contracts/artifacts/duplicate_structs/client.minimal.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,6 +61,14 @@ export type SomeStruct = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a SomeStruct to the struct representation
66+
*/
67+
export function SomeStructFromTuple(abiTuple: [bigint, bigint]) {
68+
const abiStructType = ABIStructType.fromStruct('SomeStruct', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as SomeStruct
70+
}
71+
6472
/**
6573
* The argument types for the DuplicateStructs contract
6674
*/

examples/smart_contracts/artifacts/duplicate_structs/client.pn.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,6 +61,14 @@ export type SomeStruct = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a SomeStruct to the struct representation
66+
*/
67+
export function SomeStructFromTuple(abiTuple: [bigint, bigint]) {
68+
const abiStructType = ABIStructType.fromStruct('SomeStruct', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as SomeStruct
70+
}
71+
6472
/**
6573
* The argument types for the DuplicateStructs contract
6674
*/

examples/smart_contracts/artifacts/duplicate_structs/client.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
@@ -61,6 +61,14 @@ export type SomeStruct = {
6161
}
6262

6363

64+
/**
65+
* Converts the ABI tuple representation of a SomeStruct to the struct representation
66+
*/
67+
export function SomeStructFromTuple(abiTuple: [bigint, bigint]) {
68+
const abiStructType = ABIStructType.fromStruct('SomeStruct', APP_SPEC.structs)
69+
return getStructValueFromTupleValue(abiStructType, abiTuple) as SomeStruct
70+
}
71+
6472
/**
6573
* The argument types for the DuplicateStructs contract
6674
*/

examples/smart_contracts/artifacts/hello_world/client.minimal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'

examples/smart_contracts/artifacts/hello_world/client.pn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'

examples/smart_contracts/artifacts/hello_world/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'

examples/smart_contracts/artifacts/life_cycle/client.minimal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* requires: @algorandfoundation/algokit-utils: ^10
66
*/
77
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
8-
import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
9-
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8+
import { ABIReturn, ABIStructType, Arc56Contract, getStructValueFromTupleValue } from '@algorandfoundation/algokit-utils/abi'
9+
import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
1010
import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
1111
import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
1212
import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'

0 commit comments

Comments
 (0)