Skip to content

Commit f16ced1

Browse files
committed
wip - pr feedback
1 parent 163815f commit f16ced1

File tree

4 files changed

+94
-95
lines changed

4 files changed

+94
-95
lines changed

src/transactions/asset.ts renamed to src/transactions/asset-config.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -185,45 +185,6 @@ export type AssetDestroyParams = CommonTransactionParams & {
185185
assetId: bigint
186186
}
187187

188-
/** Parameters to define an asset transfer transaction. */
189-
export type AssetTransferParams = CommonTransactionParams & {
190-
/** ID of the asset to transfer. */
191-
assetId: bigint
192-
/** Amount of the asset to transfer (in smallest divisible (decimal) units). */
193-
amount: bigint
194-
/** The address of the account that will receive the asset unit(s). */
195-
receiver: string | Address
196-
/** Optional address of an account to clawback the asset from.
197-
*
198-
* Requires the sender to be the clawback account.
199-
*
200-
* **Warning:** Be careful with this parameter as it can lead to unexpected loss of funds if not used correctly.
201-
*/
202-
clawbackTarget?: string | Address
203-
/** Optional address of an account to close the asset position to.
204-
*
205-
* **Warning:** Be careful with this parameter as it can lead to loss of funds if not used correctly.
206-
*/
207-
closeAssetTo?: string | Address
208-
}
209-
210-
/** Parameters to define an asset opt-in transaction. */
211-
export type AssetOptInParams = CommonTransactionParams & {
212-
/** ID of the asset that will be opted-in to. */
213-
assetId: bigint
214-
}
215-
216-
/** Parameters to define an asset opt-out transaction. */
217-
export type AssetOptOutParams = CommonTransactionParams & {
218-
/** ID of the asset that will be opted-out of. */
219-
assetId: bigint
220-
/**
221-
* The address of the asset creator account to close the asset
222-
* position to (any remaining asset units will be sent to this account).
223-
*/
224-
creator: string | Address
225-
}
226-
227188
export const buildAssetCreate = (params: AssetCreateParams, header: TransactionHeader): Transaction => {
228189
return {
229190
...header,
@@ -280,42 +241,3 @@ export const buildAssetDestroy = (params: AssetDestroyParams, header: Transactio
280241
},
281242
}
282243
}
283-
284-
export const buildAssetTransfer = (params: AssetTransferParams, header: TransactionHeader): Transaction => {
285-
return {
286-
...header,
287-
type: TransactionType.AssetTransfer,
288-
assetTransfer: {
289-
assetId: params.assetId,
290-
amount: params.amount,
291-
receiver: params.receiver.toString(),
292-
assetSender: params.clawbackTarget?.toString(),
293-
closeRemainderTo: params.closeAssetTo?.toString(),
294-
},
295-
}
296-
}
297-
298-
export const buildAssetOptIn = (params: AssetOptInParams, header: TransactionHeader): Transaction => {
299-
return {
300-
...header,
301-
type: TransactionType.AssetTransfer,
302-
assetTransfer: {
303-
assetId: params.assetId,
304-
amount: 0n,
305-
receiver: header.sender,
306-
},
307-
}
308-
}
309-
310-
export const buildAssetOptOut = (params: AssetOptOutParams, header: TransactionHeader): Transaction => {
311-
return {
312-
...header,
313-
type: TransactionType.AssetTransfer,
314-
assetTransfer: {
315-
assetId: params.assetId,
316-
amount: 0n,
317-
receiver: header.sender,
318-
closeRemainderTo: params.creator?.toString(),
319-
},
320-
}
321-
}

