Skip to content

Commit 3cd92e6

Browse files
committed
update SDK to handle new EffectiveAuditorConfig (untested though)
1 parent 1ea5bac commit 3cd92e6

File tree

3 files changed

+12
-134
lines changed

3 files changed

+12
-134
lines changed

confidential-assets/src/api/confidentialAsset.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import {
2222
hasUserRegistered,
2323
isBalanceNormalized,
2424
isIncomingTransfersPaused,
25-
getGlobalAuditorEpoch,
26-
getAuditorEpochForAssetType,
27-
getEffectiveAuditorEpoch,
2825
} from "../internal";
2926

3027
// Constants
@@ -481,57 +478,6 @@ export class ConfidentialAsset {
481478
});
482479
}
483480

484-
/**
485-
* Get the global auditor epoch counter.
486-
*
487-
* @param args.options - Optional ledger version for the view call
488-
* @returns The global auditor epoch
489-
*/
490-
async getGlobalAuditorEpoch(args?: { options?: LedgerVersionArg }): Promise<number> {
491-
return getGlobalAuditorEpoch({
492-
client: this.client(),
493-
moduleAddress: this.moduleAddress(),
494-
...args,
495-
});
496-
}
497-
498-
/**
499-
* Get the auditor epoch counter for a specific asset type.
500-
*
501-
* @param args.tokenAddress - The token address of the asset
502-
* @param args.options - Optional ledger version for the view call
503-
* @returns The asset-specific auditor epoch
504-
*/
505-
async getAuditorEpochForAssetType(args: {
506-
tokenAddress: AccountAddressInput;
507-
options?: LedgerVersionArg;
508-
}): Promise<number> {
509-
return getAuditorEpochForAssetType({
510-
client: this.client(),
511-
moduleAddress: this.moduleAddress(),
512-
...args,
513-
});
514-
}
515-
516-
/**
517-
* Get the effective auditor epoch: asset-specific epoch if the asset has an auditor,
518-
* otherwise global auditor epoch.
519-
*
520-
* @param args.tokenAddress - The token address of the asset
521-
* @param args.options - Optional ledger version for the view call
522-
* @returns The effective auditor epoch
523-
*/
524-
async getEffectiveAuditorEpoch(args: {
525-
tokenAddress: AccountAddressInput;
526-
options?: LedgerVersionArg;
527-
}): Promise<number> {
528-
return getEffectiveAuditorEpoch({
529-
client: this.client(),
530-
moduleAddress: this.moduleAddress(),
531-
...args,
532-
});
533-
}
534-
535481
/**
536482
* Normalize a user's balance.
537483
*

confidential-assets/src/internal/confidentialAssetTxnBuilder.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,25 @@ export class ConfidentialAssetTransactionBuilder {
268268
tokenAddress: AccountAddressInput;
269269
options?: LedgerVersionArg;
270270
}): Promise<TwistedEd25519PublicKey | undefined> {
271-
const [{ vec: effectiveAuditorPubKey }] = await this.client.view<[{ vec: { data: string }[] }]>({
271+
// EffectiveAuditorConfig::V1 { is_global: bool, config: AuditorConfig::V1 { ek: Option<CompressedRistretto>, epoch: u64 } }
272+
type EffectiveAuditorConfigResponse = {
273+
is_global: boolean;
274+
config: {
275+
ek: { vec: { data: string }[] };
276+
epoch: string;
277+
};
278+
};
279+
const [{ config }] = await this.client.view<[EffectiveAuditorConfigResponse]>({
272280
options: args.options,
273281
payload: {
274-
function: `${this.confidentialAssetModuleAddress}::${MODULE_NAME}::get_effective_auditor`,
282+
function: `${this.confidentialAssetModuleAddress}::${MODULE_NAME}::get_effective_auditor_config`,
275283
functionArguments: [args.tokenAddress],
276284
},
277285
});
278-
if (effectiveAuditorPubKey.length === 0) {
286+
if (config.ek.vec.length === 0) {
279287
return undefined;
280288
}
281-
return new TwistedEd25519PublicKey(effectiveAuditorPubKey[0].data);
289+
return new TwistedEd25519PublicKey(config.ek.vec[0].data);
282290
}
283291

284292
/**

confidential-assets/src/internal/viewFunctions.ts

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -284,79 +284,3 @@ export async function getEncryptionKey(
284284
}
285285
}
286286

287-
type AuditorEpochViewFunctionParams = {
288-
client: Aptos;
289-
tokenAddress: AccountAddressInput;
290-
options?: LedgerVersionArg;
291-
moduleAddress?: string;
292-
};
293-
294-
/**
295-
* Get the global auditor epoch counter.
296-
*
297-
* @param args.client - The Aptos client instance
298-
* @param args.options - Optional ledger version for the view call
299-
* @param args.moduleAddress - Optional module address
300-
* @returns The global auditor epoch as a number
301-
*/
302-
export async function getGlobalAuditorEpoch(args: {
303-
client: Aptos;
304-
options?: LedgerVersionArg;
305-
moduleAddress?: string;
306-
}): Promise<number> {
307-
const { client, options, moduleAddress = DEFAULT_CONFIDENTIAL_COIN_MODULE_ADDRESS } = args;
308-
const [epoch] = await client.view<[string]>({
309-
payload: {
310-
function: `${moduleAddress}::${MODULE_NAME}::get_global_auditor_epoch`,
311-
typeArguments: [],
312-
functionArguments: [],
313-
},
314-
options,
315-
});
316-
return Number(epoch);
317-
}
318-
319-
/**
320-
* Get the auditor epoch counter for a specific asset type.
321-
*
322-
* @param args.client - The Aptos client instance
323-
* @param args.tokenAddress - The token address of the asset
324-
* @param args.options - Optional ledger version for the view call
325-
* @param args.moduleAddress - Optional module address
326-
* @returns The asset-specific auditor epoch as a number
327-
*/
328-
export async function getAuditorEpochForAssetType(args: AuditorEpochViewFunctionParams): Promise<number> {
329-
const { client, tokenAddress, options, moduleAddress = DEFAULT_CONFIDENTIAL_COIN_MODULE_ADDRESS } = args;
330-
const [epoch] = await client.view<[string]>({
331-
payload: {
332-
function: `${moduleAddress}::${MODULE_NAME}::get_auditor_epoch_for_asset_type`,
333-
typeArguments: [],
334-
functionArguments: [tokenAddress],
335-
},
336-
options,
337-
});
338-
return Number(epoch);
339-
}
340-
341-
/**
342-
* Get the effective auditor epoch: asset-specific epoch if the asset has an auditor,
343-
* otherwise global auditor epoch.
344-
*
345-
* @param args.client - The Aptos client instance
346-
* @param args.tokenAddress - The token address of the asset
347-
* @param args.options - Optional ledger version for the view call
348-
* @param args.moduleAddress - Optional module address
349-
* @returns The effective auditor epoch as a number
350-
*/
351-
export async function getEffectiveAuditorEpoch(args: AuditorEpochViewFunctionParams): Promise<number> {
352-
const { client, tokenAddress, options, moduleAddress = DEFAULT_CONFIDENTIAL_COIN_MODULE_ADDRESS } = args;
353-
const [epoch] = await client.view<[string]>({
354-
payload: {
355-
function: `${moduleAddress}::${MODULE_NAME}::get_effective_auditor_epoch`,
356-
typeArguments: [],
357-
functionArguments: [tokenAddress],
358-
},
359-
options,
360-
});
361-
return Number(epoch);
362-
}

0 commit comments

Comments
 (0)