@caatinga/client 0.2.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/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/freighter.cjs +42 -0
- package/dist/freighter.d.cts +6 -0
- package/dist/freighter.d.ts +6 -0
- package/dist/freighter.js +15 -0
- package/dist/index.cjs +339 -0
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +308 -0
- package/dist/types-Bmw_J1fg.d.cts +66 -0
- package/dist/types-Bmw_J1fg.d.ts +66 -0
- package/dist/types-CND6fcI5.d.cts +66 -0
- package/dist/types-CND6fcI5.d.ts +66 -0
- package/dist/types-CiM5FkDn.d.cts +66 -0
- package/dist/types-CiM5FkDn.d.ts +66 -0
- package/dist/types-DEys6TaK.d.cts +66 -0
- package/dist/types-DEys6TaK.d.ts +66 -0
- package/package.json +69 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// src/artifacts/resolve-contract-id.ts
|
|
2
|
+
import { CaatingaError, CaatingaErrorCode } from "@caatinga/core";
|
|
3
|
+
function resolveContractId(input) {
|
|
4
|
+
if (input.explicitContractId) {
|
|
5
|
+
return input.explicitContractId;
|
|
6
|
+
}
|
|
7
|
+
const contractId = input.artifacts.networks[input.network]?.contracts[input.contract]?.contractId;
|
|
8
|
+
if (contractId) {
|
|
9
|
+
return contractId;
|
|
10
|
+
}
|
|
11
|
+
throw new CaatingaError(
|
|
12
|
+
`No contract artifact found for "${input.contract}" on "${input.network}".`,
|
|
13
|
+
CaatingaErrorCode.CONTRACT_ARTIFACT_NOT_FOUND,
|
|
14
|
+
"Deploy the contract first or pass contractId explicitly."
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/bindings/default-binding-adapter.ts
|
|
19
|
+
import { CaatingaError as CaatingaError2, CaatingaErrorCode as CaatingaErrorCode2 } from "@caatinga/core";
|
|
20
|
+
function createDefaultBindingAdapter(binding) {
|
|
21
|
+
return {
|
|
22
|
+
createClient({ contractId, publicKey, rpcUrl, networkPassphrase }) {
|
|
23
|
+
if (!binding.Client) {
|
|
24
|
+
throw new CaatingaError2(
|
|
25
|
+
"Generated binding does not export Client.",
|
|
26
|
+
CaatingaErrorCode2.BINDING_CLIENT_NOT_FOUND,
|
|
27
|
+
"Regenerate bindings with Stellar CLI."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return new binding.Client({
|
|
31
|
+
contractId,
|
|
32
|
+
publicKey,
|
|
33
|
+
rpcUrl,
|
|
34
|
+
networkPassphrase
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async callMethod({ client, method, args }) {
|
|
38
|
+
const candidate = client;
|
|
39
|
+
const fn = candidate[method];
|
|
40
|
+
if (typeof fn !== "function") {
|
|
41
|
+
throw new CaatingaError2(
|
|
42
|
+
`Binding method "${method}" was not found.`,
|
|
43
|
+
CaatingaErrorCode2.BINDING_METHOD_NOT_FOUND,
|
|
44
|
+
"Check the contract method name or regenerate bindings."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return args ? fn.call(client, args) : fn.call(client);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/client/create-caatinga-client.ts
|
|
53
|
+
import { CaatingaError as CaatingaError5, CaatingaErrorCode as CaatingaErrorCode5 } from "@caatinga/core";
|
|
54
|
+
|
|
55
|
+
// src/client/caatinga-contract-client.ts
|
|
56
|
+
import { CaatingaError as CaatingaError4, CaatingaErrorCode as CaatingaErrorCode4 } from "@caatinga/core";
|
|
57
|
+
|
|
58
|
+
// src/xdr/build-xdr.ts
|
|
59
|
+
import { CaatingaError as CaatingaError3, CaatingaErrorCode as CaatingaErrorCode3 } from "@caatinga/core";
|
|
60
|
+
async function buildXdr(input) {
|
|
61
|
+
try {
|
|
62
|
+
const transaction = input.transaction;
|
|
63
|
+
const unsignedXdr = readXdr(transaction);
|
|
64
|
+
let preparedTransaction;
|
|
65
|
+
if (typeof transaction.prepare === "function") {
|
|
66
|
+
try {
|
|
67
|
+
preparedTransaction = await transaction.prepare();
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof CaatingaError3) {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
throw new CaatingaError3(
|
|
73
|
+
`Failed to prepare XDR for "${input.contractName}.${input.method}".`,
|
|
74
|
+
CaatingaErrorCode3.XDR_PREPARE_FAILED,
|
|
75
|
+
"Check RPC connectivity, simulation errors, and binding compatibility.",
|
|
76
|
+
error
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
preparedTransaction = transaction;
|
|
81
|
+
}
|
|
82
|
+
const preparedXdr = readXdr(preparedTransaction);
|
|
83
|
+
return {
|
|
84
|
+
contract: input.contractName,
|
|
85
|
+
method: input.method,
|
|
86
|
+
contractId: input.contractId,
|
|
87
|
+
unsignedXdr,
|
|
88
|
+
preparedXdr,
|
|
89
|
+
...input.debug ? { raw: preparedTransaction } : {}
|
|
90
|
+
};
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof CaatingaError3) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
throw new CaatingaError3(
|
|
96
|
+
`Failed to build XDR for "${input.contractName}.${input.method}".`,
|
|
97
|
+
CaatingaErrorCode3.XDR_BUILD_FAILED,
|
|
98
|
+
"Check the generated binding transaction object.",
|
|
99
|
+
error
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function readXdr(transaction) {
|
|
104
|
+
const candidate = transaction;
|
|
105
|
+
if (typeof candidate.toXDR !== "function") {
|
|
106
|
+
throw new CaatingaError3(
|
|
107
|
+
"Binding transaction object does not expose toXDR().",
|
|
108
|
+
CaatingaErrorCode3.XDR_BUILD_FAILED,
|
|
109
|
+
"Regenerate bindings or provide a compatible binding adapter."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return candidate.toXDR();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/client/caatinga-contract-client.ts
|
|
116
|
+
var CaatingaContractClient = class {
|
|
117
|
+
constructor(config, contractName, registration, bindingAdapter = createDefaultBindingAdapter(
|
|
118
|
+
registration.binding
|
|
119
|
+
)) {
|
|
120
|
+
this.config = config;
|
|
121
|
+
this.contractName = contractName;
|
|
122
|
+
this.registration = registration;
|
|
123
|
+
this.bindingAdapter = bindingAdapter;
|
|
124
|
+
}
|
|
125
|
+
config;
|
|
126
|
+
contractName;
|
|
127
|
+
registration;
|
|
128
|
+
bindingAdapter;
|
|
129
|
+
async buildXdr(method, argsOrOptions, maybeOptions) {
|
|
130
|
+
const { args, debugRaw } = splitArgsAndOptions(argsOrOptions, maybeOptions);
|
|
131
|
+
const { contractId, transaction } = await this.createTransaction(method, args);
|
|
132
|
+
return buildXdr({
|
|
133
|
+
contractName: this.contractName,
|
|
134
|
+
method,
|
|
135
|
+
contractId,
|
|
136
|
+
transaction,
|
|
137
|
+
debug: debugRaw
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async invoke(method, argsOrOptions, maybeOptions) {
|
|
141
|
+
const { args, debugXdr, debugRaw } = splitInvokeArgsAndOptions(argsOrOptions, maybeOptions);
|
|
142
|
+
const { contractId, transaction } = await this.createTransaction(method, args);
|
|
143
|
+
const xdr = await buildXdr({
|
|
144
|
+
contractName: this.contractName,
|
|
145
|
+
method,
|
|
146
|
+
contractId,
|
|
147
|
+
transaction,
|
|
148
|
+
debug: debugRaw
|
|
149
|
+
});
|
|
150
|
+
let signedXdr;
|
|
151
|
+
try {
|
|
152
|
+
signedXdr = await this.config.wallet.signTransaction({
|
|
153
|
+
xdr: xdr.preparedXdr,
|
|
154
|
+
networkPassphrase: this.config.network.networkPassphrase
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new CaatingaError4(
|
|
158
|
+
`Failed to sign XDR for "${this.contractName}.${method}".`,
|
|
159
|
+
CaatingaErrorCode4.XDR_SIGN_FAILED,
|
|
160
|
+
"Connect a wallet and approve the transaction.",
|
|
161
|
+
error
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
const raw = await submitTransaction(transaction, signedXdr, this.contractName, method);
|
|
165
|
+
const normalized = normalizeSubmitResult(raw);
|
|
166
|
+
return {
|
|
167
|
+
status: "confirmed",
|
|
168
|
+
contract: this.contractName,
|
|
169
|
+
method,
|
|
170
|
+
contractId,
|
|
171
|
+
...normalized.transactionHash ? { transactionHash: normalized.transactionHash } : {},
|
|
172
|
+
...normalized.result !== void 0 ? { result: normalized.result } : {},
|
|
173
|
+
...debugXdr ? {
|
|
174
|
+
xdr: {
|
|
175
|
+
unsigned: xdr.unsignedXdr,
|
|
176
|
+
prepared: xdr.preparedXdr,
|
|
177
|
+
signed: signedXdr
|
|
178
|
+
}
|
|
179
|
+
} : {},
|
|
180
|
+
...debugRaw ? { raw } : {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
async createTransaction(method, args) {
|
|
184
|
+
const contractId = resolveContractId({
|
|
185
|
+
artifacts: this.config.artifacts,
|
|
186
|
+
network: this.config.network.name,
|
|
187
|
+
contract: this.contractName,
|
|
188
|
+
explicitContractId: this.registration.contractId
|
|
189
|
+
});
|
|
190
|
+
let publicKey;
|
|
191
|
+
try {
|
|
192
|
+
publicKey = await this.config.wallet.getPublicKey();
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (error instanceof CaatingaError4) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
throw new CaatingaError4(
|
|
198
|
+
`Wallet is not connected or the public key is unavailable for "${this.contractName}".`,
|
|
199
|
+
CaatingaErrorCode4.WALLET_NOT_CONNECTED,
|
|
200
|
+
"Connect the wallet and grant account access, then retry.",
|
|
201
|
+
error
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
const client = this.bindingAdapter.createClient({
|
|
205
|
+
contractId,
|
|
206
|
+
publicKey,
|
|
207
|
+
rpcUrl: this.config.network.rpcUrl,
|
|
208
|
+
networkPassphrase: this.config.network.networkPassphrase
|
|
209
|
+
});
|
|
210
|
+
const transaction = await this.bindingAdapter.callMethod({ client, method, args });
|
|
211
|
+
return { contractId, transaction };
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
function splitArgsAndOptions(argsOrOptions, maybeOptions) {
|
|
215
|
+
return {
|
|
216
|
+
args: argsOrOptions,
|
|
217
|
+
debugRaw: maybeOptions?.debugRaw ?? false
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function splitInvokeArgsAndOptions(argsOrOptions, maybeOptions) {
|
|
221
|
+
const looksLikeOptions = argsOrOptions !== void 0 && ("debugXdr" in argsOrOptions || "debugRaw" in argsOrOptions) && maybeOptions === void 0;
|
|
222
|
+
if (looksLikeOptions) {
|
|
223
|
+
const options = argsOrOptions;
|
|
224
|
+
return {
|
|
225
|
+
args: void 0,
|
|
226
|
+
debugXdr: options.debugXdr ?? false,
|
|
227
|
+
debugRaw: options.debugRaw ?? false
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
args: argsOrOptions,
|
|
232
|
+
debugXdr: maybeOptions?.debugXdr ?? false,
|
|
233
|
+
debugRaw: maybeOptions?.debugRaw ?? false
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
async function submitTransaction(transaction, signedXdr, contractName, method) {
|
|
237
|
+
const candidate = transaction;
|
|
238
|
+
const submit = candidate.signAndSend ?? candidate.send;
|
|
239
|
+
if (typeof submit !== "function") {
|
|
240
|
+
throw new CaatingaError4(
|
|
241
|
+
`Binding transaction for "${contractName}.${method}" cannot be submitted.`,
|
|
242
|
+
CaatingaErrorCode4.XDR_SUBMIT_FAILED,
|
|
243
|
+
"Regenerate bindings or provide a compatible binding adapter."
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const raw = await submit.call(transaction, { signedXdr });
|
|
248
|
+
assertSubmitResultRecognized(raw, contractName, method);
|
|
249
|
+
return raw;
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (error instanceof CaatingaError4) {
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
throw new CaatingaError4(
|
|
255
|
+
`Failed to submit XDR for "${contractName}.${method}".`,
|
|
256
|
+
CaatingaErrorCode4.XDR_SUBMIT_FAILED,
|
|
257
|
+
"Check wallet signature and RPC connectivity.",
|
|
258
|
+
error
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function assertSubmitResultRecognized(raw, contractName, method) {
|
|
263
|
+
if (raw === null || typeof raw !== "object") {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const record = raw;
|
|
267
|
+
const hasTransactionId = "txHash" in record || "transactionHash" in record || "hash" in record;
|
|
268
|
+
const hasResult = "result" in record;
|
|
269
|
+
if (hasTransactionId || hasResult) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
throw new CaatingaError4(
|
|
273
|
+
`Submit returned an unrecognized payload for "${contractName}.${method}".`,
|
|
274
|
+
CaatingaErrorCode4.XDR_RESULT_FAILED,
|
|
275
|
+
"Expected txHash, transactionHash, hash, or result on the submit response. Use debugRaw to inspect the binding output."
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
function normalizeSubmitResult(raw) {
|
|
279
|
+
const candidate = raw;
|
|
280
|
+
return {
|
|
281
|
+
transactionHash: candidate.txHash ?? candidate.transactionHash ?? candidate.hash,
|
|
282
|
+
result: candidate.result
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/client/create-caatinga-client.ts
|
|
287
|
+
function createCaatingaClient(config) {
|
|
288
|
+
return {
|
|
289
|
+
contract(contractName) {
|
|
290
|
+
const registration = config.contracts[contractName];
|
|
291
|
+
if (!registration) {
|
|
292
|
+
throw new CaatingaError5(
|
|
293
|
+
`Contract "${contractName}" is not registered.`,
|
|
294
|
+
CaatingaErrorCode5.CONTRACT_NOT_FOUND,
|
|
295
|
+
"Add the contract binding to createCaatingaClient()."
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return new CaatingaContractClient(config, contractName, registration);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
export {
|
|
303
|
+
CaatingaContractClient,
|
|
304
|
+
buildXdr,
|
|
305
|
+
createCaatingaClient,
|
|
306
|
+
createDefaultBindingAdapter,
|
|
307
|
+
resolveContractId
|
|
308
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KaleidoArtifacts } from '@kaleido/core';
|
|
2
|
+
|
|
3
|
+
interface KaleidoNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface KaleidoWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface KaleidoContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface KaleidoClientConfig {
|
|
20
|
+
network: KaleidoNetwork;
|
|
21
|
+
artifacts: KaleidoArtifacts;
|
|
22
|
+
wallet: KaleidoWalletAdapter;
|
|
23
|
+
contracts: Record<string, KaleidoContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type KaleidoInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface KaleidoInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface KaleidoInvokeResult<T = unknown> {
|
|
31
|
+
status: KaleidoInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface KaleidoXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface KaleidoBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { KaleidoWalletAdapter as K, KaleidoBindingAdapter as a, KaleidoClientConfig as b, KaleidoContractRegistration as c, KaleidoXdrBuildResult as d, KaleidoInvokeOptions as e, KaleidoInvokeResult as f, KaleidoInvokeStatus as g, KaleidoNetwork as h };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KaleidoArtifacts } from '@kaleido/core';
|
|
2
|
+
|
|
3
|
+
interface KaleidoNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface KaleidoWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface KaleidoContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface KaleidoClientConfig {
|
|
20
|
+
network: KaleidoNetwork;
|
|
21
|
+
artifacts: KaleidoArtifacts;
|
|
22
|
+
wallet: KaleidoWalletAdapter;
|
|
23
|
+
contracts: Record<string, KaleidoContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type KaleidoInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface KaleidoInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface KaleidoInvokeResult<T = unknown> {
|
|
31
|
+
status: KaleidoInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface KaleidoXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface KaleidoBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { KaleidoWalletAdapter as K, KaleidoBindingAdapter as a, KaleidoClientConfig as b, KaleidoContractRegistration as c, KaleidoXdrBuildResult as d, KaleidoInvokeOptions as e, KaleidoInvokeResult as f, KaleidoInvokeStatus as g, KaleidoNetwork as h };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KaleidoArtifacts } from '@kaleido-xlm/core';
|
|
2
|
+
|
|
3
|
+
interface KaleidoNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface KaleidoWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface KaleidoContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface KaleidoClientConfig {
|
|
20
|
+
network: KaleidoNetwork;
|
|
21
|
+
artifacts: KaleidoArtifacts;
|
|
22
|
+
wallet: KaleidoWalletAdapter;
|
|
23
|
+
contracts: Record<string, KaleidoContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type KaleidoInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface KaleidoInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface KaleidoInvokeResult<T = unknown> {
|
|
31
|
+
status: KaleidoInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface KaleidoXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface KaleidoBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { KaleidoWalletAdapter as K, KaleidoBindingAdapter as a, KaleidoClientConfig as b, KaleidoContractRegistration as c, KaleidoXdrBuildResult as d, KaleidoInvokeOptions as e, KaleidoInvokeResult as f, KaleidoInvokeStatus as g, KaleidoNetwork as h };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KaleidoArtifacts } from '@kaleido-xlm/core';
|
|
2
|
+
|
|
3
|
+
interface KaleidoNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface KaleidoWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface KaleidoContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface KaleidoClientConfig {
|
|
20
|
+
network: KaleidoNetwork;
|
|
21
|
+
artifacts: KaleidoArtifacts;
|
|
22
|
+
wallet: KaleidoWalletAdapter;
|
|
23
|
+
contracts: Record<string, KaleidoContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type KaleidoInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface KaleidoInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface KaleidoInvokeResult<T = unknown> {
|
|
31
|
+
status: KaleidoInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface KaleidoXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface KaleidoBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { KaleidoWalletAdapter as K, KaleidoBindingAdapter as a, KaleidoClientConfig as b, KaleidoContractRegistration as c, KaleidoXdrBuildResult as d, KaleidoInvokeOptions as e, KaleidoInvokeResult as f, KaleidoInvokeStatus as g, KaleidoNetwork as h };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CaatingaArtifacts } from '@caatinga/core';
|
|
2
|
+
|
|
3
|
+
interface CaatingaNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface CaatingaWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface CaatingaContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CaatingaClientConfig {
|
|
20
|
+
network: CaatingaNetwork;
|
|
21
|
+
artifacts: CaatingaArtifacts;
|
|
22
|
+
wallet: CaatingaWalletAdapter;
|
|
23
|
+
contracts: Record<string, CaatingaContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type CaatingaInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface CaatingaInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface CaatingaInvokeResult<T = unknown> {
|
|
31
|
+
status: CaatingaInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface CaatingaXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface CaatingaBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { CaatingaWalletAdapter as C, CaatingaBindingAdapter as a, CaatingaClientConfig as b, CaatingaContractRegistration as c, CaatingaXdrBuildResult as d, CaatingaInvokeOptions as e, CaatingaInvokeResult as f, CaatingaInvokeStatus as g, CaatingaNetwork as h };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CaatingaArtifacts } from '@caatinga/core';
|
|
2
|
+
|
|
3
|
+
interface CaatingaNetwork {
|
|
4
|
+
name: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
networkPassphrase: string;
|
|
7
|
+
}
|
|
8
|
+
interface CaatingaWalletAdapter {
|
|
9
|
+
getPublicKey(): Promise<string>;
|
|
10
|
+
signTransaction(input: {
|
|
11
|
+
xdr: string;
|
|
12
|
+
networkPassphrase: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
interface CaatingaContractRegistration {
|
|
16
|
+
binding: unknown;
|
|
17
|
+
contractId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CaatingaClientConfig {
|
|
20
|
+
network: CaatingaNetwork;
|
|
21
|
+
artifacts: CaatingaArtifacts;
|
|
22
|
+
wallet: CaatingaWalletAdapter;
|
|
23
|
+
contracts: Record<string, CaatingaContractRegistration>;
|
|
24
|
+
}
|
|
25
|
+
type CaatingaInvokeStatus = "built" | "prepared" | "signed" | "submitted" | "confirmed" | "failed";
|
|
26
|
+
interface CaatingaInvokeOptions {
|
|
27
|
+
debugXdr?: boolean;
|
|
28
|
+
debugRaw?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface CaatingaInvokeResult<T = unknown> {
|
|
31
|
+
status: CaatingaInvokeStatus;
|
|
32
|
+
contract: string;
|
|
33
|
+
method: string;
|
|
34
|
+
contractId: string;
|
|
35
|
+
transactionHash?: string;
|
|
36
|
+
result?: T;
|
|
37
|
+
xdr?: {
|
|
38
|
+
unsigned?: string;
|
|
39
|
+
prepared?: string;
|
|
40
|
+
signed?: string;
|
|
41
|
+
};
|
|
42
|
+
raw?: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface CaatingaXdrBuildResult {
|
|
45
|
+
contract: string;
|
|
46
|
+
method: string;
|
|
47
|
+
contractId: string;
|
|
48
|
+
unsignedXdr?: string;
|
|
49
|
+
preparedXdr: string;
|
|
50
|
+
raw?: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface CaatingaBindingAdapter {
|
|
53
|
+
createClient(input: {
|
|
54
|
+
contractId: string;
|
|
55
|
+
publicKey: string;
|
|
56
|
+
rpcUrl: string;
|
|
57
|
+
networkPassphrase: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
callMethod(input: {
|
|
60
|
+
client: unknown;
|
|
61
|
+
method: string;
|
|
62
|
+
args?: Record<string, unknown>;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type { CaatingaWalletAdapter as C, CaatingaBindingAdapter as a, CaatingaClientConfig as b, CaatingaContractRegistration as c, CaatingaXdrBuildResult as d, CaatingaInvokeOptions as e, CaatingaInvokeResult as f, CaatingaInvokeStatus as g, CaatingaNetwork as h };
|