-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathproofChallenge.ts
More file actions
67 lines (61 loc) · 1.87 KB
/
proofChallenge.ts
File metadata and controls
67 lines (61 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
import { Account, Signature } from "../core";
import { createProofChallenge, getProofChallenge, signProofChallenge } from "../internal/proofChallenge";
import { MoveFunctionId } from "../types";
import { AptosConfig } from "./aptosConfig";
import { ProofChallenge as ProofChallengeInstance } from "../transactions/instances/proofChallenge";
import { EntryFunctionArgumentTypes, SimpleEntryFunctionArgumentTypes } from "../transactions/types";
/**
* A class for all `ProofChallenge` Aptos related operations
*/
export class ProofChallenge {
readonly config: AptosConfig;
constructor(config: AptosConfig) {
this.config = config;
}
/**
* Creates a generic proof challenge
*
* @param args.struct The struct address of the challenge
* @param args.data The struct arguments
*
* @returns ProofChallenge
*/
async createProofChallenge(args: {
struct: MoveFunctionId;
data: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
}): Promise<ProofChallengeInstance> {
return createProofChallenge({
config: this.config,
...args,
});
}
/**
* Get the proog challenge in a human readable format
*
* @param args.struct The struct name
* @param args.data The serialized challenge
* @returns
*/
async getProofChallenge(args: { struct: MoveFunctionId; data: Uint8Array }) {
return getProofChallenge({
config: this.config,
...args,
});
}
/**
* Signs a generic proof challenge
*
* @param args.challenge The generated challenge
* @param args.signer The signer account
*
* @returns Signature
*/
// eslint-disable-next-line class-methods-use-this
signProofChallenge(args: { challenge: ProofChallengeInstance; signer: Account }): Signature {
return signProofChallenge({
...args,
});
}
}