@dynamic-labs/aleo 4.79.1 → 4.80.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/CHANGELOG.md +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -6
- package/src/connectors/DynamicWaasAleoConnector/DynamicWaasAleoConnector.cjs +798 -0
- package/src/connectors/DynamicWaasAleoConnector/DynamicWaasAleoConnector.d.ts +409 -0
- package/src/connectors/DynamicWaasAleoConnector/DynamicWaasAleoConnector.js +794 -0
- package/src/connectors/DynamicWaasAleoConnector/index.cjs +13 -0
- package/src/connectors/DynamicWaasAleoConnector/index.d.ts +3 -0
- package/src/connectors/DynamicWaasAleoConnector/index.js +9 -0
- package/src/connectors/WaasAleoWalletConnector/WaasAleoWalletConnector.cjs +216 -0
- package/src/connectors/WaasAleoWalletConnector/WaasAleoWalletConnector.d.ts +116 -0
- package/src/connectors/WaasAleoWalletConnector/WaasAleoWalletConnector.js +211 -0
- package/src/connectors/WaasAleoWalletConnector/index.d.ts +1 -0
- package/src/index.cjs +15 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +7 -0
- package/src/utils/AleoUiTransaction/AleoUiTransaction.cjs +354 -0
- package/src/utils/AleoUiTransaction/AleoUiTransaction.d.ts +130 -0
- package/src/utils/AleoUiTransaction/AleoUiTransaction.js +350 -0
- package/src/utils/AleoUiTransaction/index.d.ts +2 -0
- package/src/utils/aleoSendableTokens/aleoSendableTokens.cjs +185 -0
- package/src/utils/aleoSendableTokens/aleoSendableTokens.d.ts +78 -0
- package/src/utils/aleoSendableTokens/aleoSendableTokens.js +175 -0
- package/src/utils/aleoSendableTokens/index.d.ts +2 -0
- package/src/utils/aleoShieldableTokens/aleoShieldableTokens.cjs +119 -0
- package/src/utils/aleoShieldableTokens/aleoShieldableTokens.d.ts +45 -0
- package/src/utils/aleoShieldableTokens/aleoShieldableTokens.js +114 -0
- package/src/utils/aleoShieldableTokens/index.d.ts +2 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import type { LogoutReason } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import { JwtVerifiedCredential, SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
|
+
import { IDynamicWaasConnector, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { Logger } from '@dynamic-labs/logger';
|
|
6
|
+
import { WaasAleoWalletConnector, type WaasAleoWalletConnectorProps } from '../WaasAleoWalletConnector';
|
|
7
|
+
import { AleoWallet } from '../../wallet/AleoWallet';
|
|
8
|
+
import { AleoOwnedRecord } from '../../utils/aleoSendableTokens';
|
|
9
|
+
export type DynamicWaasAleoConnectorProps = WaasAleoWalletConnectorProps & {
|
|
10
|
+
walletUiUtils: WalletUiUtils<InternalWalletConnector>;
|
|
11
|
+
};
|
|
12
|
+
type JoinProgramResult = {
|
|
13
|
+
programId: string;
|
|
14
|
+
rounds: number;
|
|
15
|
+
finalRecordPlaintext?: string;
|
|
16
|
+
skipped?: 'insufficient_records' | 'unsupported';
|
|
17
|
+
error?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const DynamicWaasAleoConnector_base: (abstract new (...args: any[]) => {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
name: string;
|
|
22
|
+
overrideKey: string;
|
|
23
|
+
isEmbeddedWallet: boolean;
|
|
24
|
+
getSignedSessionId?: (() => Promise<string>) | undefined;
|
|
25
|
+
getMfaToken?: ((props?: {
|
|
26
|
+
mfaAction?: import("@dynamic-labs/sdk-api-core").MFAAction | undefined;
|
|
27
|
+
} | undefined) => Promise<string | undefined>) | undefined;
|
|
28
|
+
getWalletPassword?: import("@dynamic-labs/wallet-connector-core").GetWalletPasswordFn | undefined;
|
|
29
|
+
getAuthToken?: (() => string) | undefined;
|
|
30
|
+
getElevatedAccessToken?: ((props: {
|
|
31
|
+
scope: import("@dynamic-labs/sdk-api-core").TokenScope;
|
|
32
|
+
}) => Promise<string | undefined>) | undefined;
|
|
33
|
+
environmentId?: string | undefined;
|
|
34
|
+
baseApiUrl?: string | undefined;
|
|
35
|
+
relayUrl?: string | undefined;
|
|
36
|
+
baseClientKeysharesRelayApiUrl?: string | undefined;
|
|
37
|
+
dynamicWaasClient: import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient | undefined;
|
|
38
|
+
chainName: string;
|
|
39
|
+
authMode: "cookie" | "header";
|
|
40
|
+
logger: Logger;
|
|
41
|
+
__exportHandler: import("@dynamic-labs/waas").WaasExportHandler;
|
|
42
|
+
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
43
|
+
setGetAuthTokenFunction(getAuthToken: () => string): void;
|
|
44
|
+
setWaasAuthMode(authMode: "cookie" | "header"): void;
|
|
45
|
+
setGetMfaTokenFunction(getMfaToken: (props?: {
|
|
46
|
+
mfaAction?: import("@dynamic-labs/sdk-api-core").MFAAction | undefined;
|
|
47
|
+
} | undefined) => Promise<string | undefined>): void;
|
|
48
|
+
setGetElevatedAccessTokenFunction(getElevatedAccessToken: (params: {
|
|
49
|
+
scope: import("@dynamic-labs/sdk-api-core").TokenScope;
|
|
50
|
+
}) => Promise<string | undefined>): void;
|
|
51
|
+
setGetWalletPasswordFunction(getWalletPassword: import("@dynamic-labs/wallet-connector-core").GetWalletPasswordFn): void;
|
|
52
|
+
getPasswordIfNeeded({ accountAddress, }: {
|
|
53
|
+
accountAddress: string;
|
|
54
|
+
}): Promise<string | undefined>;
|
|
55
|
+
getPassword({ accountAddress, }: {
|
|
56
|
+
accountAddress: string;
|
|
57
|
+
}): Promise<string | undefined>;
|
|
58
|
+
setEnvironmentId(environmentId: string): void;
|
|
59
|
+
setBaseApiUrl(baseApiUrl: string): void;
|
|
60
|
+
setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl?: string | undefined): void;
|
|
61
|
+
setRelayUrl(relayUrl: string): void;
|
|
62
|
+
setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
|
|
63
|
+
delegateKeyShares({ accountAddress, password, }: {
|
|
64
|
+
accountAddress: string;
|
|
65
|
+
password?: string | undefined;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
createDynamicWaasClient(traceContext?: import("dist/packages/waas/utils/instrumentation").TraceContext | undefined): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
68
|
+
getWaasWalletClient(traceContext?: import("dist/packages/waas/utils/instrumentation").TraceContext | undefined): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
69
|
+
createWalletAccount({ thresholdSignatureScheme, password, bitcoinConfig, }?: {
|
|
70
|
+
thresholdSignatureScheme?: string | undefined;
|
|
71
|
+
password?: string | undefined;
|
|
72
|
+
bitcoinConfig?: import("@dynamic-labs-wallet/core").BitcoinConfig | undefined;
|
|
73
|
+
} | undefined): Promise<{
|
|
74
|
+
chainName: string;
|
|
75
|
+
accountAddress: string;
|
|
76
|
+
publicKeyHex: string;
|
|
77
|
+
rawPublicKey: string | Uint8Array | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, }: {
|
|
80
|
+
privateKey: string;
|
|
81
|
+
thresholdSignatureScheme?: string | undefined;
|
|
82
|
+
publicAddressCheck?: string | undefined;
|
|
83
|
+
addressType?: string | undefined;
|
|
84
|
+
legacyWalletId?: string | undefined;
|
|
85
|
+
password?: string | undefined;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
88
|
+
accountAddress?: string | undefined;
|
|
89
|
+
displayContainer?: HTMLIFrameElement | undefined;
|
|
90
|
+
password?: string | undefined;
|
|
91
|
+
} | undefined): Promise<void>;
|
|
92
|
+
getExportHandler(): {
|
|
93
|
+
clear: () => void;
|
|
94
|
+
};
|
|
95
|
+
exportClientKeyshares({ accountAddress, password, }: {
|
|
96
|
+
accountAddress: string;
|
|
97
|
+
password?: string | undefined;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, }: {
|
|
100
|
+
accountAddress: string;
|
|
101
|
+
password?: string | undefined;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
exportClientKeysharesFromGoogleDrive({ accountAddress, password, }: {
|
|
104
|
+
accountAddress: string;
|
|
105
|
+
password?: string | undefined;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
backupKeySharesToICloud({ accountAddress, password, }: {
|
|
108
|
+
accountAddress: string;
|
|
109
|
+
password?: string | undefined;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
displayICloudSignIn({ displayContainer, }: {
|
|
112
|
+
displayContainer: HTMLElement;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
hideICloudSignIn(): Promise<void>;
|
|
115
|
+
isICloudAuthenticated(): Promise<boolean>;
|
|
116
|
+
refreshWalletAccountShares({ accountAddress, password, }: {
|
|
117
|
+
accountAddress: string;
|
|
118
|
+
password?: string | undefined;
|
|
119
|
+
}): Promise<void>;
|
|
120
|
+
reshareWalletAccountShares({ accountAddress, thresholdSignatureScheme, password, }: {
|
|
121
|
+
accountAddress: string;
|
|
122
|
+
thresholdSignatureScheme: string;
|
|
123
|
+
password?: string | undefined;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
revokeDelegation({ accountAddress, password, }: {
|
|
126
|
+
accountAddress: string;
|
|
127
|
+
password?: string | undefined;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
130
|
+
accountAddress: string;
|
|
131
|
+
existingPassword?: string | undefined;
|
|
132
|
+
newPassword: string;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
setPassword({ accountAddress, newPassword, }: {
|
|
135
|
+
accountAddress: string;
|
|
136
|
+
newPassword: string;
|
|
137
|
+
}): Promise<void>;
|
|
138
|
+
signRawMessage({ accountAddress, message, password, }: {
|
|
139
|
+
accountAddress: string;
|
|
140
|
+
message: string;
|
|
141
|
+
password?: string | undefined;
|
|
142
|
+
}): Promise<string>;
|
|
143
|
+
unlockWallet({ accountAddress, password, }: {
|
|
144
|
+
accountAddress: string;
|
|
145
|
+
password?: string | undefined;
|
|
146
|
+
}): Promise<import("@dynamic-labs-wallet/core").GetWalletResponse>;
|
|
147
|
+
getWalletRecoveryState({ accountAddress, }: {
|
|
148
|
+
accountAddress: string;
|
|
149
|
+
}): Promise<import("@dynamic-labs-wallet/core").WalletRecoveryState>;
|
|
150
|
+
endSession(reason?: LogoutReason | undefined): Promise<void>;
|
|
151
|
+
getActiveAccountAddress(): Promise<string | undefined>;
|
|
152
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
153
|
+
generateTraceId(): string;
|
|
154
|
+
instrument(message: string, context: import("@dynamic-labs/logger").InstrumentOptions & import("dist/packages/waas/utils/instrumentation").InstrumentContext & Record<string, any>): void;
|
|
155
|
+
instrumentAsync<T_1>({ operation, resource, fn, context, }: {
|
|
156
|
+
operation: string;
|
|
157
|
+
resource: string;
|
|
158
|
+
fn: (timing: import("dist/packages/waas/utils/instrumentation").InstrumentationTimer) => Promise<T_1>;
|
|
159
|
+
context?: Record<string, any> | undefined;
|
|
160
|
+
}): Promise<T_1>;
|
|
161
|
+
}) & typeof WaasAleoWalletConnector;
|
|
162
|
+
/**
|
|
163
|
+
* Dynamic WaaS connector for Aleo.
|
|
164
|
+
* Phase 1: supports wallet creation (MPC keygen → aleo1... address) and
|
|
165
|
+
* retrieval of the active WaaS wallet. signMessage and signTransaction
|
|
166
|
+
* throw NotSupported until Sodot adds `EdBls12377.sign(bytes)` and we wire up
|
|
167
|
+
* the Aleo `signRequest` ceremony.
|
|
168
|
+
*/
|
|
169
|
+
export declare class DynamicWaasAleoConnector extends DynamicWaasAleoConnector_base implements IDynamicWaasConnector {
|
|
170
|
+
ChainWallet: typeof AleoWallet;
|
|
171
|
+
name: string;
|
|
172
|
+
overrideKey: string;
|
|
173
|
+
isEmbeddedWallet: boolean;
|
|
174
|
+
logger: Logger;
|
|
175
|
+
activeAccountAddress: string | undefined;
|
|
176
|
+
verifiedCredentials: JwtVerifiedCredential[] | undefined;
|
|
177
|
+
protected walletUiUtils: WalletUiUtils<InternalWalletConnector>;
|
|
178
|
+
constructor(props: DynamicWaasAleoConnectorProps);
|
|
179
|
+
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
180
|
+
getWalletClientByAddress({ accountAddress, }: {
|
|
181
|
+
accountAddress: string;
|
|
182
|
+
}): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
183
|
+
getActiveAccountAddress(): Promise<string | undefined>;
|
|
184
|
+
private setActiveAccountAddress;
|
|
185
|
+
afterWalletSelectHook(walletAddress: string): void;
|
|
186
|
+
private requireSignedSessionId;
|
|
187
|
+
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
188
|
+
private ensureActiveAccountFromVerifiedCredentials;
|
|
189
|
+
getAddress(): Promise<string>;
|
|
190
|
+
connect(): Promise<void>;
|
|
191
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
192
|
+
signMessage(message: string): Promise<string>;
|
|
193
|
+
signMessageWithContext({ message, context, }: {
|
|
194
|
+
message: string | {
|
|
195
|
+
raw: string;
|
|
196
|
+
};
|
|
197
|
+
context: SignMessageContext;
|
|
198
|
+
}): Promise<string>;
|
|
199
|
+
signTransaction(_transaction: unknown): Promise<string>;
|
|
200
|
+
/**
|
|
201
|
+
* Aleo full transaction flow: view key → MPC sign → prove + broadcast via DPS.
|
|
202
|
+
* Delegates to the iframe's DynamicAleoWalletClient.proveTransaction.
|
|
203
|
+
*/
|
|
204
|
+
proveTransaction(params: {
|
|
205
|
+
programId: string;
|
|
206
|
+
functionName: string;
|
|
207
|
+
inputs: string[];
|
|
208
|
+
inputTypes: string[];
|
|
209
|
+
broadcast?: boolean;
|
|
210
|
+
}): Promise<{
|
|
211
|
+
txId?: string;
|
|
212
|
+
provingResponse?: unknown;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* List this wallet's Aleo records across all programs (credits + custom
|
|
216
|
+
* tokens). Delegates into the iframe's DynamicAleoWalletClient.
|
|
217
|
+
* findOwnedRecords, which uses Provable's hosted RecordScanner. View key
|
|
218
|
+
* never leaves the iframe.
|
|
219
|
+
*
|
|
220
|
+
* Each returned record carries `program_name` + `record_name` so callers
|
|
221
|
+
* can group/display by token. Credits records additionally get a parsed
|
|
222
|
+
* `microcredits` field. Other tokens are returned raw — caller parses the
|
|
223
|
+
* plaintext per program schema.
|
|
224
|
+
*
|
|
225
|
+
* First call per wallet registers the view key with Provable (one-time,
|
|
226
|
+
* cached UUID in iframe IndexedDB). Subsequent calls reuse the UUID.
|
|
227
|
+
*/
|
|
228
|
+
listOwnedRecords(): Promise<{
|
|
229
|
+
records: unknown[];
|
|
230
|
+
}>;
|
|
231
|
+
/**
|
|
232
|
+
* Merge the wallet's owned records down — one final record per Aleo
|
|
233
|
+
* program — by recursively running `<program>/join` two-at-a-time.
|
|
234
|
+
* Mirrors the basic pairwise strategy from Provable's `example-autojoin`:
|
|
235
|
+
* at each round we pair records, run joins concurrently, wait for the
|
|
236
|
+
* outputs to surface from Provable's RecordScanner, and recurse until one
|
|
237
|
+
* record remains for that program. Odd-one-out is carried forward.
|
|
238
|
+
*
|
|
239
|
+
* Cross-program records can't combine on-chain (a `credits.aleo/credits`
|
|
240
|
+
* record and a `test_usad_stablecoin.aleo/Token` record have different
|
|
241
|
+
* record types), so the result is always one record per program.
|
|
242
|
+
*
|
|
243
|
+
* Fees are sponsored by ANF's Feemaster when its policy covers the
|
|
244
|
+
* `(programId, 'join')` pair (today: `credits.aleo`). Programs not in
|
|
245
|
+
* the policy fall through to the user-paid path inside `proveTransaction`.
|
|
246
|
+
*
|
|
247
|
+
* Today: only `credits.aleo` is allowed end-to-end. Stablecoin / ARC-21
|
|
248
|
+
* joins are blocked on snarkVM's `Stack::authorize_request` credits-only
|
|
249
|
+
* check — Provable is tracking the relaxation. Until then non-credits
|
|
250
|
+
* programs are reported as `skipped: 'unsupported'` rather than thrown,
|
|
251
|
+
* so callers can iterate the result and surface what merged vs. what
|
|
252
|
+
* didn't without try/catch noise.
|
|
253
|
+
*
|
|
254
|
+
* @param opts.programIds Programs to merge. Omit (default) to merge
|
|
255
|
+
* every owned program with ≥2 records. Programs with <2 records are
|
|
256
|
+
* reported as `skipped: 'insufficient_records'`.
|
|
257
|
+
* @param opts.filterRecord Optional per-record predicate that narrows
|
|
258
|
+
* the candidate set BEFORE pairing. Used by ARC-21 where one program
|
|
259
|
+
* (`token_registry.aleo`) hosts many tokens — the on-chain `join`
|
|
260
|
+
* refuses to combine records with different `token_id` fields, so we
|
|
261
|
+
* filter by token_id first and never broadcast a doomed merge.
|
|
262
|
+
*/
|
|
263
|
+
joinRecords(opts?: {
|
|
264
|
+
programIds?: string[];
|
|
265
|
+
filterRecord?: (record: AleoOwnedRecord) => boolean;
|
|
266
|
+
}): Promise<{
|
|
267
|
+
results: JoinProgramResult[];
|
|
268
|
+
}>;
|
|
269
|
+
/**
|
|
270
|
+
* Pre-fork: only `credits.aleo` made it past `Stack::authorize_request`.
|
|
271
|
+
* Post-fork (Roy's snarkVM @32ad6c4 + the file:-overrides in
|
|
272
|
+
* dynamic-waas-sdk's pnpm workspace), stablecoin joins authorize too.
|
|
273
|
+
* Programs that *aren't* credits and aren't a known stablecoin still
|
|
274
|
+
* 404 on shape — we'd hit `record name doesn't match` or similar
|
|
275
|
+
* mid-MPC, which is wasteful, so we keep an allowlist.
|
|
276
|
+
*/
|
|
277
|
+
private processProgramJoin;
|
|
278
|
+
/**
|
|
279
|
+
* Reads the wallet's owned records, applies the optional caller predicate,
|
|
280
|
+
* and groups by program. The `filterRecord` predicate runs first so callers
|
|
281
|
+
* can scope the merge to a sub-set within a program (ARC-21 token_id filter).
|
|
282
|
+
*/
|
|
283
|
+
private fetchAndGroupOwnedRecords;
|
|
284
|
+
/**
|
|
285
|
+
* Pairwise-merges `records` (all from `programId`) until one remains.
|
|
286
|
+
* Each round runs every pair's join concurrently, then polls the
|
|
287
|
+
* RecordScanner until the round's output records have surfaced.
|
|
288
|
+
* Caller validates the list shape and ≥2 length.
|
|
289
|
+
*
|
|
290
|
+
* We track every plaintext we've consumed across the entire call in
|
|
291
|
+
* `consumedAcrossCall` and exclude them from each poll result. Provable's
|
|
292
|
+
* RecordScanner indexes a transaction's new outputs and its spent inputs
|
|
293
|
+
* separately — outputs typically surface 5–15 s after broadcast, but the
|
|
294
|
+
* spend index for the consumed inputs can lag much longer (we've seen
|
|
295
|
+
* 30 s+). Without local consumed-tracking, polling either (a) waits for
|
|
296
|
+
* the laggy spend index, slowing every round to its slowest piece, or
|
|
297
|
+
* (b) lets a stale consumed record leak into the next round's polling
|
|
298
|
+
* and mis-count it as a fresh output.
|
|
299
|
+
*
|
|
300
|
+
* Per-program shape (record name + input types) comes from
|
|
301
|
+
* `joinShapeForProgram(programId)`. Today that supports `credits.aleo`
|
|
302
|
+
* and the four Sealance-compliant stablecoin program ids; extending
|
|
303
|
+
* to ARC-21 / token_registry would be another entry there.
|
|
304
|
+
*/
|
|
305
|
+
private joinProgramRecords;
|
|
306
|
+
/**
|
|
307
|
+
* Polls `listOwnedRecords` until `expectedNewCount` previously-unseen
|
|
308
|
+
* records of the right program/record-name have surfaced. We do NOT
|
|
309
|
+
* wait for the scanner to mark consumed inputs as spent — that index
|
|
310
|
+
* is independently delayed, and waiting on it stalls rounds whose
|
|
311
|
+
* outputs are already visible. `consumedAcrossCall` is the local-spent
|
|
312
|
+
* set tracked in `joinProgramRecords`; we filter against it explicitly.
|
|
313
|
+
*/
|
|
314
|
+
private waitForJoinRoundOutputs;
|
|
315
|
+
/**
|
|
316
|
+
* Returns the IUITransaction the widget's Send flow drives. Implementing
|
|
317
|
+
* this method is the *only* signal the widget needs to render the "Send"
|
|
318
|
+
* button next to "Deposit" — `isSendBalanceWalletConnector` is duck-typed
|
|
319
|
+
* on the presence of `createUiTransaction`.
|
|
320
|
+
*
|
|
321
|
+
* The widget's send view picks one token from the per-network registry
|
|
322
|
+
* (credits + USAD/USDCx always; mainnet additionally exposes 5 ARC-21
|
|
323
|
+
* hyp_warp tokens). At submit time the picked token's `programKind`
|
|
324
|
+
* drives the transition signature:
|
|
325
|
+
*
|
|
326
|
+
* - `credits` → `credits.aleo/transfer_private(_to_public)`,
|
|
327
|
+
* inputs `[record, recipient, amount]` (u64).
|
|
328
|
+
* - `stablecoin` → `<token>.aleo/transfer_private(_to_public)`,
|
|
329
|
+
* inputs `[recipient, amount, record]` (u128). The
|
|
330
|
+
* iframe appends a Sealance freeze-list exclusion
|
|
331
|
+
* proof + its `[MerkleProof; 2u32].private` type
|
|
332
|
+
* automatically.
|
|
333
|
+
* - `arc21` → `token_registry.aleo/transfer_private(_to_public)`,
|
|
334
|
+
* inputs `[recipient, amount, record]` (u128). The
|
|
335
|
+
* token_id is encoded inside the record plaintext;
|
|
336
|
+
* the transition signature does NOT take it as an
|
|
337
|
+
* explicit argument.
|
|
338
|
+
*
|
|
339
|
+
* Submission path: AleoUiTransaction.submit → onSubmit closure below →
|
|
340
|
+
* this.proveTransaction → iframe (Sodot MPC sign + optional Sealance
|
|
341
|
+
* proof injection) → Feemaster (when policy covers it) → Provable DPS
|
|
342
|
+
* (proves + broadcasts) → returns txId.
|
|
343
|
+
*/
|
|
344
|
+
createUiTransaction(from: string): Promise<IUITransaction>;
|
|
345
|
+
/**
|
|
346
|
+
* True when the given token is registered as shieldable on the
|
|
347
|
+
* currently-selected Aleo network. The widget's Unshielded tab uses this
|
|
348
|
+
* to gate the "Shield Manually" CTA — unregistered tokens (e.g. random
|
|
349
|
+
* third-party Aleo programs surfaced by the redcoast public-balance feed)
|
|
350
|
+
* don't get a CTA they couldn't successfully act on.
|
|
351
|
+
*
|
|
352
|
+
* Native ALEO doesn't have a contract address in redcoast's public-balance
|
|
353
|
+
* feed (it surfaces as `isNative: true` with a sentinel like `'0x0'`),
|
|
354
|
+
* so we recognise it via `isNative` and fall back to the registry's
|
|
355
|
+
* `credits.aleo` entry when the literal address misses.
|
|
356
|
+
*/
|
|
357
|
+
canShieldToken(token: {
|
|
358
|
+
address?: string;
|
|
359
|
+
isNative?: boolean;
|
|
360
|
+
}): boolean;
|
|
361
|
+
/**
|
|
362
|
+
* True when the Feemaster currently sponsors a shield (
|
|
363
|
+
* `transfer_public_to_private`) of the given token. Wraps the generic
|
|
364
|
+
* `isFeemasterSponsored` and looks up the token's `programId` from the
|
|
365
|
+
* shieldable registry. Used by the widget to decide whether the
|
|
366
|
+
* "Shield Manually" CTA can dispatch silently or needs a user-paid fee
|
|
367
|
+
* confirmation modal first.
|
|
368
|
+
*/
|
|
369
|
+
isShieldSponsored(token: {
|
|
370
|
+
address?: string;
|
|
371
|
+
isNative?: boolean;
|
|
372
|
+
}): Promise<boolean>;
|
|
373
|
+
/**
|
|
374
|
+
* True when ANF's Feemaster policy currently sponsors `(programId,
|
|
375
|
+
* functionName)` on the connector-selected network. Used by the widget
|
|
376
|
+
* to decide whether to show a user-paid confirmation modal before a
|
|
377
|
+
* shield/send/join. Generic — applies to any (program, function) pair,
|
|
378
|
+
* not shield-specific. Never throws — returns `false` on any failure so
|
|
379
|
+
* callers default to "show modal" rather than silently dispatching.
|
|
380
|
+
*/
|
|
381
|
+
isFeemasterSponsored(args: {
|
|
382
|
+
programId: string;
|
|
383
|
+
functionName: string;
|
|
384
|
+
}): Promise<boolean>;
|
|
385
|
+
private resolveShieldableToken;
|
|
386
|
+
/**
|
|
387
|
+
* Shield (`transfer_public_to_private`) `amount` of the given token from
|
|
388
|
+
* the wallet's public balance into a fresh private record owned by self.
|
|
389
|
+
* Drives the widget's "Shield Manually" CTA on the Unshielded tab.
|
|
390
|
+
*
|
|
391
|
+
* `amount` is in the token's atomic units (microcredits for credits;
|
|
392
|
+
* `10^decimals` for stablecoin / ARC-21). The connector resolves the
|
|
393
|
+
* shield-shape registry by `tokenAddress` (matching the unshielded
|
|
394
|
+
* `TokenBalance.address` redcoast surfaces). Recipient is always self.
|
|
395
|
+
*
|
|
396
|
+
* Throws `DynamicError` if the token has no shield shape registered for
|
|
397
|
+
* the current network — those tokens shouldn't have rendered the CTA in
|
|
398
|
+
* the first place, but the throw is a safety net against a stale UI
|
|
399
|
+
* state slipping a doomed transaction past us.
|
|
400
|
+
*/
|
|
401
|
+
shieldToken(args: {
|
|
402
|
+
tokenAddress: string;
|
|
403
|
+
isNative?: boolean;
|
|
404
|
+
amount: bigint;
|
|
405
|
+
}): Promise<string>;
|
|
406
|
+
endSession(reason?: LogoutReason): Promise<void>;
|
|
407
|
+
getProvider(): undefined;
|
|
408
|
+
}
|
|
409
|
+
export {};
|