@azguardwallet/types 0.3.1 → 0.4.0
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 -3
- package/dist/operation.d.ts +16 -31
- package/dist/result.d.ts +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
CallAction,
|
|
31
31
|
FailedResult,
|
|
32
32
|
OkResult,
|
|
33
|
+
SendTransactionResult,
|
|
33
34
|
} from "@azguardwallet/types";
|
|
34
35
|
|
|
35
36
|
if (!window.azguard) {
|
|
@@ -58,11 +59,11 @@ const [result] = await azguard.request("execute", {
|
|
|
58
59
|
],
|
|
59
60
|
});
|
|
60
61
|
|
|
61
|
-
if (result.
|
|
62
|
-
const txHash = (result as OkResult<
|
|
62
|
+
if (result.status === "ok") {
|
|
63
|
+
const txHash = (result as OkResult<SendTransactionResult>).result;
|
|
63
64
|
// ...
|
|
64
65
|
}
|
|
65
|
-
else if (result.
|
|
66
|
+
else if (result.status === "failed") {
|
|
66
67
|
const error = (result as FailedResult).error;
|
|
67
68
|
// ...
|
|
68
69
|
}
|
package/dist/operation.d.ts
CHANGED
|
@@ -2,22 +2,11 @@ import { Action, CallAction, EncodedCallAction } from "./action";
|
|
|
2
2
|
import { Result } from "./result";
|
|
3
3
|
import { CaipAccount, CaipChain } from "./dapp-session";
|
|
4
4
|
/** Operation kind */
|
|
5
|
-
export type OperationKind = "add_note" | "get_complete_address" | "register_contract" | "register_sender" | "send_transaction" | "simulate_transaction" | "
|
|
5
|
+
export type OperationKind = "add_note" | "get_complete_address" | "register_contract" | "register_sender" | "send_transaction" | "simulate_transaction" | "simulate_utility" | "simulate_views";
|
|
6
6
|
/** A request to perform some operation */
|
|
7
|
-
export type Operation =
|
|
7
|
+
export type Operation = GetCompleteAddressOperation | RegisterContractOperation | RegisterSenderOperation | SendTransactionOperation | SimulateTransactionOperation | SimulateUtilityOperation | SimulateViewsOperation;
|
|
8
8
|
/** Operation result */
|
|
9
|
-
export type OperationResult =
|
|
10
|
-
/** A request to add a note to PXE */
|
|
11
|
-
export type AddNoteOperation = {
|
|
12
|
-
/** Operation kind */
|
|
13
|
-
kind: "add_note";
|
|
14
|
-
/** Account to add the note for */
|
|
15
|
-
account: CaipAccount;
|
|
16
|
-
/** Note to add (ExtendedNote) */
|
|
17
|
-
note: unknown;
|
|
18
|
-
};
|
|
19
|
-
/** A result of the "add_note" operation */
|
|
20
|
-
export type AddNoteResult = Result<void>;
|
|
9
|
+
export type OperationResult = Result<GetCompleteAddressResult> | Result<RegisterContractResult> | Result<RegisterSenderResult> | Result<SendTransactionResult> | Result<SimulateTransactionResult> | Result<SimulateUtilityResult> | Result<SimulateViewsResult>;
|
|
21
10
|
/** A request to get complete address of the specified account */
|
|
22
11
|
export type GetCompleteAddressOperation = {
|
|
23
12
|
/** Operation kind */
|
|
@@ -26,7 +15,7 @@ export type GetCompleteAddressOperation = {
|
|
|
26
15
|
account: CaipAccount;
|
|
27
16
|
};
|
|
28
17
|
/** A result of the "get_complete_address" operation (CompleteAddress) */
|
|
29
|
-
export type GetCompleteAddressResult =
|
|
18
|
+
export type GetCompleteAddressResult = unknown;
|
|
30
19
|
/** A request to register contract in PXE */
|
|
31
20
|
export type RegisterContractOperation = {
|
|
32
21
|
/** Operation kind */
|
|
@@ -47,7 +36,7 @@ export type RegisterContractOperation = {
|
|
|
47
36
|
artifact?: unknown;
|
|
48
37
|
};
|
|
49
38
|
/** A result of the "register_contract" operation */
|
|
50
|
-
export type RegisterContractResult =
|
|
39
|
+
export type RegisterContractResult = void;
|
|
51
40
|
/** A request to register sender in PXE */
|
|
52
41
|
export type RegisterSenderOperation = {
|
|
53
42
|
/** Operation kind */
|
|
@@ -58,7 +47,7 @@ export type RegisterSenderOperation = {
|
|
|
58
47
|
address: string;
|
|
59
48
|
};
|
|
60
49
|
/** A result of the "register_sender" operation */
|
|
61
|
-
export type RegisterSenderResult =
|
|
50
|
+
export type RegisterSenderResult = void;
|
|
62
51
|
/** A request to send the transaction */
|
|
63
52
|
export type SendTransactionOperation = {
|
|
64
53
|
/** Operation kind */
|
|
@@ -77,7 +66,7 @@ export type SendTransactionOperation = {
|
|
|
77
66
|
setup?: Action[];
|
|
78
67
|
};
|
|
79
68
|
/** A result of the "send_transaction" operation (TxHash) */
|
|
80
|
-
export type SendTransactionResult =
|
|
69
|
+
export type SendTransactionResult = string;
|
|
81
70
|
/** A request to simulate the transaction */
|
|
82
71
|
export type SimulateTransactionOperation = {
|
|
83
72
|
/** Operation kind */
|
|
@@ -97,8 +86,8 @@ export type SimulateTransactionOperation = {
|
|
|
97
86
|
/** Whether to also simulate enqueued public calls or not */
|
|
98
87
|
simulatePublic?: boolean;
|
|
99
88
|
};
|
|
100
|
-
/**
|
|
101
|
-
export type
|
|
89
|
+
/** A result of the "simulate_transaction" operation */
|
|
90
|
+
export type SimulateTransactionResult = {
|
|
102
91
|
/** Gas usage info (GasUsed) */
|
|
103
92
|
gasUsed: unknown;
|
|
104
93
|
/** Private return values (NestedProcessReturnValues) */
|
|
@@ -106,12 +95,10 @@ export type SimulationReturn = {
|
|
|
106
95
|
/** Public return values (NestedProcessReturnValues[]) */
|
|
107
96
|
publicReturn: unknown[];
|
|
108
97
|
};
|
|
109
|
-
/** A
|
|
110
|
-
export type
|
|
111
|
-
/** A request to simulate the unconstrained function */
|
|
112
|
-
export type SimulateUnconstrainedOperation = {
|
|
98
|
+
/** A request to simulate the utility function */
|
|
99
|
+
export type SimulateUtilityOperation = {
|
|
113
100
|
/** Operation kind */
|
|
114
|
-
kind: "
|
|
101
|
+
kind: "simulate_utility";
|
|
115
102
|
/** Address of the account to simulate for */
|
|
116
103
|
account: CaipAccount;
|
|
117
104
|
/** Address of the contract (AztecAddress) */
|
|
@@ -121,8 +108,8 @@ export type SimulateUnconstrainedOperation = {
|
|
|
121
108
|
/** Arguments (unencoded) */
|
|
122
109
|
args: any[];
|
|
123
110
|
};
|
|
124
|
-
/** A result of the "
|
|
125
|
-
export type
|
|
111
|
+
/** A result of the "simulate_utility" operation (AbiDecoded) */
|
|
112
|
+
export type SimulateUtilityResult = unknown;
|
|
126
113
|
/** A request to simulate the batch of view calls */
|
|
127
114
|
export type SimulateViewsOperation = {
|
|
128
115
|
/** Operation kind */
|
|
@@ -132,12 +119,10 @@ export type SimulateViewsOperation = {
|
|
|
132
119
|
/** Batch of view calls to simulate */
|
|
133
120
|
calls: (CallAction | EncodedCallAction)[];
|
|
134
121
|
};
|
|
135
|
-
/**
|
|
136
|
-
export type
|
|
122
|
+
/** A result of the "simulate_views" operation */
|
|
123
|
+
export type SimulateViewsResult = {
|
|
137
124
|
/** List of results, encoded with function return types ABI (Fr[][]) */
|
|
138
125
|
encoded: string[][];
|
|
139
126
|
/** List of results, decoded with function return types ABI (AbiDecoded[]) */
|
|
140
127
|
decoded: unknown[];
|
|
141
128
|
};
|
|
142
|
-
/** A result of the "simulate_views" operation */
|
|
143
|
-
export type SimulateViewsResult = Result<ViewsSimulationResult>;
|
package/dist/result.d.ts
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
export type Result<T> = OkResult<T> | FailedResult | SkippedResult;
|
|
3
3
|
/** Successful result, containing returned value */
|
|
4
4
|
export type OkResult<T> = {
|
|
5
|
-
/** Result
|
|
6
|
-
|
|
5
|
+
/** Result status */
|
|
6
|
+
status: "ok";
|
|
7
7
|
/** Returned value */
|
|
8
8
|
result: T;
|
|
9
9
|
};
|
|
10
10
|
/** Failed result, containing error message */
|
|
11
11
|
export type FailedResult = {
|
|
12
|
-
/** Result
|
|
13
|
-
|
|
12
|
+
/** Result status */
|
|
13
|
+
status: "failed";
|
|
14
14
|
/** Returned error */
|
|
15
15
|
error: string;
|
|
16
16
|
};
|
|
@@ -19,6 +19,6 @@ export type FailedResult = {
|
|
|
19
19
|
* due to one of the previous operations in the same batch failed
|
|
20
20
|
* */
|
|
21
21
|
export type SkippedResult = {
|
|
22
|
-
/** Result
|
|
23
|
-
|
|
22
|
+
/** Result status */
|
|
23
|
+
status: "skipped";
|
|
24
24
|
};
|
package/package.json
CHANGED