-
Notifications
You must be signed in to change notification settings - Fork 8
/
app-client.ts
95 lines (92 loc) · 3.07 KB
/
app-client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import algosdk from 'algosdk'
import { AppSpecAppDetails, AppSpecAppDetailsByCreatorAndName, AppSpecAppDetailsById, ApplicationClient } from './types/app-client'
import Algodv2 = algosdk.Algodv2
/**
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
* `algorand.client.getAppClientByCreatorAndName`.
* If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
* which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
*
* Create a new ApplicationClient instance
* @param appDetails The details of the app
* @param algod An algod instance
*
* @example Resolve by creator and name
* const client = algokit.getAppClient(
* {
* resolveBy: 'creatorAndName',
* app: {appSpec},
* sender: {account},
* creatorAddress: {creator},
* findExistingUsing: indexerClient,
* },
* algodClient,
* )
*
* @example Resolve by id:
* const client = algokit.getAppClient(
* {
* resolveBy: 'id',
* app: {appSpec},
* sender: {account},
* id: {id},
* },
* algodClient,
* )
*
* @returns The application client
*/
export function getAppClient(appDetails: AppSpecAppDetails, algod: Algodv2) {
return new ApplicationClient(appDetails, algod)
}
/**
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById`.
* If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
* which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
*
*
* Create a new ApplicationClient instance by id
* @param appDetails The details of the app
* @param algod An algod instance
*
* @example
* const client = algokit.getAppClientById(
* {
* app: {appSpec},
* sender: {account},
* id: {id},
* },
* algodClient,
* )
*
* @returns The application client
*/
export function getAppClientById(appDetails: AppSpecAppDetailsById, algod: Algodv2) {
return new ApplicationClient({ ...appDetails, resolveBy: 'id' }, algod)
}
/**
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientByCreatorAndName`.
* If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
* which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
*
*
* Create a new ApplicationClient instance by creator and name
* @param appDetails The details of the app by creator and name
* @param algod An algod instance
*
* @example
* const client = algokit.getAppClientByCreatorAndName(
* {
* app: {appSpec},
* sender: {account},
* creatorAddress: {account.addr},
* findExistingUsing: {indexerClient},
* },
* algodClient,
* )
*
* @returns The application client
*/
export function getAppClientByCreatorAndName(appDetails: AppSpecAppDetailsByCreatorAndName, algod: Algodv2) {
return new ApplicationClient({ ...appDetails, resolveBy: 'creatorAndName' }, algod)
}