-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [abi] Add number of signers to the ABI * [refactor] Remove valueOf() * [view] Add BCS view functions * Update src/transactions/transactionBuilder/remoteAbi.ts Co-authored-by: Maayan <maayan@aptoslabs.com> * Update src/transactions/transactionBuilder/transactionBuilder.ts Co-authored-by: Maayan <maayan@aptoslabs.com> * [abi] Address comments * fix test * fix changelog --------- Co-authored-by: Maayan <maayan@aptoslabs.com>
- Loading branch information
1 parent
c2774d9
commit 19506cf
Showing
18 changed files
with
302 additions
and
127 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
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
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
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,35 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { LedgerVersionArg, MimeType, MoveValue } from "../types"; | ||
import { AptosConfig } from "../api/aptosConfig"; | ||
import { generateViewFunctionPayload, InputViewFunctionData } from "../transactions"; | ||
import { Serializer } from "../bcs"; | ||
import { postAptosFullNode } from "../client"; | ||
|
||
export async function view<T extends Array<MoveValue> = Array<MoveValue>>(args: { | ||
aptosConfig: AptosConfig; | ||
payload: InputViewFunctionData; | ||
options?: LedgerVersionArg; | ||
}): Promise<T> { | ||
const { aptosConfig, payload, options } = args; | ||
const viewFunctionPayload = await generateViewFunctionPayload({ | ||
...payload, | ||
aptosConfig, | ||
}); | ||
|
||
const serializer = new Serializer(); | ||
viewFunctionPayload.serialize(serializer); | ||
const bytes = serializer.toUint8Array(); | ||
|
||
const { data } = await postAptosFullNode<Uint8Array, MoveValue[]>({ | ||
aptosConfig, | ||
path: "view", | ||
originMethod: "view", | ||
contentType: MimeType.BCS_VIEW_FUNCTION, | ||
params: { ledger_version: options?.ledgerVersion }, | ||
body: bytes, | ||
}); | ||
|
||
return data as T; | ||
} |
Oops, something went wrong.