src/transactions/asset-transfer.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'
2+
import { Address } from '@algorandfoundation/sdk'
3+
import { CommonTransactionParams, TransactionHeader } from './common'
4+
5+
/** Parameters to define an asset transfer transaction. */
6+
export type AssetTransferParams = CommonTransactionParams & {
7+
/** ID of the asset to transfer. */
8+
assetId: bigint
9+
/** Amount of the asset to transfer (in smallest divisible (decimal) units). */
10+
amount: bigint
11+
/** The address of the account that will receive the asset unit(s). */
12+
receiver: string | Address
13+
/** Optional address of an account to clawback the asset from.
14+
*
15+
* Requires the sender to be the clawback account.
16+
*
17+
* **Warning:** Be careful with this parameter as it can lead to unexpected loss of funds if not used correctly.
18+
*/
19+
clawbackTarget?: string | Address
20+
/** Optional address of an account to close the asset position to.
21+
*
22+
* **Warning:** Be careful with this parameter as it can lead to loss of funds if not used correctly.
23+
*/
24+
closeAssetTo?: string | Address
25+
}
26+
27+
/** Parameters to define an asset opt-in transaction. */
28+
export type AssetOptInParams = CommonTransactionParams & {
29+
/** ID of the asset that will be opted-in to. */
30+
assetId: bigint
31+
}
32+
33+
/** Parameters to define an asset opt-out transaction. */
34+
export type AssetOptOutParams = CommonTransactionParams & {
35+
/** ID of the asset that will be opted-out of. */
36+
assetId: bigint
37+
/**
38+
* The address of the asset creator account to close the asset
39+
* position to (any remaining asset units will be sent to this account).
40+
*/
41+
creator: string | Address
42+
}
43+
44+
export const buildAssetTransfer = (params: AssetTransferParams, header: TransactionHeader): Transaction => {
45+
return {
46+
...header,
47+
type: TransactionType.AssetTransfer,
48+
assetTransfer: {
49+
assetId: params.assetId,
50+
amount: params.amount,
51+
receiver: params.receiver.toString(),
52+
assetSender: params.clawbackTarget?.toString(),
53+
closeRemainderTo: params.closeAssetTo?.toString(),
54+
},
55+
}
56+
}
57+
58+
export const buildAssetOptIn = (params: AssetOptInParams, header: TransactionHeader): Transaction => {
59+
return {
60+
...header,
61+
type: TransactionType.AssetTransfer,
62+
assetTransfer: {
63+
assetId: params.assetId,
64+
amount: 0n,
65+
receiver: header.sender,
66+
},
67+
}
68+
}
69+
70+
export const buildAssetOptOut = (params: AssetOptOutParams, header: TransactionHeader): Transaction => {
71+
return {
72+
...header,
73+
type: TransactionType.AssetTransfer,
74+
assetTransfer: {
75+
assetId: params.assetId,
76+
amount: 0n,
77+
receiver: header.sender,
78+
closeRemainderTo: params.creator?.toString(),
79+
},
80+
}
81+
}

src/types/app-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ export class ApplicationClient {
21602160
call?.method &&
21612161
// We aren't skipping the send
21622162
!call.sendParams?.skipSending &&
2163-
// There isn't an composer passed in
2163+
// There isn't a composer passed in
21642164
!call.sendParams?.transactionComposer &&
21652165
// The method is readonly
21662166
this.appSpec.hints?.[this.getABIMethodSignature(this.getABIMethod(call.method)!)]?.read_only

src/types/composer.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,25 @@ import {
3939
type AppDeleteParams,
4040
type AppUpdateParams,
4141
} from '../transactions/app-call'
42+
import {
43+
buildAssetOptIn,
44+
buildAssetOptOut,
45+
buildAssetTransfer,
46+
type AssetOptInParams,
47+
type AssetOptOutParams,
48+
type AssetTransferParams,
49+
} from '../transactions/asset-transfer'
50+
4251
import {
4352
buildAssetConfig,
4453
buildAssetCreate,
4554
buildAssetDestroy,
4655
buildAssetFreeze,
47-
buildAssetOptIn,
48-
buildAssetOptOut,
49-
buildAssetTransfer,
5056
type AssetConfigParams,
5157
type AssetCreateParams,
5258
type AssetDestroyParams,
5359
type AssetFreezeParams,
54-
type AssetOptInParams,
55-
type AssetOptOutParams,
56-
type AssetTransferParams,
57-
} from '../transactions/asset'
60+
} from '../transactions/asset-config'
5861
import { deepCloneTransactionParams } from '../transactions/clone'
5962
import { buildTransactionHeader, calculateInnerFeeDelta, getDefaultValidityWindow } from '../transactions/common'
6063
import { buildKeyReg, type OfflineKeyRegistrationParams, type OnlineKeyRegistrationParams } from '../transactions/key-registration'
@@ -101,15 +104,8 @@ export type {
101104
AppUpdateParams,
102105
CommonAppCallParams,
103106
} from '../transactions/app-call'
104-
export type {
105-
AssetConfigParams,
106-
AssetCreateParams,
107-
AssetDestroyParams,
108-
AssetFreezeParams,
109-
AssetOptInParams,
110-
AssetOptOutParams,
111-
AssetTransferParams,
112-
} from '../transactions/asset'
107+
export type { AssetConfigParams, AssetCreateParams, AssetDestroyParams, AssetFreezeParams } from '../transactions/asset-config'
108+
export type { AssetOptInParams, AssetOptOutParams, AssetTransferParams } from '../transactions/asset-transfer'
113109
export type { CommonTransactionParams } from '../transactions/common'
114110
export type { OfflineKeyRegistrationParams, OnlineKeyRegistrationParams } from '../transactions/key-registration'
115111
export type {

0 commit comments

Comments
 (0)