-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
176 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Account, Signature } from "../core"; | ||
import { createProofChallenge, 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 to query all `General` Aptos related queries | ||
*/ | ||
export class ProofChallenge { | ||
readonly config: AptosConfig; | ||
|
||
constructor(config: AptosConfig) { | ||
this.config = config; | ||
} | ||
|
||
async createProofChallenge(args: { | ||
struct: MoveFunctionId; | ||
data: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>; | ||
}): Promise<ProofChallengeInstance> { | ||
return createProofChallenge({ | ||
config: this.config, | ||
...args, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
signProofChallenge(args: { challenge: ProofChallengeInstance; signer: Account }): Signature { | ||
return signProofChallenge({ | ||
...args, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AptosConfig } from "../api/aptosConfig"; | ||
import { Account, Signature } from "../core"; | ||
import { EntryFunctionArgumentTypes, SimpleEntryFunctionArgumentTypes, generateProofChallenge } from "../transactions"; | ||
import { ProofChallenge } from "../transactions/instances/proofChallenge"; | ||
import { MoveFunctionId } from "../types"; | ||
|
||
export async function createProofChallenge(args: { | ||
config: AptosConfig; | ||
struct: MoveFunctionId; | ||
data: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>; | ||
}): Promise<ProofChallenge> { | ||
const challenge = generateProofChallenge({ ...args }); | ||
return challenge; | ||
} | ||
|
||
export function signProofChallenge(args: { challenge: ProofChallenge; signer: Account }): Signature { | ||
const { challenge, signer } = args; | ||
const challengeHex = challenge.bcsToBytes(); | ||
const signature = signer.sign(challengeHex); | ||
return signature; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Serializable, Serializer } from "../../bcs"; | ||
|
||
export class ProofChallenge extends Serializable { | ||
public readonly data: Serializable[]; | ||
|
||
constructor(data: Serializable[]) { | ||
super(); | ||
this.data = data; | ||
} | ||
|
||
serialize(serializer: Serializer): void { | ||
this.data.forEach((data) => { | ||
serializer.serialize(data); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.