@xelis/sdk 0.11.32 → 0.11.34
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/dist/cjs/contract/contract.js +126 -84
- package/dist/cjs/contract/typed_contract.js +134 -88
- package/dist/cjs/contract/xvm_serializer.js +252 -29
- package/dist/cjs/rpc/websocket.js +10 -4
- package/dist/esm/contract/contract.js +125 -83
- package/dist/esm/contract/typed_contract.js +131 -85
- package/dist/esm/contract/xvm_serializer.js +244 -27
- package/dist/esm/rpc/websocket.js +10 -4
- package/dist/types/contract/contract.d.ts +46 -10
- package/dist/types/contract/typed_contract.d.ts +50 -15
- package/dist/types/contract/xvm_serializer.d.ts +68 -4
- package/dist/types/daemon/types.d.ts +17 -8
- package/dist/types/wallet/rpc.d.ts +1 -1
- package/dist/types/wallet/types.d.ts +34 -17
- package/dist/types/wallet/websocket.d.ts +1 -1
- package/package.json +1 -1
|
@@ -34,8 +34,6 @@ export class WSRPC {
|
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
let idRefObject = {};
|
|
37
|
-
await this.dataCall(`subscribe`, { notify: event }, idRefObject)
|
|
38
|
-
.catch(err => listener(null, err));
|
|
39
37
|
const onMessage = (msgEvent) => {
|
|
40
38
|
const eventData = this.events.get(event);
|
|
41
39
|
if (eventData && typeof msgEvent.data === `string`) {
|
|
@@ -58,8 +56,16 @@ export class WSRPC {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
try {
|
|
60
|
+
this.socket.addEventListener(`message`, onMessage);
|
|
61
|
+
this.events.set(event, { onMessage, listeners: [listener] });
|
|
62
|
+
await this.dataCall(`subscribe`, { notify: event }, idRefObject);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
this.socket.removeEventListener(`message`, onMessage);
|
|
66
|
+
this.events.delete(event);
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
// make sure connection is open or wait
|
|
@@ -7,21 +7,38 @@ export interface ABIEntry {
|
|
|
7
7
|
name: string;
|
|
8
8
|
outputs?: string;
|
|
9
9
|
params: ABIParam[];
|
|
10
|
-
type: 'entry'
|
|
10
|
+
type: 'entry';
|
|
11
|
+
}
|
|
12
|
+
export interface InternalType {
|
|
13
|
+
name: string;
|
|
14
|
+
kind: 'struct' | 'enum';
|
|
15
|
+
fields?: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}>;
|
|
19
|
+
variants?: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
fields: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}>;
|
|
25
|
+
}>;
|
|
11
26
|
}
|
|
12
27
|
export interface ABI {
|
|
13
28
|
data: ABIEntry[];
|
|
14
29
|
version: string;
|
|
30
|
+
internal_types?: InternalType[];
|
|
15
31
|
}
|
|
16
32
|
export interface ContractCallParams {
|
|
17
33
|
[key: string]: any;
|
|
18
34
|
maxGas?: number;
|
|
35
|
+
permission: string;
|
|
19
36
|
deposits?: Record<string, number | bigint>;
|
|
20
37
|
}
|
|
21
38
|
export interface IContract {
|
|
22
39
|
readonly address: string;
|
|
23
40
|
readonly abi: ABI;
|
|
24
|
-
invoke(
|
|
41
|
+
invoke(method_name: string, params?: ContractCallParams): Record<string, any>;
|
|
25
42
|
}
|
|
26
43
|
type GenerateContractMethods<T extends ABI> = {
|
|
27
44
|
[K in T['data'][number]['name']]: (params?: ContractCallParams) => Record<string, any>;
|
|
@@ -34,34 +51,53 @@ export declare class Contract<T extends ABI = ABI> implements IContract {
|
|
|
34
51
|
readonly abi: T;
|
|
35
52
|
private readonly methods;
|
|
36
53
|
constructor(address: string, abi: T);
|
|
54
|
+
/**
|
|
55
|
+
* Register all custom types from ABI
|
|
56
|
+
*/
|
|
57
|
+
private register_internal_types;
|
|
58
|
+
/**
|
|
59
|
+
* Helper to create struct values with positional arguments
|
|
60
|
+
* Validates field types immediately
|
|
61
|
+
* @param type_name - Name of the struct type
|
|
62
|
+
* @param field_values - Field values in the order defined in ABI
|
|
63
|
+
*/
|
|
64
|
+
struct(type_name: string, ...field_values: any[]): any;
|
|
65
|
+
/**
|
|
66
|
+
* Helper to create enum values with positional arguments
|
|
67
|
+
* Validates field types immediately
|
|
68
|
+
* @param type_name - Name of the enum type
|
|
69
|
+
* @param variant_name - Name of the variant
|
|
70
|
+
* @param field_values - Field values in the order defined in ABI
|
|
71
|
+
*/
|
|
72
|
+
enum(type_name: string, variant_name: string, ...field_values: any[]): any;
|
|
37
73
|
/**
|
|
38
74
|
* Creates a dynamic method on the contract instance
|
|
39
75
|
*/
|
|
40
|
-
private
|
|
76
|
+
private create_dynamic_method;
|
|
41
77
|
/**
|
|
42
78
|
* Invoke a contract method by name
|
|
43
|
-
* @param
|
|
79
|
+
* @param method_name - Name of the method from the ABI
|
|
44
80
|
* @param params - Parameters for the method call
|
|
45
81
|
*/
|
|
46
|
-
invoke(
|
|
82
|
+
invoke(method_name: string, params?: ContractCallParams): Record<string, any>;
|
|
47
83
|
/**
|
|
48
84
|
* Get list of available methods
|
|
49
85
|
*/
|
|
50
|
-
|
|
86
|
+
get_methods(): string[];
|
|
51
87
|
/**
|
|
52
88
|
* Get method signature information
|
|
53
89
|
*/
|
|
54
|
-
|
|
90
|
+
get_method_signature(method_name: string): ABIEntry | undefined;
|
|
55
91
|
/**
|
|
56
92
|
* Validate parameters for a method without creating the transaction
|
|
57
93
|
*/
|
|
58
|
-
|
|
94
|
+
validate_params(method_name: string, params: ContractCallParams): boolean;
|
|
59
95
|
}
|
|
60
96
|
/**
|
|
61
97
|
* Helper function to create a typed contract instance
|
|
62
98
|
* This provides better TypeScript support when the ABI is known at compile time
|
|
63
99
|
*/
|
|
64
|
-
export declare function
|
|
100
|
+
export declare function create_contract<T extends ABI>(address: string, abi: T): Contract<T> & GenerateContractMethods<T>;
|
|
65
101
|
/**
|
|
66
102
|
* Factory for creating multiple contracts with the same ABI
|
|
67
103
|
*/
|
|
@@ -75,6 +111,6 @@ export declare class ContractFactory<T extends ABI = ABI> {
|
|
|
75
111
|
/**
|
|
76
112
|
* Get the ABI
|
|
77
113
|
*/
|
|
78
|
-
|
|
114
|
+
get_abi(): T;
|
|
79
115
|
}
|
|
80
116
|
export {};
|
|
@@ -9,14 +9,30 @@ export interface ABIEntry {
|
|
|
9
9
|
name: string;
|
|
10
10
|
outputs?: string | string[];
|
|
11
11
|
params: ABIParam[];
|
|
12
|
-
type: 'entry'
|
|
12
|
+
type: 'entry';
|
|
13
13
|
description?: string;
|
|
14
14
|
}
|
|
15
|
+
export interface InternalType {
|
|
16
|
+
name: string;
|
|
17
|
+
kind: 'struct' | 'enum';
|
|
18
|
+
fields?: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
}>;
|
|
22
|
+
variants?: Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
fields: Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
15
30
|
export type ABI = {
|
|
16
31
|
data: ABIEntry[];
|
|
17
32
|
version: string;
|
|
33
|
+
internal_types?: InternalType[];
|
|
18
34
|
};
|
|
19
|
-
type ParamType<T extends string> = T extends 'Hash' ? string : T extends 'Address' ? string : T extends 'PublicKey' ? string : T extends 'Blob' ? string : T extends 'String' | 'string' ? string : T extends 'Boolean' | 'boolean' | 'bool' ? boolean : T extends 'U256' | 'u256' ? bigint | number : T extends 'U128' | 'u128' ? bigint | number : T extends 'U64' | 'u64' ? bigint | number : T extends 'U32' | 'u32' ? number : T extends 'U16' | 'u16' ? number : T extends 'U8' | 'u8' ? number : any;
|
|
35
|
+
type ParamType<T extends string> = T extends 'Hash' ? string : T extends 'Address' ? string : T extends 'PublicKey' ? string : T extends 'Blob' ? string : T extends 'String' | 'string' ? string : T extends 'Boolean' | 'boolean' | 'bool' ? boolean : T extends 'U256' | 'u256' ? bigint | number : T extends 'U128' | 'u128' ? bigint | number : T extends 'U64' | 'u64' ? bigint | number : T extends 'U32' | 'u32' ? number : T extends 'U16' | 'u16' ? number : T extends 'U8' | 'u8' ? number : T extends `${infer Inner}[]` ? Array<ParamType<Inner>> : T extends `optional<${infer Inner}>` ? ParamType<Inner> | null | undefined : T extends `map<${infer K}, ${infer V}>` ? ParamType<K> extends string | number | symbol ? Record<ParamType<K>, ParamType<V>> : Record<string, ParamType<V>> : T extends `(${string})` ? any[] : any;
|
|
20
36
|
type ExtractParams<T extends ABIEntry> = {
|
|
21
37
|
[K in T['params'][number] as K['name']]: K extends {
|
|
22
38
|
optional: true;
|
|
@@ -37,39 +53,58 @@ export declare class TypedContract<T extends ABI> {
|
|
|
37
53
|
readonly abi: T;
|
|
38
54
|
private readonly methods;
|
|
39
55
|
constructor(address: string, abi: T);
|
|
56
|
+
/**
|
|
57
|
+
* Register all custom types from ABI
|
|
58
|
+
*/
|
|
59
|
+
private register_internal_types;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to create struct values with positional arguments
|
|
62
|
+
* Validates field types immediately
|
|
63
|
+
* @param type_name - Name of the struct type
|
|
64
|
+
* @param field_values - Field values in the order defined in ABI
|
|
65
|
+
*/
|
|
66
|
+
struct(type_name: string, ...field_values: any[]): any;
|
|
67
|
+
/**
|
|
68
|
+
* Helper to create enum values with positional arguments
|
|
69
|
+
* Validates field types immediately
|
|
70
|
+
* @param type_name - Name of the enum type
|
|
71
|
+
* @param variant_name - Name of the variant
|
|
72
|
+
* @param field_values - Field values in the order defined in ABI
|
|
73
|
+
*/
|
|
74
|
+
enum(type_name: string, variant_name: string, ...field_values: any[]): any;
|
|
40
75
|
/**
|
|
41
76
|
* Internal method to invoke contract functions
|
|
42
77
|
*/
|
|
43
|
-
invokeUnsafe(
|
|
78
|
+
invokeUnsafe(method_name: string, params?: any): Record<string, any>;
|
|
44
79
|
/**
|
|
45
80
|
* Type-safe invoke method
|
|
46
81
|
*/
|
|
47
|
-
invoke<K extends T['data'][number]['name']>(
|
|
82
|
+
invoke<K extends T['data'][number]['name']>(method_name: K, params: K extends T['data'][number]['name'] ? T['data'][number] extends infer E ? E extends ABIEntry ? E['name'] extends K ? ExtractParams<E> : never : never : never : never): Record<string, any>;
|
|
48
83
|
/**
|
|
49
84
|
* Get list of available methods
|
|
50
85
|
*/
|
|
51
|
-
|
|
86
|
+
get_methods(): string[];
|
|
52
87
|
/**
|
|
53
88
|
* Get method signature information
|
|
54
89
|
*/
|
|
55
|
-
|
|
90
|
+
get_method_signature(method_name: string): ABIEntry | undefined;
|
|
56
91
|
/**
|
|
57
92
|
* Generate TypeScript interface for the contract
|
|
58
93
|
*/
|
|
59
|
-
|
|
60
|
-
private
|
|
94
|
+
generate_interface(): string;
|
|
95
|
+
private get_typescript_type;
|
|
61
96
|
}
|
|
62
97
|
/**
|
|
63
98
|
* Create a typed contract instance with full TypeScript support
|
|
64
99
|
*/
|
|
65
|
-
export declare function
|
|
100
|
+
export declare function create_typed_contract<T extends ABI>(address: string, abi: T): TypedContract<T> & MethodsFromABI<T>;
|
|
66
101
|
/**
|
|
67
102
|
* Contract factory with strong typing
|
|
68
103
|
*/
|
|
69
104
|
export declare class TypedContractFactory<T extends ABI> {
|
|
70
105
|
private readonly abi;
|
|
71
|
-
private readonly
|
|
72
|
-
constructor(abi: T,
|
|
106
|
+
private readonly contract_name;
|
|
107
|
+
constructor(abi: T, contract_name?: string);
|
|
73
108
|
/**
|
|
74
109
|
* Create a new contract instance at the specified address
|
|
75
110
|
*/
|
|
@@ -77,18 +112,18 @@ export declare class TypedContractFactory<T extends ABI> {
|
|
|
77
112
|
/**
|
|
78
113
|
* Get the ABI
|
|
79
114
|
*/
|
|
80
|
-
|
|
115
|
+
get_abi(): T;
|
|
81
116
|
/**
|
|
82
117
|
* Generate TypeScript definitions for this contract
|
|
83
118
|
*/
|
|
84
|
-
|
|
119
|
+
generate_type_definitions(): string;
|
|
85
120
|
}
|
|
86
121
|
/**
|
|
87
122
|
* Utility to validate ABI structure
|
|
88
123
|
*/
|
|
89
|
-
export declare function
|
|
124
|
+
export declare function validate_abi(abi: any): abi is ABI;
|
|
90
125
|
/**
|
|
91
126
|
* Helper to create a contract from JSON ABI
|
|
92
127
|
*/
|
|
93
|
-
export declare function
|
|
128
|
+
export declare function create_contract_from_json(address: string, abi_path: string): Promise<TypedContract<ABI> & MethodsFromABI<ABI>>;
|
|
94
129
|
export {};
|
|
@@ -23,14 +23,26 @@ export type ValidationType = keyof typeof TYPE_VALIDATORS;
|
|
|
23
23
|
* @param type - The type string (e.g., 'u64', 'Hash', 'string')
|
|
24
24
|
* @param validate - Whether to validate and convert the value (default: true)
|
|
25
25
|
*/
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function createVMPrimitive(value: any, type: ValidationType, validate?: boolean): VMParameter;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize an array of values
|
|
29
|
+
*/
|
|
30
|
+
export declare function serialize_array(items: any[], item_type: string): VMParameter;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize a map
|
|
33
|
+
*/
|
|
34
|
+
export declare function serialize_map(map: Record<string, any>, keyType: string, valueType: string): VMParameter;
|
|
35
|
+
/**
|
|
36
|
+
* Serialize an optional value
|
|
37
|
+
*/
|
|
38
|
+
export declare function serialize_optional(value: any, inner_type: string): VMParameter;
|
|
27
39
|
/**
|
|
28
40
|
* Convenience functions for common types
|
|
29
41
|
*/
|
|
30
|
-
export declare const
|
|
42
|
+
export declare const VMParam: {
|
|
31
43
|
hash: (value: string) => VMParameter;
|
|
32
44
|
address: (value: string) => VMParameter;
|
|
33
|
-
|
|
45
|
+
public_key: (value: string) => VMParameter;
|
|
34
46
|
blob: (value: string) => VMParameter;
|
|
35
47
|
u64: (value: number | bigint) => VMParameter;
|
|
36
48
|
u32: (value: number) => VMParameter;
|
|
@@ -39,6 +51,57 @@ export declare const vmParam: {
|
|
|
39
51
|
string: (value: string) => VMParameter;
|
|
40
52
|
boolean: (value: boolean) => VMParameter;
|
|
41
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* A type that knows how to serialize itself to VMParameter
|
|
56
|
+
*/
|
|
57
|
+
export interface SerializableType {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
to_VMParameter(value: any): VMParameter;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Enum variant schema
|
|
63
|
+
*/
|
|
64
|
+
export interface EnumVariantSchema {
|
|
65
|
+
name: string;
|
|
66
|
+
fields: Array<{
|
|
67
|
+
name: string;
|
|
68
|
+
type: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Struct field schema
|
|
73
|
+
*/
|
|
74
|
+
export interface StructFieldSchema {
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Define an enum type from ABI schema
|
|
80
|
+
*/
|
|
81
|
+
export declare function defineEnum(name: string, variants: EnumVariantSchema[]): SerializableType;
|
|
82
|
+
/**
|
|
83
|
+
* Define a struct type from ABI schema
|
|
84
|
+
*/
|
|
85
|
+
export declare function defineStruct(name: string, fields: StructFieldSchema[]): SerializableType;
|
|
86
|
+
/**
|
|
87
|
+
* Type registry - simple Map for custom types
|
|
88
|
+
*/
|
|
89
|
+
declare class TypeRegistry {
|
|
90
|
+
private types;
|
|
91
|
+
register(definition: SerializableType): SerializableType;
|
|
92
|
+
get(name: string): SerializableType | undefined;
|
|
93
|
+
has(name: string): boolean;
|
|
94
|
+
clear(): void;
|
|
95
|
+
all(): Iterable<SerializableType>;
|
|
96
|
+
}
|
|
97
|
+
export declare const typeRegistry: TypeRegistry;
|
|
98
|
+
/**
|
|
99
|
+
* Enhanced parameter creation that handles both primitive and custom types
|
|
100
|
+
* @param value - The value to serialize
|
|
101
|
+
* @param type - The type string (primitive or custom type name)
|
|
102
|
+
* @param validate - Whether to validate primitive values (default: true)
|
|
103
|
+
*/
|
|
104
|
+
export declare function createVMParameter(value: any, type: string, validate?: boolean): VMParameter;
|
|
42
105
|
/**
|
|
43
106
|
* Creates a deposits object for contract calls
|
|
44
107
|
* @param deposits - Object mapping token hashes to amounts
|
|
@@ -51,8 +114,9 @@ export declare function createDeposits(deposits: Record<string, number | bigint>
|
|
|
51
114
|
*/
|
|
52
115
|
export interface ContractInvocationParams {
|
|
53
116
|
contract: string;
|
|
54
|
-
|
|
117
|
+
chunk_id: number;
|
|
55
118
|
parameters?: VMParameter[];
|
|
119
|
+
permission: string;
|
|
56
120
|
deposits?: Record<string, number | bigint>;
|
|
57
121
|
maxGas?: number;
|
|
58
122
|
}
|
|
@@ -300,16 +300,27 @@ export interface Reference {
|
|
|
300
300
|
hash: string;
|
|
301
301
|
topoheight: number;
|
|
302
302
|
}
|
|
303
|
+
export interface SignatureId {
|
|
304
|
+
id: number;
|
|
305
|
+
signature: string;
|
|
306
|
+
}
|
|
307
|
+
export interface MultiSig {
|
|
308
|
+
signatures: {
|
|
309
|
+
[id: number]: SignatureId;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
303
312
|
export interface Transaction {
|
|
304
313
|
hash: string;
|
|
305
314
|
version: number;
|
|
306
315
|
source: string;
|
|
307
316
|
data: TransactionData;
|
|
308
317
|
fee: number;
|
|
318
|
+
fee_limit: number;
|
|
309
319
|
nonce: number;
|
|
310
320
|
source_commitments: SourceCommitment[];
|
|
311
321
|
range_proof: number[];
|
|
312
322
|
reference: Reference;
|
|
323
|
+
multisig?: MultiSig;
|
|
313
324
|
signature: string;
|
|
314
325
|
size: number;
|
|
315
326
|
}
|
|
@@ -418,25 +429,23 @@ export interface MaxSupplyFixed {
|
|
|
418
429
|
export interface MaxSupplyMintable {
|
|
419
430
|
mintable: number;
|
|
420
431
|
}
|
|
421
|
-
export
|
|
432
|
+
export type MaxSupplyMode = "none" | MaxSupplyFixed | MaxSupplyMintable;
|
|
433
|
+
export interface AssetOwnerCreator {
|
|
422
434
|
contract: string;
|
|
423
435
|
id: number;
|
|
424
436
|
}
|
|
425
|
-
export interface
|
|
437
|
+
export interface AssetOwnerOwner {
|
|
426
438
|
origin: string;
|
|
427
439
|
origin_id: number;
|
|
428
440
|
owner: string;
|
|
429
441
|
}
|
|
442
|
+
export type AssetOwner = "none" | AssetOwnerCreator | AssetOwnerOwner;
|
|
430
443
|
export interface AssetData {
|
|
431
444
|
decimals: number;
|
|
432
445
|
name: string;
|
|
433
446
|
ticker: string;
|
|
434
|
-
max_supply:
|
|
435
|
-
owner:
|
|
436
|
-
creator: AssetCreator;
|
|
437
|
-
} | {
|
|
438
|
-
owner: AssetOwner;
|
|
439
|
-
};
|
|
447
|
+
max_supply: MaxSupplyMode;
|
|
448
|
+
owner: AssetOwner;
|
|
440
449
|
topoheight: number;
|
|
441
450
|
}
|
|
442
451
|
export interface AssetWithData extends AssetData {
|
|
@@ -25,7 +25,7 @@ export declare class RPC extends HttpRPC {
|
|
|
25
25
|
buildTransaction(params: types.BuildTransactionParams): Promise<types.TransactionResponse>;
|
|
26
26
|
buildTransactionOffline(params: types.BuildTransactionOfflineParams): Promise<types.TransactionResponse>;
|
|
27
27
|
buildUnsignedTransaction(params: types.BuildTransactionParams): Promise<types.UnsignedTransactionResponse>;
|
|
28
|
-
signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<
|
|
28
|
+
signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<daemonTypes.SignatureId>;
|
|
29
29
|
finalizeUnsignedTransaction(params: types.FinalizeUnsignedTransactionParams): Promise<types.TransactionResponse>;
|
|
30
30
|
clearTxCache(): Promise<boolean>;
|
|
31
31
|
listTransactions(params?: types.ListTransactionParams): Promise<types.TransactionEntry[]>;
|
|
@@ -2,10 +2,20 @@ import * as daemonTypes from '../daemon/types';
|
|
|
2
2
|
export interface GetAddressParams {
|
|
3
3
|
integrated_data?: string;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
value?: number;
|
|
5
|
+
export interface ExtraFeeModeTip {
|
|
6
|
+
tip: number;
|
|
8
7
|
}
|
|
8
|
+
export interface ExtraFeeModeMultiplier {
|
|
9
|
+
multiplier: number;
|
|
10
|
+
}
|
|
11
|
+
export type ExtraFeeMode = "none" | ExtraFeeModeTip | ExtraFeeModeMultiplier;
|
|
12
|
+
export interface FeeBuilderFixed {
|
|
13
|
+
fixed: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FeeBuilderExtra {
|
|
16
|
+
extra: ExtraFeeMode;
|
|
17
|
+
}
|
|
18
|
+
export type FeeBuilder = FeeBuilderFixed | FeeBuilderExtra;
|
|
9
19
|
export interface MultiSigBuilder {
|
|
10
20
|
participants: string[];
|
|
11
21
|
threshold: number;
|
|
@@ -44,45 +54,51 @@ export interface SignerId {
|
|
|
44
54
|
id: number;
|
|
45
55
|
private_key: number[];
|
|
46
56
|
}
|
|
47
|
-
export interface
|
|
57
|
+
export interface BaseFeeModeFixed {
|
|
58
|
+
fixed: number;
|
|
59
|
+
}
|
|
60
|
+
export interface BaseFeeModeCap {
|
|
61
|
+
cap: number;
|
|
62
|
+
}
|
|
63
|
+
type BaseFeeMode = "none" | BaseFeeModeFixed | BaseFeeModeCap;
|
|
64
|
+
export interface BuildUnsignedTransaction {
|
|
48
65
|
transfers?: TransferBuilder[];
|
|
49
66
|
burn?: daemonTypes.Burn;
|
|
50
67
|
multi_sig?: MultiSigBuilder;
|
|
51
68
|
invoke_contract?: InvokeContractBuilder;
|
|
52
69
|
deploy_contract?: DeployContractBuilder;
|
|
53
70
|
fee?: FeeBuilder;
|
|
71
|
+
base_fee?: BaseFeeMode;
|
|
72
|
+
fee_limit?: number;
|
|
54
73
|
nonce?: number;
|
|
55
74
|
tx_version?: number;
|
|
56
|
-
broadcast: boolean;
|
|
57
75
|
tx_as_hex: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface BuildTransactionParams extends BuildUnsignedTransaction {
|
|
78
|
+
broadcast: boolean;
|
|
58
79
|
signers?: SignerId[];
|
|
59
80
|
}
|
|
60
81
|
export interface BuildTransactionOfflineParams extends BuildTransactionParams {
|
|
61
|
-
|
|
82
|
+
balances: {
|
|
83
|
+
[hash: string]: any;
|
|
84
|
+
};
|
|
62
85
|
reference: daemonTypes.Reference;
|
|
86
|
+
nonce: number;
|
|
63
87
|
}
|
|
64
88
|
export interface TransactionResponse extends daemonTypes.Transaction {
|
|
65
89
|
txt_as_hex?: string;
|
|
66
90
|
}
|
|
67
|
-
export interface SignatureId {
|
|
68
|
-
id: number;
|
|
69
|
-
signature: string;
|
|
70
|
-
}
|
|
71
|
-
export interface MultiSig {
|
|
72
|
-
signatures: {
|
|
73
|
-
[id: number]: SignatureId;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
91
|
export interface UnsignedTransaction {
|
|
77
92
|
version: number;
|
|
78
93
|
source: string;
|
|
79
94
|
data: daemonTypes.TransactionData;
|
|
80
95
|
fee: number;
|
|
96
|
+
fee_limit: number;
|
|
81
97
|
nonce: number;
|
|
82
98
|
source_commitments: daemonTypes.SourceCommitment[];
|
|
83
99
|
reference: daemonTypes.Reference;
|
|
84
100
|
range_proof: number[];
|
|
85
|
-
multisig?: MultiSig;
|
|
101
|
+
multisig?: daemonTypes.MultiSig;
|
|
86
102
|
}
|
|
87
103
|
export interface UnsignedTransactionResponse extends UnsignedTransaction {
|
|
88
104
|
hash: string;
|
|
@@ -201,7 +217,7 @@ export interface SignUnsignedTransactionParams {
|
|
|
201
217
|
}
|
|
202
218
|
export interface FinalizeUnsignedTransactionParams {
|
|
203
219
|
unsigned: string;
|
|
204
|
-
signatures: SignatureId[];
|
|
220
|
+
signatures: daemonTypes.SignatureId[];
|
|
205
221
|
broadcast: boolean;
|
|
206
222
|
tx_as_hex: boolean;
|
|
207
223
|
}
|
|
@@ -366,3 +382,4 @@ export declare enum RPCEvent {
|
|
|
366
382
|
TrackAsset = "track_asset",
|
|
367
383
|
UntrackAsset = "untrack_asset"
|
|
368
384
|
}
|
|
385
|
+
export {};
|
|
@@ -77,7 +77,7 @@ export declare class WalletMethods {
|
|
|
77
77
|
buildTransaction(params: types.BuildTransactionParams): Promise<types.TransactionResponse>;
|
|
78
78
|
buildTransactionOffline(params: types.BuildTransactionOfflineParams): Promise<types.TransactionResponse>;
|
|
79
79
|
buildUnsignedTransaction(params: types.BuildTransactionParams): Promise<types.UnsignedTransactionResponse>;
|
|
80
|
-
signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<
|
|
80
|
+
signUnsignedTransaction(params: types.SignUnsignedTransactionParams): Promise<daemonTypes.SignatureId>;
|
|
81
81
|
finalizeUnsignedTransaction(params: types.FinalizeUnsignedTransactionParams): Promise<types.TransactionResponse>;
|
|
82
82
|
clearTxCache(): Promise<boolean>;
|
|
83
83
|
listTransactions(params?: types.ListTransactionParams): Promise<types.TransactionEntry[]>;
|
package/package.json
CHANGED