algosdk 1.13.0-beta.1 → 1.13.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/src/abi/abi_type.js +75 -47
- package/dist/cjs/src/abi/abi_type.js.map +1 -1
- package/dist/cjs/src/abi/contract.js +6 -4
- package/dist/cjs/src/abi/contract.js.map +1 -1
- package/dist/cjs/src/abi/index.js +2 -0
- package/dist/cjs/src/abi/index.js.map +1 -1
- package/dist/cjs/src/abi/interface.js +2 -0
- package/dist/cjs/src/abi/interface.js.map +1 -1
- package/dist/cjs/src/abi/method.js +5 -8
- package/dist/cjs/src/abi/method.js.map +1 -1
- package/dist/cjs/src/abi/reference.js +25 -0
- package/dist/cjs/src/abi/reference.js.map +1 -0
- package/dist/cjs/src/abi/transaction.js +52 -0
- package/dist/cjs/src/abi/transaction.js.map +1 -0
- package/dist/cjs/src/client/baseHTTPClient.js +3 -0
- package/dist/cjs/src/client/baseHTTPClient.js.map +1 -0
- package/dist/cjs/src/client/client.js +165 -104
- package/dist/cjs/src/client/client.js.map +1 -1
- package/dist/cjs/src/client/urlTokenBaseHTTPClient.js +138 -0
- package/dist/cjs/src/client/urlTokenBaseHTTPClient.js.map +1 -0
- package/dist/cjs/src/client/v2/algod/algod.js +7 -2
- package/dist/cjs/src/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/src/client/v2/indexer/indexer.js +7 -2
- package/dist/cjs/src/client/v2/indexer/indexer.js.map +1 -1
- package/dist/cjs/src/client/v2/serviceClient.js +17 -8
- package/dist/cjs/src/client/v2/serviceClient.js.map +1 -1
- package/dist/cjs/src/composer.js +154 -34
- package/dist/cjs/src/composer.js.map +1 -1
- package/dist/cjs/src/main.js.map +1 -1
- package/dist/cjs/src/transaction.js +4 -2
- package/dist/cjs/src/transaction.js.map +1 -1
- package/dist/cjs/src/wait.js +21 -8
- package/dist/cjs/src/wait.js.map +1 -1
- package/dist/esm/src/abi/abi_type.js +75 -47
- package/dist/esm/src/abi/abi_type.js.map +1 -1
- package/dist/esm/src/abi/contract.js +6 -4
- package/dist/esm/src/abi/contract.js.map +1 -1
- package/dist/esm/src/abi/index.js +2 -0
- package/dist/esm/src/abi/index.js.map +1 -1
- package/dist/esm/src/abi/interface.js +2 -0
- package/dist/esm/src/abi/interface.js.map +1 -1
- package/dist/esm/src/abi/method.js +3 -5
- package/dist/esm/src/abi/method.js.map +1 -1
- package/dist/esm/src/abi/reference.js +21 -0
- package/dist/esm/src/abi/reference.js.map +1 -0
- package/dist/esm/src/abi/transaction.js +47 -0
- package/dist/esm/src/abi/transaction.js.map +1 -0
- package/dist/esm/src/client/baseHTTPClient.js +2 -0
- package/dist/esm/src/client/baseHTTPClient.js.map +1 -0
- package/dist/esm/src/client/client.js +165 -101
- package/dist/esm/src/client/client.js.map +1 -1
- package/dist/esm/src/client/urlTokenBaseHTTPClient.js +112 -0
- package/dist/esm/src/client/urlTokenBaseHTTPClient.js.map +1 -0
- package/dist/esm/src/client/v2/algod/algod.js +7 -2
- package/dist/esm/src/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/src/client/v2/indexer/indexer.js +7 -2
- package/dist/esm/src/client/v2/indexer/indexer.js.map +1 -1
- package/dist/esm/src/client/v2/serviceClient.js +17 -8
- package/dist/esm/src/client/v2/serviceClient.js.map +1 -1
- package/dist/esm/src/composer.js +155 -35
- package/dist/esm/src/composer.js.map +1 -1
- package/dist/esm/src/main.js.map +1 -1
- package/dist/esm/src/transaction.js +4 -2
- package/dist/esm/src/transaction.js.map +1 -1
- package/dist/esm/src/wait.js +21 -8
- package/dist/esm/src/wait.js.map +1 -1
- package/dist/types/src/abi/abi_type.d.ts +19 -19
- package/dist/types/src/abi/contract.d.ts +10 -2
- package/dist/types/src/abi/index.d.ts +2 -0
- package/dist/types/src/abi/interface.d.ts +2 -0
- package/dist/types/src/abi/method.d.ts +14 -12
- package/dist/types/src/abi/reference.d.ts +15 -0
- package/dist/types/src/abi/transaction.d.ts +33 -0
- package/dist/types/src/client/baseHTTPClient.d.ts +41 -0
- package/dist/types/src/client/client.d.ts +67 -31
- package/dist/types/src/client/kmd.d.ts +1 -1
- package/dist/types/src/client/urlTokenBaseHTTPClient.d.ts +44 -0
- package/dist/types/src/client/v2/algod/algod.d.ts +8 -2
- package/dist/types/src/client/v2/indexer/indexer.d.ts +8 -2
- package/dist/types/src/client/v2/serviceClient.d.ts +4 -2
- package/dist/types/src/composer.d.ts +17 -3
- package/dist/types/src/main.d.ts +1 -0
- package/package.json +5 -3
|
@@ -6,7 +6,7 @@ export declare const LENGTH_ENCODE_BYTE_SIZE = 2;
|
|
|
6
6
|
export declare type ABIValue = boolean | number | bigint | string | Uint8Array | ABIValue[];
|
|
7
7
|
export declare abstract class ABIType {
|
|
8
8
|
abstract toString(): string;
|
|
9
|
-
abstract
|
|
9
|
+
abstract equals(other: ABIType): boolean;
|
|
10
10
|
abstract isDynamic(): boolean;
|
|
11
11
|
abstract byteLen(): number;
|
|
12
12
|
abstract encode(value: ABIValue): Uint8Array;
|
|
@@ -17,10 +17,10 @@ export declare class ABIUintType extends ABIType {
|
|
|
17
17
|
bitSize: number;
|
|
18
18
|
constructor(size: number);
|
|
19
19
|
toString(): string;
|
|
20
|
-
|
|
20
|
+
equals(other: ABIType): boolean;
|
|
21
21
|
isDynamic(): boolean;
|
|
22
22
|
byteLen(): number;
|
|
23
|
-
encode(value:
|
|
23
|
+
encode(value: ABIValue): Uint8Array;
|
|
24
24
|
decode(byteString: Uint8Array): bigint;
|
|
25
25
|
}
|
|
26
26
|
export declare class ABIUfixedType extends ABIType {
|
|
@@ -28,42 +28,42 @@ export declare class ABIUfixedType extends ABIType {
|
|
|
28
28
|
precision: number;
|
|
29
29
|
constructor(size: number, denominator: number);
|
|
30
30
|
toString(): string;
|
|
31
|
-
|
|
31
|
+
equals(other: ABIType): boolean;
|
|
32
32
|
isDynamic(): boolean;
|
|
33
33
|
byteLen(): number;
|
|
34
|
-
encode(value:
|
|
34
|
+
encode(value: ABIValue): Uint8Array;
|
|
35
35
|
decode(byteString: Uint8Array): bigint;
|
|
36
36
|
}
|
|
37
37
|
export declare class ABIAddressType extends ABIType {
|
|
38
38
|
toString(): string;
|
|
39
|
-
|
|
39
|
+
equals(other: ABIType): boolean;
|
|
40
40
|
isDynamic(): boolean;
|
|
41
41
|
byteLen(): number;
|
|
42
|
-
encode(value:
|
|
42
|
+
encode(value: ABIValue): Uint8Array;
|
|
43
43
|
decode(byteString: Uint8Array): string;
|
|
44
44
|
}
|
|
45
45
|
export declare class ABIBoolType extends ABIType {
|
|
46
46
|
toString(): string;
|
|
47
|
-
|
|
47
|
+
equals(other: ABIType): boolean;
|
|
48
48
|
isDynamic(): boolean;
|
|
49
49
|
byteLen(): number;
|
|
50
|
-
encode(value:
|
|
50
|
+
encode(value: ABIValue): Uint8Array;
|
|
51
51
|
decode(byteString: Uint8Array): boolean;
|
|
52
52
|
}
|
|
53
53
|
export declare class ABIByteType extends ABIType {
|
|
54
54
|
toString(): string;
|
|
55
|
-
|
|
55
|
+
equals(other: ABIType): boolean;
|
|
56
56
|
isDynamic(): boolean;
|
|
57
57
|
byteLen(): number;
|
|
58
|
-
encode(value:
|
|
58
|
+
encode(value: ABIValue): Uint8Array;
|
|
59
59
|
decode(byteString: Uint8Array): number;
|
|
60
60
|
}
|
|
61
61
|
export declare class ABIStringType extends ABIType {
|
|
62
62
|
toString(): string;
|
|
63
|
-
|
|
63
|
+
equals(other: ABIType): boolean;
|
|
64
64
|
isDynamic(): boolean;
|
|
65
65
|
byteLen(): never;
|
|
66
|
-
encode(value:
|
|
66
|
+
encode(value: ABIValue): Uint8Array;
|
|
67
67
|
decode(byteString: Uint8Array): string;
|
|
68
68
|
}
|
|
69
69
|
export declare class ABIArrayStaticType extends ABIType {
|
|
@@ -71,10 +71,10 @@ export declare class ABIArrayStaticType extends ABIType {
|
|
|
71
71
|
staticLength: number;
|
|
72
72
|
constructor(argType: ABIType, arrayLength: number);
|
|
73
73
|
toString(): string;
|
|
74
|
-
|
|
74
|
+
equals(other: ABIType): boolean;
|
|
75
75
|
isDynamic(): boolean;
|
|
76
76
|
byteLen(): number;
|
|
77
|
-
encode(
|
|
77
|
+
encode(value: ABIValue): Uint8Array;
|
|
78
78
|
decode(byteString: Uint8Array): ABIValue[];
|
|
79
79
|
toABITupleType(): ABITupleType;
|
|
80
80
|
}
|
|
@@ -82,10 +82,10 @@ export declare class ABIArrayDynamicType extends ABIType {
|
|
|
82
82
|
childType: ABIType;
|
|
83
83
|
constructor(argType: ABIType);
|
|
84
84
|
toString(): string;
|
|
85
|
-
|
|
85
|
+
equals(other: ABIType): boolean;
|
|
86
86
|
isDynamic(): boolean;
|
|
87
87
|
byteLen(): never;
|
|
88
|
-
encode(
|
|
88
|
+
encode(value: ABIValue): Uint8Array;
|
|
89
89
|
decode(byteString: Uint8Array): ABIValue[];
|
|
90
90
|
toABITupleType(length: number): ABITupleType;
|
|
91
91
|
}
|
|
@@ -93,10 +93,10 @@ export declare class ABITupleType extends ABIType {
|
|
|
93
93
|
childTypes: ABIType[];
|
|
94
94
|
constructor(argTypes: ABIType[]);
|
|
95
95
|
toString(): string;
|
|
96
|
-
|
|
96
|
+
equals(other: ABIType): boolean;
|
|
97
97
|
isDynamic(): boolean;
|
|
98
98
|
byteLen(): number;
|
|
99
|
-
encode(
|
|
99
|
+
encode(value: ABIValue): Uint8Array;
|
|
100
100
|
decode(byteString: Uint8Array): ABIValue[];
|
|
101
101
|
static parseTupleContent(str: string): string[];
|
|
102
102
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { ABIMethod, ABIMethodParams } from './method';
|
|
2
|
+
export interface ABIContractNetworkInfo {
|
|
3
|
+
appID: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ABIContractNetworks {
|
|
6
|
+
[network: string]: ABIContractNetworkInfo;
|
|
7
|
+
}
|
|
2
8
|
export interface ABIContractParams {
|
|
3
9
|
name: string;
|
|
4
|
-
|
|
10
|
+
desc?: string;
|
|
11
|
+
networks?: ABIContractNetworks;
|
|
5
12
|
methods: ABIMethodParams[];
|
|
6
13
|
}
|
|
7
14
|
export declare class ABIContract {
|
|
8
15
|
readonly name: string;
|
|
9
|
-
readonly
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
readonly networks: ABIContractNetworks;
|
|
10
18
|
readonly methods: ABIMethod[];
|
|
11
19
|
constructor(params: ABIContractParams);
|
|
12
20
|
toJSON(): ABIContractParams;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ABIMethod, ABIMethodParams } from './method';
|
|
2
2
|
export interface ABIInterfaceParams {
|
|
3
3
|
name: string;
|
|
4
|
+
desc?: string;
|
|
4
5
|
methods: ABIMethodParams[];
|
|
5
6
|
}
|
|
6
7
|
export declare class ABIInterface {
|
|
7
8
|
readonly name: string;
|
|
9
|
+
readonly description?: string;
|
|
8
10
|
readonly methods: ABIMethod[];
|
|
9
11
|
constructor(params: ABIInterfaceParams);
|
|
10
12
|
toJSON(): ABIInterfaceParams;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { TransactionType } from '../types/transactions/base';
|
|
2
1
|
import { ABIType } from './abi_type';
|
|
3
|
-
|
|
2
|
+
import { ABITransactionType } from './transaction';
|
|
3
|
+
import { ABIReferenceType } from './reference';
|
|
4
|
+
export interface ABIMethodArgParams {
|
|
5
|
+
type: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
desc?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ABIMethodReturnParams {
|
|
10
|
+
type: string;
|
|
11
|
+
desc?: string;
|
|
12
|
+
}
|
|
4
13
|
export interface ABIMethodParams {
|
|
5
14
|
name: string;
|
|
6
15
|
desc?: string;
|
|
7
|
-
args:
|
|
8
|
-
|
|
9
|
-
name?: string;
|
|
10
|
-
desc?: string;
|
|
11
|
-
}>;
|
|
12
|
-
returns: {
|
|
13
|
-
type: string;
|
|
14
|
-
desc?: string;
|
|
15
|
-
};
|
|
16
|
+
args: ABIMethodArgParams[];
|
|
17
|
+
returns: ABIMethodReturnParams;
|
|
16
18
|
}
|
|
17
|
-
export declare type ABIArgumentType = ABIType |
|
|
19
|
+
export declare type ABIArgumentType = ABIType | ABITransactionType | ABIReferenceType;
|
|
18
20
|
export declare type ABIReturnType = ABIType | 'void';
|
|
19
21
|
export declare class ABIMethod {
|
|
20
22
|
readonly name: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum ABIReferenceType {
|
|
2
|
+
/**
|
|
3
|
+
* Account reference type
|
|
4
|
+
*/
|
|
5
|
+
account = "account",
|
|
6
|
+
/**
|
|
7
|
+
* Application reference type
|
|
8
|
+
*/
|
|
9
|
+
application = "application",
|
|
10
|
+
/**
|
|
11
|
+
* Asset reference type
|
|
12
|
+
*/
|
|
13
|
+
asset = "asset"
|
|
14
|
+
}
|
|
15
|
+
export declare function abiTypeIsReference(type: any): type is ABIReferenceType;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Transaction } from '../transaction';
|
|
2
|
+
export declare enum ABITransactionType {
|
|
3
|
+
/**
|
|
4
|
+
* Any transaction type
|
|
5
|
+
*/
|
|
6
|
+
any = "txn",
|
|
7
|
+
/**
|
|
8
|
+
* Payment transaction type
|
|
9
|
+
*/
|
|
10
|
+
pay = "pay",
|
|
11
|
+
/**
|
|
12
|
+
* Key registration transaction type
|
|
13
|
+
*/
|
|
14
|
+
keyreg = "keyreg",
|
|
15
|
+
/**
|
|
16
|
+
* Asset configuration transaction type
|
|
17
|
+
*/
|
|
18
|
+
acfg = "acfg",
|
|
19
|
+
/**
|
|
20
|
+
* Asset transfer transaction type
|
|
21
|
+
*/
|
|
22
|
+
axfer = "axfer",
|
|
23
|
+
/**
|
|
24
|
+
* Asset freeze transaction type
|
|
25
|
+
*/
|
|
26
|
+
afrz = "afrz",
|
|
27
|
+
/**
|
|
28
|
+
* Application transaction type
|
|
29
|
+
*/
|
|
30
|
+
appl = "appl"
|
|
31
|
+
}
|
|
32
|
+
export declare function abiTypeIsTransaction(type: any): type is ABITransactionType;
|
|
33
|
+
export declare function abiCheckTransactionType(type: ABITransactionType, txn: Transaction): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare type Query<F> = {
|
|
2
|
+
format?: F;
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
5
|
+
export interface BaseHTTPClientResponse {
|
|
6
|
+
body: Uint8Array;
|
|
7
|
+
status: number;
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* BaseHTTPClientError is the interface that errors thrown
|
|
12
|
+
* by methods of BaseHTTPClient should be using
|
|
13
|
+
*/
|
|
14
|
+
export interface BaseHTTPClientError {
|
|
15
|
+
response: BaseHTTPClientResponse;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* BaseHTTPClient is an interface abstracting the queries that can be
|
|
19
|
+
* made to an algod/indexer endpoint.
|
|
20
|
+
* The SDK normally uses the URLTokenBaseHTTPClient implementation.
|
|
21
|
+
* But when used via wallets, the wallet may provide a different object
|
|
22
|
+
* satisfying the HTTPClient interface. This is useful to allow
|
|
23
|
+
* wallets to provide access to paid API services without leaking
|
|
24
|
+
* the secret tokens/URLs.
|
|
25
|
+
*
|
|
26
|
+
* Note that post and delete also have an optional query parameter
|
|
27
|
+
* This is to allow future extension where post and delete may have queries
|
|
28
|
+
* Currently however HTTPClient does not make use of it
|
|
29
|
+
*
|
|
30
|
+
* Compared to HTTPClient, BaseHTTPClient does not deal with serialization/deserialization
|
|
31
|
+
* Everything is already string/Uint8Array
|
|
32
|
+
* and all the headers (including Accept/Content-Type) are assumed to be provided
|
|
33
|
+
*
|
|
34
|
+
* In case of non-200 status, all methods must throw an error of type
|
|
35
|
+
* BaseHTTPClientError
|
|
36
|
+
*/
|
|
37
|
+
export interface BaseHTTPClient {
|
|
38
|
+
get(relativePath: string, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
39
|
+
post(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
40
|
+
delete(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
41
|
+
}
|
|
@@ -1,35 +1,62 @@
|
|
|
1
|
-
import * as request from 'superagent';
|
|
2
1
|
import * as utils from '../utils/utils';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { BaseHTTPClient, Query } from './baseHTTPClient';
|
|
3
|
+
import { TokenHeader } from './urlTokenBaseHTTPClient';
|
|
4
|
+
export interface HTTPClientResponse {
|
|
5
|
+
body: Uint8Array | any;
|
|
6
|
+
text?: string;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
status: number;
|
|
9
|
+
ok: boolean;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export interface CustomTokenHeader {
|
|
18
|
-
[headerName: string]: string;
|
|
19
|
-
}
|
|
20
|
-
export declare type TokenHeader = AlgodTokenHeader | IndexerTokenHeader | KMDTokenHeader | CustomTokenHeader;
|
|
11
|
+
/**
|
|
12
|
+
* HTTPClient is a wrapper around a BaseHTTPClient
|
|
13
|
+
* It takes care of setting the proper "Accept" header and of
|
|
14
|
+
* decoding the JSON outputs.
|
|
15
|
+
*/
|
|
21
16
|
export default class HTTPClient {
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
private bc;
|
|
18
|
+
/**
|
|
19
|
+
* Construct an HTTPClient from a BaseHTTPClient
|
|
20
|
+
* @param bc - the BaseHTTPClient used
|
|
21
|
+
*/
|
|
22
|
+
constructor(bc: BaseHTTPClient);
|
|
23
|
+
/**
|
|
24
|
+
* Construct an HTTPClient from a URL (baseServer+port) and a token
|
|
25
|
+
*/
|
|
26
|
+
constructor(tokenHeader: TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record<string, string>);
|
|
27
|
+
/**
|
|
28
|
+
* Parse JSON using either the built-in JSON.parse or utils.parseJSON
|
|
29
|
+
* depending on whether jsonOptions are provided or not
|
|
30
|
+
*
|
|
31
|
+
* @param text JSON data
|
|
32
|
+
* @param status Status of the response (used in case parseJSON fails)
|
|
33
|
+
* @param jsonOptions Options object to use to decode JSON responses. See
|
|
34
|
+
* utils.parseJSON for the options available.
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
private static parseJSON;
|
|
38
|
+
/**
|
|
39
|
+
* Serialize the data according to the requestHeaders
|
|
40
|
+
* Assumes that requestHeaders contain a key "content-type"
|
|
41
|
+
* If the content-type is "application/json", data is JSON serialized
|
|
42
|
+
* Otherwise, data needs to be either an UTF-8 string that is converted to an Uint8Array
|
|
43
|
+
* or an Uint8Array
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
private static serializeData;
|
|
47
|
+
/**
|
|
48
|
+
* Convert a BaseHTTPClientResponse into a full HTTPClientResponse
|
|
49
|
+
* Parse the body in
|
|
50
|
+
* Modifies in place res and return the result
|
|
51
|
+
*/
|
|
52
|
+
private static prepareResponse;
|
|
27
53
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
54
|
+
* Prepare an error with a response
|
|
55
|
+
* (the type of errors BaseHTTPClient are supposed to throw)
|
|
56
|
+
* by adding the status and preparing the internal response
|
|
57
|
+
* @private
|
|
31
58
|
*/
|
|
32
|
-
private
|
|
59
|
+
private static prepareResponseError;
|
|
33
60
|
/**
|
|
34
61
|
* Send a GET request.
|
|
35
62
|
* @param {string} relativePath The path of the request.
|
|
@@ -39,8 +66,17 @@ export default class HTTPClient {
|
|
|
39
66
|
* utils.parseJSON for the options available.
|
|
40
67
|
* @returns Response object.
|
|
41
68
|
*/
|
|
42
|
-
get(relativePath: string, query?: Query<any>, requestHeaders?: Record<string,
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
get(relativePath: string, query?: Query<any>, requestHeaders?: Record<string, string>, jsonOptions?: utils.JSONOptions): Promise<HTTPClientResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Send a POST request.
|
|
72
|
+
* If no content-type present, adds the header "content-type: application/json"
|
|
73
|
+
* and data is serialized in JSON (if not empty)
|
|
74
|
+
*/
|
|
75
|
+
post(relativePath: string, data: any, requestHeaders?: Record<string, string>): Promise<HTTPClientResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Send a DELETE request.
|
|
78
|
+
* If no content-type present, adds the header "content-type: application/json"
|
|
79
|
+
* and data is serialized in JSON (if not empty)
|
|
80
|
+
*/
|
|
81
|
+
delete(relativePath: string, data: any, requestHeaders?: Record<string, string>): Promise<HTTPClientResponse>;
|
|
45
82
|
}
|
|
46
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import ServiceClient from './v2/serviceClient';
|
|
3
3
|
import * as txn from '../transaction';
|
|
4
|
-
import { CustomTokenHeader, KMDTokenHeader } from './
|
|
4
|
+
import { CustomTokenHeader, KMDTokenHeader } from './urlTokenBaseHTTPClient';
|
|
5
5
|
export default class Kmd extends ServiceClient {
|
|
6
6
|
constructor(token: string | KMDTokenHeader | CustomTokenHeader, baseServer?: string, port?: string | number, headers?: {});
|
|
7
7
|
/**
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseHTTPClient, BaseHTTPClientResponse, Query } from './baseHTTPClient';
|
|
2
|
+
export interface AlgodTokenHeader {
|
|
3
|
+
'X-Algo-API-Token': string;
|
|
4
|
+
}
|
|
5
|
+
export interface IndexerTokenHeader {
|
|
6
|
+
'X-Indexer-API-Token': string;
|
|
7
|
+
}
|
|
8
|
+
export interface KMDTokenHeader {
|
|
9
|
+
'X-KMD-API-Token': string;
|
|
10
|
+
}
|
|
11
|
+
export interface CustomTokenHeader {
|
|
12
|
+
[headerName: string]: string;
|
|
13
|
+
}
|
|
14
|
+
export declare type TokenHeader = AlgodTokenHeader | IndexerTokenHeader | KMDTokenHeader | CustomTokenHeader;
|
|
15
|
+
/**
|
|
16
|
+
* Implementation of BaseHTTPClient that uses a URL and a token
|
|
17
|
+
* and make the REST queries using superagent.
|
|
18
|
+
* This is the default implementation of BaseHTTPClient.
|
|
19
|
+
*/
|
|
20
|
+
export declare class URLTokenBaseHTTPClient implements BaseHTTPClient {
|
|
21
|
+
private defaultHeaders;
|
|
22
|
+
private readonly baseURL;
|
|
23
|
+
private readonly tokenHeader;
|
|
24
|
+
constructor(tokenHeader: TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record<string, any>);
|
|
25
|
+
/**
|
|
26
|
+
* Compute the URL for a path relative to the instance's address
|
|
27
|
+
* @param relativePath - A path string
|
|
28
|
+
* @returns A URL string
|
|
29
|
+
*/
|
|
30
|
+
private addressWithPath;
|
|
31
|
+
/**
|
|
32
|
+
* Convert a superagent response to a valid BaseHTTPClientResponse
|
|
33
|
+
* Modify the superagent response
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private static superagentToHTTPClientResponse;
|
|
37
|
+
/**
|
|
38
|
+
* Make a superagent error more readable. For more info, see https://github.com/visionmedia/superagent/issues/1074
|
|
39
|
+
*/
|
|
40
|
+
private static formatSuperagentError;
|
|
41
|
+
get(relativePath: string, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
42
|
+
post(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
43
|
+
delete(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
|
|
44
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ServiceClient from '../serviceClient';
|
|
2
|
-
import { AlgodTokenHeader, CustomTokenHeader } from '../../client';
|
|
3
2
|
import * as modelsv2 from './models/types';
|
|
4
3
|
import AccountInformation from './accountInformation';
|
|
5
4
|
import Block from './block';
|
|
@@ -19,8 +18,15 @@ import Supply from './supply';
|
|
|
19
18
|
import Versions from './versions';
|
|
20
19
|
import Genesis from './genesis';
|
|
21
20
|
import Proof from './proof';
|
|
21
|
+
import { BaseHTTPClient } from '../../baseHTTPClient';
|
|
22
|
+
import { AlgodTokenHeader, CustomTokenHeader } from '../../urlTokenBaseHTTPClient';
|
|
22
23
|
export default class AlgodClient extends ServiceClient {
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Create an AlgodClient from
|
|
26
|
+
* * either a token, baseServer, port, and optional headers
|
|
27
|
+
* * or a base client server for interoperability with external dApp wallets
|
|
28
|
+
*/
|
|
29
|
+
constructor(tokenOrBaseClient: string | AlgodTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer?: string, port?: string | number, headers?: Record<string, string>);
|
|
24
30
|
healthCheck(): HealthCheck;
|
|
25
31
|
versionsCheck(): Versions;
|
|
26
32
|
sendRawTransaction(stxOrStxs: Uint8Array | Uint8Array[]): SendRawTransaction;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ServiceClient from '../serviceClient';
|
|
2
|
-
import { CustomTokenHeader, IndexerTokenHeader } from '../../client';
|
|
3
2
|
import MakeHealthCheck from './makeHealthCheck';
|
|
4
3
|
import LookupAssetBalances from './lookupAssetBalances';
|
|
5
4
|
import LookupAssetTransactions from './lookupAssetTransactions';
|
|
@@ -14,8 +13,15 @@ import SearchAccounts from './searchAccounts';
|
|
|
14
13
|
import SearchForTransactions from './searchForTransactions';
|
|
15
14
|
import SearchForAssets from './searchForAssets';
|
|
16
15
|
import SearchForApplications from './searchForApplications';
|
|
16
|
+
import { BaseHTTPClient } from '../../baseHTTPClient';
|
|
17
|
+
import { CustomTokenHeader, IndexerTokenHeader } from '../../urlTokenBaseHTTPClient';
|
|
17
18
|
export default class IndexerClient extends ServiceClient {
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Create an IndexerClient from
|
|
21
|
+
* * either a token, baseServer, port, and optional headers
|
|
22
|
+
* * or a base client server for interoperability with external dApp wallets
|
|
23
|
+
*/
|
|
24
|
+
constructor(tokenOrBaseClient: string | IndexerTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer?: string, port?: string | number, headers?: Record<string, string>);
|
|
19
25
|
/**
|
|
20
26
|
* Returns the health object for the service.
|
|
21
27
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import HTTPClient
|
|
1
|
+
import HTTPClient from '../client';
|
|
2
2
|
import IntDecoding from '../../types/intDecoding';
|
|
3
|
+
import { BaseHTTPClient } from '../baseHTTPClient';
|
|
4
|
+
import { TokenHeader } from '../urlTokenBaseHTTPClient';
|
|
3
5
|
export declare type TokenHeaderIdentifier = 'X-Indexer-API-Token' | 'X-KMD-API-Token' | 'X-Algo-API-Token' | string;
|
|
4
6
|
/**
|
|
5
7
|
* Abstract service client to encapsulate shared AlgodClient and IndexerClient logic
|
|
@@ -7,7 +9,7 @@ export declare type TokenHeaderIdentifier = 'X-Indexer-API-Token' | 'X-KMD-API-T
|
|
|
7
9
|
export default abstract class ServiceClient {
|
|
8
10
|
c: HTTPClient;
|
|
9
11
|
intDecoding: IntDecoding;
|
|
10
|
-
constructor(tokenHeaderIdentifier: TokenHeaderIdentifier,
|
|
12
|
+
constructor(tokenHeaderIdentifier: TokenHeaderIdentifier, tokenHeaderOrStrOrBaseClient: string | TokenHeader | BaseHTTPClient, baseServer: string, port?: string | number, defaultHeaders?: Record<string, any>);
|
|
11
13
|
/**
|
|
12
14
|
* Set the default int decoding method for all JSON requests this client creates.
|
|
13
15
|
* @param method - \{"default" | "safe" | "mixed" | "bigint"\} method The method to use when parsing the
|
|
@@ -68,9 +68,9 @@ export declare class AtomicTransactionComposer {
|
|
|
68
68
|
* causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid
|
|
69
69
|
* for the given method.
|
|
70
70
|
*/
|
|
71
|
-
addMethodCall({
|
|
72
|
-
/** The ID of the smart contract to call */
|
|
73
|
-
|
|
71
|
+
addMethodCall({ appID, method, methodArgs, sender, suggestedParams, onComplete, approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages, note, lease, rekeyTo, signer, }: {
|
|
72
|
+
/** The ID of the smart contract to call. Set this to 0 to indicate an application creation call. */
|
|
73
|
+
appID: number;
|
|
74
74
|
/** The method to call on the smart contract */
|
|
75
75
|
method: ABIMethod;
|
|
76
76
|
/** The arguments to include in the method call. If omitted, no arguments will be passed to the method. */
|
|
@@ -81,6 +81,20 @@ export declare class AtomicTransactionComposer {
|
|
|
81
81
|
suggestedParams: SuggestedParams;
|
|
82
82
|
/** The OnComplete action to take for this application call. If omitted, OnApplicationComplete.NoOpOC will be used. */
|
|
83
83
|
onComplete?: OnApplicationComplete;
|
|
84
|
+
/** The approval program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */
|
|
85
|
+
approvalProgram?: Uint8Array;
|
|
86
|
+
/** The clear program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */
|
|
87
|
+
clearProgram?: Uint8Array;
|
|
88
|
+
/** The global integer schema size. Only set this if this is an application creation call. */
|
|
89
|
+
numGlobalInts?: number;
|
|
90
|
+
/** The global byte slice schema size. Only set this if this is an application creation call. */
|
|
91
|
+
numGlobalByteSlices?: number;
|
|
92
|
+
/** The local integer schema size. Only set this if this is an application creation call. */
|
|
93
|
+
numLocalInts?: number;
|
|
94
|
+
/** The local byte slice schema size. Only set this if this is an application creation call. */
|
|
95
|
+
numLocalByteSlices?: number;
|
|
96
|
+
/** The number of extra pages to allocate for the application's programs. Only set this if this is an application creation call. If omitted, defaults to 0. */
|
|
97
|
+
extraPages?: number;
|
|
84
98
|
/** The note value for this application call */
|
|
85
99
|
note?: Uint8Array;
|
|
86
100
|
/** The lease value for this application call */
|
package/dist/types/src/main.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export { default as Kmd } from './client/kmd';
|
|
|
66
66
|
export { default as IntDecoding } from './types/intDecoding';
|
|
67
67
|
export { default as Account } from './types/account';
|
|
68
68
|
export { default as Indexer } from './client/v2/indexer/indexer';
|
|
69
|
+
export { BaseHTTPClient, BaseHTTPClientResponse, BaseHTTPClientError, } from './client/baseHTTPClient';
|
|
69
70
|
export { waitForConfirmation } from './wait';
|
|
70
71
|
export { isValidAddress, encodeAddress, decodeAddress, getApplicationAddress, } from './encoding/address';
|
|
71
72
|
export { encodeUint64, decodeUint64 } from './encoding/uint64';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "algosdk",
|
|
3
|
-
"version": "1.13.0-beta.
|
|
3
|
+
"version": "1.13.0-beta.2",
|
|
4
4
|
"description": "The official JavaScript SDK for Algorand",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -59,7 +59,9 @@
|
|
|
59
59
|
"source-map-loader": "^2.0.2",
|
|
60
60
|
"ts-loader": "^8.3.0",
|
|
61
61
|
"ts-node": "^10.0.0",
|
|
62
|
-
"typedoc": "^0.
|
|
62
|
+
"typedoc": "^0.22.10",
|
|
63
|
+
"typedoc-plugin-missing-exports": "^0.22.6",
|
|
64
|
+
"typedoc-plugin-rename-defaults": "^0.4.0",
|
|
63
65
|
"typescript": "^4.2.3",
|
|
64
66
|
"webpack": "^5.38.1",
|
|
65
67
|
"webpack-cli": "^4.7.2"
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"prepare": "npm run build",
|
|
70
72
|
"prepare-browser-tests": "npm run build && mkdir -p tests/cucumber/browser/build && cp dist/browser/algosdk.min.* tests/cucumber/browser/build/ && webpack --config tests/cucumber/browser/webpack.config.js",
|
|
71
73
|
"build": "concurrently \"webpack --config webpack.config.js\" \"tsc -p tsconfig-esm.json\" \"tsc -p tsconfig-cjs.json\"",
|
|
72
|
-
"docs": "typedoc src/main.ts",
|
|
74
|
+
"docs": "typedoc src/main.ts --options typedoc.config.json",
|
|
73
75
|
"lint": "eslint .",
|
|
74
76
|
"lint:fix": "eslint --fix .",
|
|
75
77
|
"format": "prettier --write .",
|